• Adjust speed of CONTINIOUS_USE
    1 replies, posted
I am making this entity and have the UseType set to CONTINIOUS_USE: [lua] self:SetUseType( CONTINUOUS_USE ) if ply:Health() < 100 then if self:Health() < 0 then self:Remove() end ply:SetHealth( ply:Health() + 1 ) self:SetHealth( self:Health() - 1 ) end [/lua] How do I make it slower.
Use a cooldown... Here's simple time controls: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/time/understanding_time%20and_basic_time_calculations.lua.html[/url] So, just make sure the elapsed time since last cache either has not been set, or has exceeded x time, then set the last cache time to CurTime, and continue with your hp. Otherwise don't enter the if, or return.. [code]if ( !self.LastHeal || CurTime( ) - self.LastHeal > 1 ) then -- run healing code here... self.LastHeal = CurTime( ); -- or here end[/code] Here's a system that does everything for you, if it is attached to an entity ( if not use game.GetWorld( )... ) [url]https://bitbucket.org/Acecool/acecooldev_base/src/master/gamemode/shared/entity/entity_setcooldown.lua?at=master[/url] [url]https://bitbucket.org/Acecool/acecooldev_base/src/master/gamemode/shared/entity/entity_hascooldown.lua?at=master[/url] [code]if ( !self:HasCooldown( "HealingDelay" ) ) then -- run healing code here... self:SetCooldown( "HealingDelay", 1 ); -- 1 second -- or here end[/code]
Sorry, you need to Log In to post a reply to this thread.