Make the heat source more useful in Cooking
1 1

6 posts in this topic

Recommended Posts

Currently, the heat source is only used for make the food changing from "uncooked" to "cooked" (or "burned") .But the heat source can do better in real life. It supposed to have the ability to change item A to item B. 

For example, you put bread dough into fire, it should come out with bread (if it wasn't over cooked), not cooked bread dough.

So, is it possible, right now, to make a mod to allow the heat source to change a item to a completely new item? 

Share this post


Link to post
Share on other sites

I'm pretty sure this can be done already. You need to add an OnCooked line to the food item's stats that references a new lua function that removes the old item and adds a new one.

Pretty sure this was added when canning became a Base feature, so take a look at those items for a better idea of how it's done.

Share this post


Link to post
Share on other sites

I'm pretty sure this can be done already. You need to add an OnCooked line to the food item's stats that references a new lua function that removes the old item and adds a new one.

Pretty sure this was added when canning became a Base feature, so take a look at those items for a better idea of how it's done.

the lua files about the canned food?

Share this post


Link to post
Share on other sites

The lua for canning looks something like this

function CannedFood_OnCooked(cannedFood)    local aged = cannedFood:getAge() / cannedFood:getOffAgeMax();    cannedFood:setOffAgeMax(90);    cannedFood:setOffAge(60);    cannedFood:setAge(cannedFood:getOffAgeMax() * aged);--    print("new jared food age " .. cannedFood:getAge() .. " and max age " .. cannedFood:getOffAgeMax());end

What you are trying to do would be something more like this:

 

For the item you want to change into something else in the media\scripts folder

item FoodItem	{		HungerChange	=	-40,		Weight	=	0.3,		Type	=	Food,		IsCookable	=	TRUE,		DangerousUncooked	=	TRUE,		DaysTotallyRotten	=	4,		MinutesToBurn	=	70,		DisplayName	=	Steak,		Icon	=	Steak,		DaysFresh	=	2,		MinutesToCook	=	50,		EvolvedRecipe = Stew:15;Stir fry:15;Burger:15;Roasted Vegetables:15,		FoodType    =   Meat,                OnCooked    =    FoodItem_OnCooked, /Add this line/	}

and in the media\lua\server folder make a new .lua file with code like this

function FoodItem_OnCooked(items, player)    player:getInventory():AddItem("Module.NewFoodItem");end

I'm not the best with lua, but you'd also need to add something in there that removes the item being cooked from the container that it's in.

 

Hope that helps!

Share this post


Link to post
Share on other sites

The lua for canning looks something like this

function CannedFood_OnCooked(cannedFood)    local aged = cannedFood:getAge() / cannedFood:getOffAgeMax();    cannedFood:setOffAgeMax(90);    cannedFood:setOffAge(60);    cannedFood:setAge(cannedFood:getOffAgeMax() * aged);--    print("new jared food age " .. cannedFood:getAge() .. " and max age " .. cannedFood:getOffAgeMax());end
What you are trying to do would be something more like this:

For the item you want to change into something else in the media\scripts folder

item FoodItem	{		HungerChange	=	-40,		Weight	=	0.3,		Type	=	Food,		IsCookable	=	TRUE,		DangerousUncooked	=	TRUE,		DaysTotallyRotten	=	4,		MinutesToBurn	=	70,		DisplayName	=	Steak,		Icon	=	Steak,		DaysFresh	=	2,		MinutesToCook	=	50,		EvolvedRecipe = Stew:15;Stir fry:15;Burger:15;Roasted Vegetables:15,		FoodType    =   Meat,                OnCooked    =    FoodItem_OnCooked, /Add this line/	}
and in the media\lua\server folder make a new .lua file with code like this
function FoodItem_OnCooked(items, player)    player:getInventory():AddItem("Module.NewFoodItem");end
I'm not the best with lua, but you'd also need to add something in there that removes the item being cooked from the container that it's in.

Hope that helps!

Thank you.

I'll give it a try.

Share this post


Link to post
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
1 1