NotLuzeria Posted April 1, 2025 Share Posted April 1, 2025 Hello, I'm trying to make a mod where the character can craft a little chunk of slime using health, but my problems are that the item uses durability (instead of spoilage) and that it can't be eaten. I've attached the item's .lua and modmain.lua, ask me about any other information you may need! (Also, if anyone wants to help me with getting images to work in the crafting menu, that'd be awesome too) slime_chunk.lua modmain.lua Link to comment https://forums.kleientertainment.com/forums/topic/165171-help-with-modded-item-spoilage/ Share on other sites More sharing options...
yanecc Posted April 1, 2025 Share Posted April 1, 2025 FOODTYPE = { GENERIC = "GENERIC", MEAT = "MEAT", VEGGIE = "VEGGIE", ELEMENTAL = "ELEMENTAL", GEARS = "GEARS", HORRIBLE = "HORRIBLE", INSECT = "INSECT", SEEDS = "SEEDS", BERRY = "BERRY", RAW = "RAW", BURNT = "BURNT", ROUGHAGE = "ROUGHAGE", WOOD = "WOOD", GOODIES = "GOODIES", MONSTER = "MONSTER", }, There is no definition of FOODTYPE.SWEETENER. I think this should work: inst:AddComponent("edible") inst.components.edible.healthvalue = slimeChunkHealValue inst.components.edible.hungervalue = slimeChunkHungerValue inst.components.edible.sanityvalue = slimeChunkSanityValue inst:AddComponent("perishable") inst.components.perishable:SetPerishTime(slimeChunkSpoilTime) inst.components.perishable:StartPerishing() inst.components.perishable.onperishreplacement = "spoiled_food" Link to comment https://forums.kleientertainment.com/forums/topic/165171-help-with-modded-item-spoilage/#findComment-1810452 Share on other sites More sharing options...
NotLuzeria Posted April 2, 2025 Author Share Posted April 2, 2025 9 hours ago, yanecc said: There is no definition of FOODTYPE.SWEETENER. I think this should work: What FOODTYPE does honey and royal honey use then? I would like to be able to use the slime chunks to craft things like taffy and jellybeans. 9 hours ago, yanecc said: inst.components.perishable.onperishreplacement = "spoiled_food" I'd like for it to spoil into nothing instead, especially since the character's favourite food is most likely going to be rot. Apart from that, it is edible now, and it does actually spoil instead of deplete durability! Thanks! Link to comment https://forums.kleientertainment.com/forums/topic/165171-help-with-modded-item-spoilage/#findComment-1810562 Share on other sites More sharing options...
yanecc Posted April 2, 2025 Share Posted April 2, 2025 I recommend keeping it FOODTYPE.GENERIC as default (or use FOODTYPE.GOODIES). 10 hours ago, NotLuzeria said: I'd like for it to spoil into nothing instead Food would corrupt into nothing by default, just delete it. inst.components.perishable:SetOnPerishFn(inst.Remove) Link to comment https://forums.kleientertainment.com/forums/topic/165171-help-with-modded-item-spoilage/#findComment-1810621 Share on other sites More sharing options...
NotLuzeria Posted April 2, 2025 Author Share Posted April 2, 2025 4 hours ago, yanecc said: I recommend keeping it FOODTYPE.GENERIC as default (or use FOODTYPE.GOODIES). How can I make the item acceptable as a unit of sweetener for crockpots then? 4 hours ago, yanecc said: inst.components.perishable:SetOnPerishFn(inst.Remove) It now just no longer spoils at all? Link to comment https://forums.kleientertainment.com/forums/topic/165171-help-with-modded-item-spoilage/#findComment-1810664 Share on other sites More sharing options...
yanecc Posted April 3, 2025 Share Posted April 3, 2025 9 hours ago, NotLuzeria said: How can I make the item acceptable as a unit of sweetener for crockpots then? In your modmain.lua AddIngredientValues({ "slime_chunk" }, { sweetener = 1 }) 9 hours ago, NotLuzeria said: It now just no longer spoils at all? inst:AddComponent("perishable") inst.components.perishable:SetPerishTime(slimeChunkSpoilTime) inst.components.perishable:StartPerishing() inst.components.perishable:SetOnPerishFn(inst.Remove) Link to comment https://forums.kleientertainment.com/forums/topic/165171-help-with-modded-item-spoilage/#findComment-1810734 Share on other sites More sharing options...
NotLuzeria Posted April 3, 2025 Author Share Posted April 3, 2025 8 hours ago, yanecc said: AddIngredientValues({ "slime_chunk" }, { sweetener = 1 }) yuurpp!! this all works now, thanks 8 hours ago, yanecc said: inst:AddComponent("perishable") inst.components.perishable:SetPerishTime(slimeChunkSpoilTime) inst.components.perishable:StartPerishing() inst.components.perishable:SetOnPerishFn(inst.Remove) This didn't work, but adding inst.components.perishable:SetPercent(1) made it work, strangely. It spoiled before when it spoiled to rot, but making it spoil to nothing made it require this little bit... Thanks for the help! Link to comment https://forums.kleientertainment.com/forums/topic/165171-help-with-modded-item-spoilage/#findComment-1810783 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now