Pausing a script.

In another framework I have worked with, there was a function called wait(), what it did was pause the script for that amount of time, thus allowing legitimate amounts of time before one part of a script proceeds, my question is, how do I do that in Gmod lua?

From my experience there’s not such a function in LUA. I would suggest taking a look at Timers or Hooks.

Gamemode Hooks? what he needs is a timer.

I was just thinking when i was starting i wanted something like this, just to find out later hooks were better suited for it.

Timer’s don’t pause scripts.
This isn’t implanted into GLua, I’m almost sure that it’s impossible to pause scripts with pure lua.

Actually if a for loop iteration takes one tick, and you had a ticks to second algorithm you could just do
function Wait(num)
for i = 1, secondstoticks(num) do
end
end

But I don’t know the limits of gmod lua.

That’s not pausing it. that’s just holding it up.

With coroutines you can, but these are broken in gmod anyway.

I know.

whats the difference?

The effect is the same. it’s just not actually pausing because it’s still busy at that time.

Cause it’s running on a different thread, right?

Lua isn’t threaded, so no, It’s just busy doing a different operation, once it’s done it will continue.

[editline]28th October 2011[/editline]

Also, by your logic if it was running in a different thread then it would do both simultaneously.

-snip-

Just found this post contained invalid information.