Jump to content

Checking stats


Recommended Posts

When does that fire? You need to check it every now and then.

So to make the constant check i need to make a loop?  With do while? This is where the code is located:

 

 

local fn = function(inst)-- 1inst.soundsname = "wolfgang"-- 2inst.MiniMapEntity:SetIcon( "wilson.png" )-- 3inst.components.health:SetMaxHealth(200)inst.components.hunger:SetMax(150)inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE*1.25)inst.components.sanity:SetMax(100)inst.components.combat.damagemultiplier = TUNING.WATHGRITHR_DAMAGE_MULTinst.components.locomotor.walkspeed = 5inst.components.locomotor.runspeed = 7if  inst.components.hunger.current  < 100 theninst.components.health.maxhealth =  TUNING.WATHGRITHR_HEALTH * 0.8inst.components.locomotor.walkspeed = 4inst.components.locomotor.runspeed = 6end

Maybe if i use a boolean value like the wolfgang prefab it'll work?

Link to comment
Share on other sites

So to make the constant check i need to make a loop?  With do while? This is where the code is located:

 

EDIT: Snip

 

Maybe if i use a boolean value like the wolfgang prefab it'll work?

 

Do NOT make a while loop. That will run indefinitely, effectively freezing the game.

 

Use this instead (period of 1 second for example purposes):

 

inst:DoPeriodicTask(1, function()

    if  inst.components.hunger.current  < 100 then

    inst.components.health.maxhealth =  TUNING.WATHGRITHR_HEALTH * 0.8

    inst.components.locomotor.walkspeed = 4

    inst.components.locomotor.runspeed = 6

    end

end)

 

Link to comment
Share on other sites

OOOOH , now i understood  .I made something similar to what you did BlueBerrys  with  a local function  and i put  the eventlistener in local fn = function(inst) . 

 

The only problem is , apparently , it only checks one time and the "else" part of the code doesn't work.  The code mobbstar showed worked  like  a charm , i never knew that  inst:DoPeriodicTask  existed.  Sorry for  my bad english, not my first language.

Link to comment
Share on other sites

Archived

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