Jump to content

Recommended Posts

Hello, I'm a beginner mod creator. I would like some help with a mod I'm creating. I will admit it's an edit and reupload of a mod but it doesn't say in the original mod description that it's not permitted. So if I do finish the mod and get it working, I promise to credit the original mod creator. So what I'm trying to do is add code so that all farm plants like all seasons. I've already got a configuration option working for this feature but I can't get the code itself to work. I tried using AI programs to write me code for this feature but I couldn't get the code to do anything. If anyone can lend me code to have all crops like all seasons (including modded ones), I would appreciate it and I will credit you in the mod description for it.

Sorry for the late response but the code you gave me isn't all that functional. The server doesn't seem to load with the direct code and when I correct the code from the logs, (add end after the second to last line) the server refuses to start. According to the logs, the subject "veggie" seems to cause problems with the server starting up.

Oh, sorry, there was indeed some error. The following code has been tested and works.

local PLANT_DEFS = require("prefabs/farm_plant_defs").PLANT_DEFS
for _, data in pairs(PLANT_DEFS) do
	data.good_seasons = { autumn = true, winter = true, spring = true, summer = true }
end


 

Edited by yanecc

It works! The season icons in the garden plant UI don't seem to show that they like all seasons, but crops grow like they would in their favored season! I need to run some more tests to make sure that the edited mod works 100% as intended before uploading it. But I promise when I do upload it, I will credit you. Thank you so much!

If a mod adds its new crops to farm_plant_defs, I think you can use AddSimPostInit like this:

local function SetAllSeasonsForPlants()
    local PLANT_DEFS = require("prefabs/farm_plant_defs").PLANT_DEFS

    for _, data in pairs(PLANT_DEFS) do
        data.good_seasons = { autumn = true, winter = true, spring = true, summer = true }
    end
end

AddSimPostInit(SetAllSeasonsForPlants)

In other cases, you must specifically adapt for it.

Edited by yanecc

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...