Jump to content

Recommended Posts

Hello, I'm working on a character that gains health and hunger from growing his beard --- think Samson's hair. I have two code versions, but none of them works correctly.

This one works, but I have to exit and reload the save for it to update:

local function OnGrowShortBeard(inst)    inst.AnimState:OverrideSymbol("beard", "beard", "beard_short")    inst.components.beard.bits = BEARD_BITS[1]   inst.components.health:SetMaxHealth(TUNING.WILSON_HEALTH*1.5)    inst.components.hunger:SetMax(TUNING.WILSON_HUNGER*1.5)    inst.components.sanity:SetMax(TUNING.WILSON_SANITY/1.5)    return inst    endlocal function OnGrowMediumBeard(inst)    inst.AnimState:OverrideSymbol("beard", "beard", "beard_medium")    inst.components.beard.bits = BEARD_BITS[2]    inst.components.health:SetMaxHealth(TUNING.WILSON_HEALTH*2)    inst.components.hunger:SetMax(TUNING.WILSON_HUNGER*2)    inst.components.sanity:SetMax(TUNING.WILSON_SANITY/2)    return instendlocal function OnGrowLongBeard(inst)    inst.AnimState:OverrideSymbol("beard", "beard", "beard_long")    inst.components.beard.bits = BEARD_BITS[3]    inst.components.health:SetMaxHealth(TUNING.WILSON_HEALTH*3)    inst.components.hunger:SetMax(TUNING.WILSON_HUNGER*3)    inst.components.sanity:SetMax(TUNING.WILSON_SANITY/3)    return instend

and this one doesn't work at all

local function master_postinit(inst)-- Stats    if BEARD_DAYS >=3 then    inst.components.health:SetMaxHealth(TUNING.WILSON_HEALTH*1.5)    inst.components.hunger:SetMax(TUNING.WILSON_HUNGER*1.5)    inst.components.sanity:SetMax(TUNING.WILSON_SANITY/1.5)    end        elseif BEARD_DAYS >=7 then    inst.components.health:SetMaxHealth(TUNING.WILSON_HEALTH*2)    inst.components.hunger:SetMax(TUNING.WILSON_HUNGER*2)    inst.components.sanity:SetMax(TUNING.WILSON_SANITY/2)    end        elseif BEARD_DAYS >=11 then    inst.components.health:SetMaxHealth(TUNING.WILSON_HEALTH*3)    inst.components.hunger:SetMax(TUNING.WILSON_HUNGER*3)    inst.components.sanity:SetMax(TUNING.WILSON_SANITY/3)    end        else     inst.components.health:SetMaxHealth(TUNING.WILSON_HEALTH)    inst.components.hunger:SetMax(TUNING.WILSON_HUNGER)    inst.components.sanity:SetMax(TUNING.WILSON_SANITY)    endend

Any help would be appreciated. 

The second one should look like this:

local function master_postinit(inst) -- Stats    if BEARD_DAYS >=3 then    inst.components.health:SetMaxHealth(TUNING.WILSON_HEALTH*1.5)    inst.components.hunger:SetMax(TUNING.WILSON_HUNGER*1.5)    inst.components.sanity:SetMax(TUNING.WILSON_SANITY/1.5)         elseif BEARD_DAYS >=7 then    inst.components.health:SetMaxHealth(TUNING.WILSON_HEALTH*2)    inst.components.hunger:SetMax(TUNING.WILSON_HUNGER*2)    inst.components.sanity:SetMax(TUNING.WILSON_SANITY/2)         elseif BEARD_DAYS >=11 then    inst.components.health:SetMaxHealth(TUNING.WILSON_HEALTH*3)    inst.components.hunger:SetMax(TUNING.WILSON_HUNGER*3)    inst.components.sanity:SetMax(TUNING.WILSON_SANITY/3)         else    inst.components.health:SetMaxHealth(TUNING.WILSON_HEALTH)    inst.components.hunger:SetMax(TUNING.WILSON_HUNGER)    inst.components.sanity:SetMax(TUNING.WILSON_SANITY)    endend

 

The second one should look like this:

local function master_postinit(inst) -- Stats    if BEARD_DAYS >=3 then    inst.components.health:SetMaxHealth(TUNING.WILSON_HEALTH*1.5)    inst.components.hunger:SetMax(TUNING.WILSON_HUNGER*1.5)    inst.components.sanity:SetMax(TUNING.WILSON_SANITY/1.5)         elseif BEARD_DAYS >=7 then    inst.components.health:SetMaxHealth(TUNING.WILSON_HEALTH*2)    inst.components.hunger:SetMax(TUNING.WILSON_HUNGER*2)    inst.components.sanity:SetMax(TUNING.WILSON_SANITY/2)         elseif BEARD_DAYS >=11 then    inst.components.health:SetMaxHealth(TUNING.WILSON_HEALTH*3)    inst.components.hunger:SetMax(TUNING.WILSON_HUNGER*3)    inst.components.sanity:SetMax(TUNING.WILSON_SANITY/3)         else    inst.components.health:SetMaxHealth(TUNING.WILSON_HEALTH)    inst.components.hunger:SetMax(TUNING.WILSON_HUNGER)    inst.components.sanity:SetMax(TUNING.WILSON_SANITY)    endend

 

It doesn't crash, technically. I'm just stuck in a neverending loading screen

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