Jump to content

My Mod is breaking


Recommended Posts

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

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)	endend

Functions that already come with the beard component.

Edited by DarkXero
Link to comment
Share on other sites

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

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
 Share

×
×
  • Create New...