Search the Community
Showing results for tags 'timer'.
-
Hello everyone. After some frustrations, I've decided to give up and open a post here in hope I could get some help. I would like to make a button which needs to stay pressed for x sec / ms before calling its output. I don't know what my problem is, the script in itself is not complicated, but it seems I can't make it work... If you don't understand what I mean I made a little video which I hope will help you see the goal. rotbuttondemo.mp4 Another video of this kind of action can be found in this video at around 57 sec: I don't really care for the rotation of the button at the moment. I know the math and could easily implement it later. What I'm really interested in is the delay before the output and the detection of the player pressing the button. I've tried using the default button script and the trigger delay script but with no success. I could give you a scrap of code I made if it can help. Script.cleaningtime = 5000 --int "Cleaning time (ms)" function Script:Start() self.enable = true cleantimeleft=0 end function Script:Use() cleantimeleft = Time:GetCurrent() + self.cleaningtime while(window:KeyDown(Key.E))do --while the player is holding its use key down if Time:GetCurrent()>cleantimeleft and self.enable then System:Print("Clean!") self.component:CallOutputs("Used") end end end I don't know what I'm missing out. Whenever I try this the game freezes until the player release the use key... Anyway, thank you very much for the help.
- 6 replies
-
- timer
- help needed
-
(and 2 more)
Tagged with:
-
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!