jiggawutt Posted May 29, 2019 Share Posted May 29, 2019 (edited) I was wondering if anyone knows how to check if a workshop mod has been enabled in the game or not? The issue is that my mod overwrites another mod called NeverRot. Now, NeverRot is just a three line conditional statement shoved into the SFarmingSystem:growPlant() function. Unfortunately, I can't just delete my version of this function as it's necessary for the new plants that my mod adds to the game. So, my thought is just to add another condition to see if NeverRot is enabled in-game. A clunkier version to this would be to check if the files from NeverRot exist, but I want people to have the choice to have NeverRot enabled or not. Does anyone have an elegant solution to this problem, or am I just going to have to rely on checking for NeverRot files in the workshop folder? Edited May 29, 2019 by jiggawutt Link to comment Share on other sites More sharing options...
Dr_Cox1911 Posted May 29, 2019 Share Posted May 29, 2019 This also works for workshop mods: jiggawutt 1 Link to comment Share on other sites More sharing options...
jiggawutt Posted May 29, 2019 Author Share Posted May 29, 2019 You're so handsome, Dr_Cox1911! Thank you for this! Link to comment Share on other sites More sharing options...
jiggawutt Posted May 29, 2019 Author Share Posted May 29, 2019 (edited) If anyone encounters the same issue I had, this is the exact modified code snippet I've put into my mod. This should be inserted within the if(luaObject.state == "seeded") branch inside the function SFarmingSystem:growPlant(luaObject, nextGrowing, updateNbOfGrow). The code this file overrides is from media/lua/server/Farming/SFarmingSystem.lua local actmods = getActivatedMods(); local activeNR = false; for i=0, actmods:size()-1, 1 do if actmods:get(i) == "FarmingNeverRot" then activeNR = true; break; end end if (activeNR) then --NeverRot is this if statement. if (luaObject.nbOfGrow >6) then luaObject.nbOfGrow = 6 end end Edited May 29, 2019 by jiggawutt Link to comment Share on other sites More sharing options...
Fenris_Wolf Posted May 29, 2019 Share Posted May 29, 2019 6 hours ago, Dr_Cox1911 said: This also works for workshop mods: Those functions are pretty redundant. getActivatedMods():contains("MyModName") Just use the contains() method instead of looping though the array. jiggawutt and Dr_Cox1911 1 1 Link to comment Share on other sites More sharing options...
jiggawutt Posted June 4, 2019 Author Share Posted June 4, 2019 (edited) On 5/29/2019 at 4:30 PM, Fenris_Wolf said: Those functions are pretty redundant. getActivatedMods():contains("MyModName") Just use the contains() method instead of looping though the array. Yeah, it appears as if maybe the break statement is causing the code to escape all the way out of every branch in the function, which broke farming. Putting this line as the condition for an if statement does the trick way better (and doesn't break farming). if (getActivatedMods():contains("FarmingNeverRot")) then --NeverRot is this if statement. if (luaObject.nbOfGrow >6) then luaObject.nbOfGrow = 6 end end Edited June 4, 2019 by jiggawutt Link to comment 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