Search the Community
Showing results for tags 'Timer'.
-
I've been working on a script that's based on an old reepblue script he included in his old lex template. I want it to damage the player as long as he's inside the trigger box, but right now, it just kills him outright, can't get the timer to work I think, what am I doing wrong? Script.enabled=true --bool "Start Enabled" Script.entered = false Script.exited = false Script.hadCollision = false Script.RefireTime = 1.0 -- float "Refire Time" Script.Timer = 0 Script.Tipped=false Script.damage=10--int "Damage" function Script:Start() self.enabled=true end function Script:UpdatePhysics() if self.enabled then if self.entered then if self.hadCollision == false then if self.exited == false then self.component:CallOutputs("onendTouchAll") --System:Print("onendTouchAll") self.Timer = 0 self.Tipped=false self.entered = false end end end self.hadCollision = false end end function Script:Collision(entity, position, normal, speed) if self.enabled then if entity:GetKeyValue("name") == "FPSPlayer" then self.hadCollision = true entity:AddForce(0,0,0) if self.entered == false then self.component:CallOutputs("onstartTouch") --System:Print("onstartTouch") self.entered = true self.exited = false end if not self.Tipped then self:Trigger(entity) end end end end function Script:UpdateWorld() if self.enabled and self.entered then -- A negitive value will disable this. if self.Tipped and self.RefireTime >= 0 then self.Timer = self.Timer + (Time:GetSpeed()/100) if self.Timer > self.RefireTime then self.Timer = 0 end end end end function Script:Trigger(entity) self.component:CallOutputs("OnTriggerTick") --System:Print("OnTriggerTick") -- Hurt the activator! if entity.script then if self.Timer == 0 then if type(entity.script.Hurt)=="function" then entity.script:Hurt(self.damage) end end end end function Script:Enable()--in if self.enabled==false then self.enabled=true end end function Script:Disable()--in if self.enabled then self.enabled=false end end
-
I am making a contraption that is sort of like pistons, and know how to make everything except a timer to keep them moving. I was thinking I could create a pivot to have an output (that I could manage in the FlowGraph editor), and just have it loop the output with a delay of about a second before it loops again. To quickly summarize How to program an output that will be displayed in the FlowGraph editor How to loop it with a delay between outputs How to have it not stop until I want it to. Thank you
-
Can someone please tell me a good way to do a timer that starts when the game starts and ends if a object is touched? I tryed many things but it doesnt worked. Thanks for your Answeres!