• My new addon ( Can't make ENT:NextThink() work )
    7 replies, posted
[url]http://wiki.garrysmod.com/page/Entity/NextThink[/url] I have made a simular code ( with Msg() instead of print() ) , to test how ENT:NextThink() ( written as self:NextThink( CurTime() + 1 ) and ENT:Think() works and I am modifying custom values in my ENT, such as "ENT.On" and also Triggering Wire output to 1/0 Every Think like so: [code] ENT:Think() Msg("Blah !") if( self.On == 1 ) then -- So this is how it should be then according to ralle105 ? ... Wire_TriggerOutput(self,"Test",1) self.On = 0 elseif( self.On == 0 ) Wire_TriggerOutput(self,"Test",0) self.On = 1 end self:NextThink(CurTime() + 1) -- < This makes me mad return true end [/code] The first run it will enter the if, and the next one else, leading to swing my Test NORMAL value after i Use Wire Debugger tool from 1 to 0 as vice versa ( 1 0 1 0 1 0 ... every second ) I have put this in lua\entities\gmod_entname\init.lua ( using "ents.Create( "gmod_entname" )" that is ) :/
Lua treats 0 as true in an if statement, use true/false instead of 1/0
But still if so, i have to get many "Blah !" - s instead of only one or two ... also Nice avatar :) Gmod will go for the first IF, Setting the wire output to 1, but it stays in 0 :/
Think is called every frame.
[QUOTE=Handsome Matt;43473853]What do you think NextThink does?[/QUOTE] Hmmm... It should be since i am calling it inside ENT:Think() it will be set at the next second Have to set the condition to (self.On == 0) as ralle105 said though ...
[QUOTE=Handsome Matt;43473853]What do you think NextThink does?[/QUOTE] My bad :v:
Hi guys it works now you can mark it as [SOLVED] Regards DVD !
Sorry, you need to Log In to post a reply to this thread.