So I’m back again, sorry haha:
I’m using CompileString to compile a function that will be used clientside, the setup right now is; I have a string which contains all the code that needs to be turned into a function, I create a new string like this:
CodeString = "local "..TIMER_ID.." = coroutine.create(function() "..CodeString.." end) timer.Create(tostring(math.random()), 2, 0, function() coroutine.resume("..TIMER_ID..") end)"
This, in theory should create a coroutine that is resumed every 2 seconds, this means that a player can use coroutine.wait(4) and the script will pause for however many seconds and then continue, my problem is that of course - you can’t have more than one coroutine running at a time, so when I the code:
Console.AddText("TESTING_") coroutine.wait(1) Console.AddText(" TESTING_")
It is ran perfectly, UNLESS there are two coroutines, then the text that was supposed to be added to console 1, only gets added to console 2, because the coroutine for console 1 is killed off.
I have a feeling I’m just being pretty stupid right now, but I can’t come up with any solutions that provide me with the ability to generate a coroutine out of player code that gives them the ability to use a wait function to pause the script for the specified amount of time and then continue.
Example: Chessnut’s unreleased Gterminal 2 features the wait() function, I’ve spoken to him and he replied telling me it was coroutines, if this was the case, how would I implement the wait function that doesn’t break if I spawn in another console?