Jump to content

Max Health


Recommended Posts

You need a function that updates the max health, and fire it every new day. My suggestion:


local function SetHealth(inst)
    inst.components.health.maxhealth =
BASE_VALUE + PER_DAY * GetClock().numcycles --change the capitalised values

local function fn() --you already have this line
[...] --some stuff



Link to comment
Share on other sites

How do I setup that function to do the listenevent. This is what I have just for testing the event. 


local GetClock = GLOBAL.GetClock
local GetWorld = GLOBAL.GetWorld
local function SetHealth(inst)
    inst.components.health.maxhealth = 200
local function test( inst )
inst.components.health.maxhealth = 150
AddPrefabPostInit("wilson", test)
But can't get it to work. I get this error
../mods/1TESTING/modmain.lua:5: attempt to index field 'health' (a nil value)
LUA ERROR stack traceback:
        ../mods/1TESTING/modmain.lua(5,1) in function 'fn'
        scripts/entityscript.lua(631,1) in function 'PushEvent'
        scripts/components/clock.lua(439,1) in function 'StartDay'
        scripts/components/clock.lua(233,1) in function 'NextPhase'
        scripts/components/clock.lua(309,1) in function 'OnUpdate'


Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

  • Create New...