I have used lua on other games such as roblox, but every time has its own play on things so i am very very confused.
Im using luapad to do this.
x = 2 while true do x = x-1 timer.Create( "timer", 10, 1, function() if x == 1 then msg("x = 1") elseif x == 0 then msg("x = 0") else ("x = )... x) end end) end
All i could find about a “wait” function was timer.Create and i am very confused. Also this crashed my gmod client, so I am wondering if this caused an infinite loop despite my attempt on a wait function.
If someone could tell me what the hell I should use to “wait()” or “sleep()” so it doesnt infinite loop it would be much appreciated
PS I want this to repeat every 10 seconds, so that is why I am using while true do.
(also I wrote this from scratch so there may be some other errors, but please focus on my question. Thanks :downs: )
[editline]23rd December 2012[/editline]
x = 2 while true do x = x-1 timer.Simple(10, msg) if x == 1 then msg("x = 1") elseif x == 0 then msg("x = 0") else msg("x = not 1 or 0") end end
Came up with that after doing a bit more research ( I figured timer.Simple would be more simpler than timer.Create. but I’m not exactly sure on how to use it and what arguments to use.