Anstarveo Posted March 14, 2017 Share Posted March 14, 2017 (edited) local function RegenFn(inst) if inst:HasTag("playerghost") then return end if inst.transformed then inst:AddTag("canmove") inst:RemoveTag("nomove") inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED) inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 0.75) inst.components.combat.damagemultiplier = 1 inst.components.sanity.dapperness = TUNING.DAPPERNESS_TINY *0.01 else inst:AddTag("nomove") inst:RemoveTag("canmove") inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 0.00) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 0.00) inst.components.temperature.inherentinsulation = 120 inst.components.temperature.inherentsummerinsulation = 60 inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 0.25) inst:DoPeriodicTask(15, ???????????? inst.components.sanity.dapperness = TUNING.DAPPERNESS_HUGE * Z end I want to have number Z increases by 1 ever 15 seconds but so far can't figure it out. Edited March 18, 2017 by Anstarveo Link to comment Share on other sites More sharing options...
Anstarveo Posted March 14, 2017 Author Share Posted March 14, 2017 (edited) I just want to set a number P = 0 and make it increase by 1 every 15s. Wait...how can I delete the above post? Edited March 14, 2017 by Anstarveo Link to comment Share on other sites More sharing options...
Serpens Posted March 14, 2017 Share Posted March 14, 2017 if you found a solution already, do not delte your post, just post the solution, so others can learn from it And yes, it should be "DoPeriodicTask" If you don't know how to use the function, simply do a search for it in all the game files. There you will have tons of examples And you will also see where it is defined, in entityscript.lua:EntityScript:DoPeriodicTask(time, fn, initialdelay, ...) Here you can see how to use notepad++ to serach all lua scripts at once: Link to comment Share on other sites More sharing options...
Anstarveo Posted March 14, 2017 Author Share Posted March 14, 2017 (edited) I couldn't find my answer in the game files, because the answer is too simple. I found it out the hard way >_< Here is my solution, inside (your mod name).lua put this: inst:DoPeriodicTask(1, sanRe, 15) inside: local master_postinit = function(inst) and put this: local zzz = -1 local function sanRe(inst) if inst:HasTag("nomove") then zzz = zzz + 1 inst.components.sanity.dapperness = TUNING.DAPPERNESS_TINY * (zzz/2) else inst.components.sanity.dapperness = 0 zzz = -1 end end into (your mod name).lua The "nomove" is my custom tag. Purpose of the script: the longer I stay in "nomove" state, the faster my sanity will regen, take 15s to start. Edited March 14, 2017 by Anstarveo Link to comment 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