FatalVitality Posted December 6, 2015 Share Posted December 6, 2015 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 instendand this one doesn't work at alllocal 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) endendAny help would be appreciated. Link to comment https://forums.kleientertainment.com/forums/topic/60266-help-game-doesnt-update-stats-using-my-code/ Share on other sites More sharing options...
TheDonkeyQueen Posted December 6, 2015 Share Posted December 6, 2015 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 Link to comment https://forums.kleientertainment.com/forums/topic/60266-help-game-doesnt-update-stats-using-my-code/#findComment-693535 Share on other sites More sharing options...
FatalVitality Posted December 6, 2015 Author Share Posted December 6, 2015 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 Link to comment https://forums.kleientertainment.com/forums/topic/60266-help-game-doesnt-update-stats-using-my-code/#findComment-693538 Share on other sites More sharing options...
FatalVitality Posted December 6, 2015 Author Share Posted December 6, 2015 It doesn't crash, technically. I'm just stuck in a neverending loading screenIt crashed when I tried making a new world and spawning in it as the character. Link to comment https://forums.kleientertainment.com/forums/topic/60266-help-game-doesnt-update-stats-using-my-code/#findComment-693541 Share on other sites More sharing options...
TheDonkeyQueen Posted December 6, 2015 Share Posted December 6, 2015 It crashed when I tried making a new world and spawning in it as the character.I'm no master at this, but you might wanna look at transformation on Woodie Link to comment https://forums.kleientertainment.com/forums/topic/60266-help-game-doesnt-update-stats-using-my-code/#findComment-693572 Share on other sites More sharing options...
Mobbstar Posted December 6, 2015 Share Posted December 6, 2015 um... "beard_days" is a table, right? A list of numbers? you can't compare the whole table with individual numbers. Link to comment https://forums.kleientertainment.com/forums/topic/60266-help-game-doesnt-update-stats-using-my-code/#findComment-693656 Share on other sites More sharing options...
FatalVitality Posted December 6, 2015 Author Share Posted December 6, 2015 um... "beard_days" is a table, right? A list of numbers? you can't compare the whole table with individual numbers.would you know a way I can work around it? I'm a bit stuck Link to comment https://forums.kleientertainment.com/forums/topic/60266-help-game-doesnt-update-stats-using-my-code/#findComment-693667 Share on other sites More sharing options...
Mobbstar Posted December 6, 2015 Share Posted December 6, 2015 would you know a way I can work around it? I'm a bit stuck Did you take a look at how Wilson and the beefalos do it? Link to comment https://forums.kleientertainment.com/forums/topic/60266-help-game-doesnt-update-stats-using-my-code/#findComment-693675 Share on other sites More sharing options...
FatalVitality Posted December 7, 2015 Author Share Posted December 7, 2015 Did you take a look at how Wilson and the beefalos do it?Yes, however neither of their status is changed whether or not they have their beard. I have the beard growing, but the stats doesn't update. Link to comment https://forums.kleientertainment.com/forums/topic/60266-help-game-doesnt-update-stats-using-my-code/#findComment-694008 Share on other sites More sharing options...
ZupaleX Posted December 8, 2015 Share Posted December 8, 2015 You posted the "On..." function but did you make the correct ListenForEvent callbacks? Link to comment https://forums.kleientertainment.com/forums/topic/60266-help-game-doesnt-update-stats-using-my-code/#findComment-694952 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