• Pausing a script.
    13 replies, posted
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 [url=http://wiki.garrysmod.com/?title=Timer]Timers[/url] or [url=http://wiki.garrysmod.com/?title=Gamemode_Hooks]Hooks[/url].
[QUOTE=MayorBee;32988202]From my experience there's not such a function in LUA. I would suggest taking a look at [url=http://wiki.garrysmod.com/?title=Timer]Timers[/url] or [url=http://wiki.garrysmod.com/?title=Gamemode_Hooks]Hooks[/url].[/QUOTE] Gamemode Hooks? what he needs is a timer.
[QUOTE=Gustavgr16;32989823]Gamemode Hooks? what he needs is a timer.[/QUOTE] 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.
[QUOTE=_NewBee;32994835]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.[/QUOTE] With coroutines you can, but these are broken in gmod anyway.
[QUOTE=Wizard of Ass;32997441]but these are broken in gmod anyway.[/QUOTE] I know.
[QUOTE=_NewBee;32995990]That's not pausing it. that's just holding it up.[/QUOTE] whats the difference?
[QUOTE=Stonna;32997930]whats the difference?[/QUOTE] The effect is the same. it's just not actually pausing because it's still busy at that time.
[QUOTE=_NewBee;33004678]The effect is the same. it's just not actually pausing because it's still busy at that time.[/QUOTE] 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.
[QUOTE=Stonna;33014321]Lua isn't threaded, so no, It's just busy doing a different operation, once it's done it will continue.[/QUOTE] -snip- Just found this post contained invalid information.
Sorry, you need to Log In to post a reply to this thread.