Jump to content

Creating parody crockpot food items


Recommended Posts

I am trying to make it when you cook a meal in Warly's crockpot, the lowest stat of the food is increased by 30%. This is the current code I have:

local foods = require("preparedfoods")
for k,recipe in pairs (foods) do
    local p = recipe
    p.priority = p.priority + 10

    if (p.health < p.sanity and p.health < p.hunger) then
        p.health = p.health * 1.3
    end
    if (p.sanity < p.health and p.sanity < p.hunger) then
        p.sanity = p.sanity * 1.3
    end
    if (p.hunger < p.sanity and p.hunger < p.health) then
        p.hunger = p.hunger * 1.3
    end

    p.name = "warly_" .. p.name
    p.no_cookbook = true

	AddCookerRecipe("portablecookpot", p)
end

This works, but when the food comes out it has no texture or anything. How would I either change the stats of an individual item, or change the texture of an item created by AddCookerRecipe

Link to comment
Share on other sites

On 4/4/2021 at 5:11 AM, decduck3 said:

This works, but when the food comes out it has no texture or anything. How would I either change the stats of an individual item, or change the texture of an item created by AddCookerRecipe

If you make a seperate prefab to 'parody' the crockpot item, it's always going to be invisible. It's an intrinsic flaw with how the preparedfood anims work. Given by what you've made here though you're for sure better at coding than I, but maybe you could make it so any food that comes out of warly's cookpot gets a tag, and then modify the eater component to raise the lowest stat of the food by 30% when eaten if the food has X tag? Idk just spitballing.

Link to comment
Share on other sites

I'm not familiar with tags. So, I'm guessing, that you add a tag, then you can check if an item has that tag later? How would that work with stacking items and such? Can you add tags after an item has been created?

Link to comment
Share on other sites

On 4/5/2021 at 7:18 PM, decduck3 said:

I'm not familiar with tags. So, I'm guessing, that you add a tag, then you can check if an item has that tag later? Can you add tags after an item has been created?

Yes and Yes. Although i am completely unfamiliar with how tags would work in conjunction with stacking, it wouldnt be hard to experiment with to find out. Tags are by far one of the most powerful tools in a modders toolkit so I suggest you do learn about them. You can add a taq by doing x:AddTag("tag"), remove them by doing x:RemoveTag("tag") and check if X has a tag with  x:HasTag("tag")

Link to comment
Share on other sites

So far, this is what I've done. In the stewer component, I created a value called foodtag, and used this code to assign the tag

if self.foodtag ~= nil then
	loot:AddTag(self.foodtag)
end

And then in portablecookpot.lua, I do this:

inst.components.stewer.foodtag = "warlyfood"

And then in eater.lua, I have this for each stat:

if food:HasTag("warlyfood") then
	if healthf < hungerf and healthf < sanityf then
		self.inst.components.health:DoDelta(delta * stack_mult * 0.3, nil, food.prefab)
	end
end

Where the different values are set as each:

local healthf = food.components.edible:GetHealth(self.inst) * base_mult * self.healthabsorption
local hungerf = food.components.edible:GetHunger(self.inst) * base_mult * self.hungerabsorption
local sanityf = food.components.edible:GetSanity(self.inst) * base_mult * self.sanityabsorption

But it still isn't working, and I have no idea why. Any ideas? (btw, I did do a test where I just used health:DoDelta(900), and it worked)

 

Follow up question: How do I make it that the food is called "Warly's ....." eg "Warly's Meatballs"

Edited by decduck3
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
 Share

×
  • Create New...