Christo1 Posted July 18, 2015 Share Posted July 18, 2015 Hey I have been working on my first character mod and I have been trying to get it so that in the winter my character's beard will grow. The following is what I have been trying to use to get it to do so.local yes = {1, 6, 9}local no = {100, 101, 102}local function beardf()if TheWorld.state.season == "winter" thenreturn yeselsereturn noendendlocal BEARD_DAYS = beardf()local BEARD_BITS = { 1, 6, 9 }It works fine if i replace the "if TheWorld.state.season == "winter" then" line with something like "if 1>0 then" so I know that the local BEARD_DAYS is getting the information it needs from the yes and no. The problem comes from me trying to get what season it is. I have been trying to use other parts of other files (like this particular try was from the bearger's hibernation function) but I can't seem to get it. Could anyone help? Link to comment Share on other sites More sharing options...
DarkXero Posted July 20, 2015 Share Posted July 20, 2015 (edited) If you are putting this in modmain then you have to put GLOBAL.TheWorld to not index a nil value.This shouldn't crash. What is the context for this code? What you can also do, in your character's master_postinit:inst:AddComponent("beard")inst:WatchWorldState("season", AdjustGrowth)AdjustGrowth(inst, TheWorld.state.season)in the prefab, outside the master_postinit:local function AdjustGrowth(inst, season) if season == "winter" then inst.components.beard:EnableGrowth(true) else inst.components.beard:EnableGrowth(false) endendFunctions that already come with the beard component. Edited July 20, 2015 by DarkXero Link to comment Share on other sites More sharing options...
Christo1 Posted July 20, 2015 Author Share Posted July 20, 2015 Thank you. That worked, and I didn't know that the beard actuially had a function that enabled/disabled growth. I did actuiallly get my way to work (sorta) in a really ghetto fasion. But I went ahead and used that way better because it was more of what I wanted to do in the first place. 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