Jump to content

Changing spoilage rate of specific items?


Ran

Recommended Posts

I'm not much a modder, but I often customize other mods to my liking, and have made a few very tiny "mods" myself, based on the knowledge I gather from reading other people's work. But I have no idea how to do this, and can't find any updated mods that do it, to see how they do it.

 

I've modified seeds perish rate before, cause I found they have their own .lua file. Mind you, I only ever managed to modify normal seeds, never crop ones, so that was still only half success. But regardless, now I'm trying to change perish rate of birchnuts, and I can't find that at all.

 

Anyone has any idea?

 

For the record, the ability to remove spoilage from them altogether would be equally useful, but I dunno how to do that either.

Link to comment
Share on other sites

You can simply use the AddPrefabPostInit function in the modmain.lua like so:

 

function BetterNuts(inst) --you can call the function elsehow too

    inst.components.perishable.perishtime = TUNING.PERISH_FAST --set the time to something else, ideally a tuning value

    inst:RemoveComponent("perishable") --remove spoilage entirely

end

 

AddPrefabPostInit("acorn",BetterNuts) --after making the editing function, attach it to the birch nut (acorn)

Link to comment
Share on other sites

Wow, so I don't even need to know where the "acorn" is? Honestly that's all pretty unknown to me, lol. I mean I can get some logic out of it, but the most I've ever done was change tuning.lua flat values through a modmain.lua. I have no idea about functions and such. In fact, I tried to change the duration of an item before (Blue Amulet), but I couldn't cause apparently using things like "total_day_time" needs something else. Probably some sort of call to that variable so it knows what it is.

 

So it's one or the other, right? The first part would be to change perish time, and the second to remove it, I don't need both? And could I add other items at the end there? Use that AddPrefabPostInit multiple times with different stuff?

 

Sorry if it's too many questions, I'm just glad someone who knows this stuff answered :p

Link to comment
Share on other sites

Yes you're meant to use one of those lines or the other.  No point in setting a perishable rate when you then remove the component completely afterwards =-)

 

Also you can use the wiki to find the prefab names of objects because they're not always in an easy to find file.

Link to comment
Share on other sites

 

 

Sorry if it's too many questions, I'm just glad someone who knows this stuff answered :razz:

The only time its possible to ask 'too many questions' is when the person asking the question doesnt put in as much effort to fully understand the response, as the responder spent in writing it.  

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...