lxFirebal69xl Posted November 21, 2016 Share Posted November 21, 2016 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 Quote Link to comment Share on other sites More sharing options...
reepblue Posted November 21, 2016 Share Posted November 21, 2016 Try playing with self.RefireTime and/or Time:GerSpeed() Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.