In a "for" "do" loop, have can you have more than one set of rules happening at once, for instance having:
'i' decreasing to 0, whilst 'a' increases to 2.
I would have imagined it would look like this, but it does not seem to work:
for i=1, 0, -0.1 do for a=1, 0, 0.1 do wait(0.5) print(i) print(a) end end
This is obviously just a scenario, however how do I get them both to count simultaneously on the output?
I don't know if this would be the most efficient way of doing this, but you could use coroutines, and it would look something like this:
coroutine.resume(coroutine.create(function() for i = 1,10 do print(i) wait() end end)) coroutine.resume(coroutine.create(function() for i = 1,10 do print("I'm printing!") wait() end end))
Two different scripts or two different threads; First one is pretty self explanatory so I won't explain that method.
You can create a new thread with the inbuilt spawn function, it takes a function parameter
spawn(function() while true do wait(1) print'Im looping :D' end end) print'i printed even with a loop above me'
for your case, something like this
spawn(function() for i = 1, 10 do print(i) end end) for i = 1, 20, 2 do print(i) end