Jump to content

Lua spawning an item using ..._OnCreate


lance789

Recommended Posts

So, so im trying to figure out how to spawn an item added by a mod directly into player inventory but whenever i use the associated recipe, the items needed gets used but the item doesn't spawn...

 

Example:

 

Item:

module Extended_Foods{    imports        {            Base        }item ChickenRamenPot_3_5   {	HungerChange		=	-60,	Type				=	Food,	DisplayName			=	Pot of Chicken Flavoured Ramen,	MinutesToCook		=	30,	Weight				=	3,	IsCookable			=	True,	DaysTotallyRotten	=	10,	UnhappyChange		=	90,	FatigueChange		=	+80,	StressChange		=	+70,	MinutesToBurn		=	30,	Icon				=	EFM_BLANK,	ReplaceOnUse		=	Pot,	DaysFresh			=	5,	//BoredomChange		=	30,	DangerousUncooked	=	TRUE,   }}

Recipe:

module Extended_Foods{    imports        {            Base        }recipe Make ThreeFifths Pot of Ramen Chicken Flavor   {	ChickenRamenBowl=3,	Pot,	Result:Bowl=3,	Time:20.0,   }}

3 Bowls Combined to make 3/5 of a Pot of Ramen:

-- Recipe LUA-- Made by: Svarog-- (I added in this pot of ramen data)-- Pot of Ramen - B2P (3/5)function RecipeMake ThreeFifths Pot of Ramen Chicken Flavor_OnCreate(items, result, player)	local inv = player:getInventory();	inv:AddItem("Extended_Foods.ChickenRamenPot");

So every time i've made 3 Ramen Bowls and combined them, i'd get the 3 bowls back (so thats good), but no 3/5Ramen Pot...

 

Could anyone please help me sort out how to get this properly working?

Ive already have the codes for all ramen chicken "bowls -> pot", "pot -> bowls", and "pot -> pot" combinations done, i just need to get the Lua working. D:

Link to comment
Share on other sites

So, so im trying to figure out how to spawn an item added by a mod directly into player inventory but whenever i use the associated recipe, the items needed gets used but the item doesn't spawn...

 

Example:

 

Item:

module Extended_Foods{    imports        {            Base        }item ChickenRamenPot_3_5   {	HungerChange		=	-60,	Type				=	Food,	DisplayName			=	Pot of Chicken Flavoured Ramen,	MinutesToCook		=	30,	Weight				=	3,	IsCookable			=	True,	DaysTotallyRotten	=	10,	UnhappyChange		=	90,	FatigueChange		=	+80,	StressChange		=	+70,	MinutesToBurn		=	30,	Icon				=	EFM_BLANK,	ReplaceOnUse		=	Pot,	DaysFresh			=	5,	//BoredomChange		=	30,	DangerousUncooked	=	TRUE,   }}

Recipe:

module Extended_Foods{    imports        {            Base        }recipe Make ThreeFifths Pot of Ramen Chicken Flavor   {	ChickenRamenBowl=3,	Pot,	Result:Bowl=3,	Time:20.0,   }}

3 Bowls Combined to make 3/5 of a Pot of Ramen:

-- Recipe LUA-- Made by: Svarog-- (I added in this pot of ramen data)-- Pot of Ramen - B2P (3/5)function RecipeMake ThreeFifths Pot of Ramen Chicken Flavor_OnCreate(items, result, player)	local inv = player:getInventory();	inv:AddItem("Extended_Foods.ChickenRamenPot");

So every time i've made 3 Ramen Bowls and combined them, i'd get the 3 bowls back (so thats good), but no 3/5Ramen Pot...

 

Could anyone please help me sort out how to get this properly working?

Ive already have the codes for all ramen chicken "bowls -> pot", "pot -> bowls", and "pot -> pot" combinations done, i just need to get the Lua working. D:

 

well, your lua should be:

-- Recipe LUA-- Made by: Svarog-- (I added in this pot of ramen data)-- Pot of Ramen - B2P (3/5)function Flavor_OnCreate(items, result, player)	local inv = player:getInventory();	inv:AddItem("Extended_Foods.ChickenRamenPot");end

and your recipe needs to have:

module Extended_Foods{    imports        {            Base        }recipe Make ThreeFifths Pot of Ramen Chicken Flavor   {	ChickenRamenBowl=3,	Pot,	OnCreate:Flavor_OnCreate	Result:Bowl=3,	Time:20.0,   }}
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...