This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
craftminer502's profile picture

[Lua][Variables] Help needed

Started by craftminer502, 14 April 2012 - 01:57 PM
craftminer502 #1
Posted 14 April 2012 - 03:57 PM
Hi is there anyway to count how many times a loop has run?
Like in java you can do var++. I can't find anything about it on lua.org.
Cloudy #2
Posted 14 April 2012 - 06:01 PM
var = var + 1.

If you're wanting to stop a loop after so many iterations, it may be better to use a for loop.
Wolvan #3
Posted 14 April 2012 - 10:52 PM
or if you are using while and want to break it use

if var == x then break end
or

while var < x do
[stuff you want to do]
end