|
function Wait(seconds)
A = os.clock()
v = A + seconds
while true do
if os.clock() ~= v then
end
end
end
Wait(2)
print 'lol'
This is what I have so far (using SciTE), when I write 'Wait(2)' the loop doesn't end, and I wind up having to break the script.
How can I fix it? |
|
|
function Wait(seconds)
A = os.clock()
v = A + seconds
while wait() do
if os.clock() ~= v then
end
end
end
Wait(2)
print 'lol'
Also, where did you get os.clock() from? |
|
|
while os.clock ~= v do
end
Or
while true do
if os.clock() ~= v then
break
end
end
You never put anything that would let the loop stop/exit. |
|
|
http://www.lua.org/manual/5.1/manual.html#pdf-os.clock |
|
|
@Silver: wait() is a roblox-specific function. I believe that os is a standard Lua library ._. |
|
|
@patato
it waits 3 seconds .. :c |
|
|
Off topic, but I never realized how many math functions there are.
I could return e with math.exp(1)! My life is complete! |
|
|
If you don't mind me asking, how is this off-topic? |
|
|
function Wait(t)
s=time()
repeat wait()
until time()-s>=t
end |
|
|
Yes, I know that defeats the purpose =P |
|
nightnameJoin Date: 2008-06-10 Post Count: 8960 |
Here is the custom wait command I use while I am not playing on Roblox:
function wait(delay)
delay = delay or 1
local time_to = tick() + delay
while tick() < time_to do end
end
Hope this helps! |
|
nightnameJoin Date: 2008-06-10 Post Count: 8960 |
Wait... I forgot to edit it... Here is the right one. The other one was for my Roblox uses XD
function wait(delay)
delay = delay or 1
local time_to = os.time() + delay
while os.time() < time_to do end
end |
|
|
I'm using SciTE..
lua: cmath.lua:5: attempt to call field 'tick' (a nil value)
stack traceback:
cmath.lua:5: in function 'wait'
cmath.lua:10: in main chunk
[C]: ?
>Exit code: 1
That's from your wait command, nightmare. |
|
|
nightnameJoin Date: 2008-06-10 Post Count: 8960 |
Sorry about that... I copied and pasted it from my Notepad++.
I save all my functions somewhere XD |
|