Page 1 of 1

Lua Please help

Posted: Sat Nov 03, 2012 3:51 am
by muttley1968
Hello i am wrighting a program for computercraft which uses the language lua i have wrote this
Code: Select all
mon = peripheral.wrap("top")
term.redirect(mon)

while true do
counter = 1
counter = counter + 1 
mon.clear()
mon.setCursorPos(1,1)
mon.setTextScale(2)
print("Welcome to Tekkitwars")
print("")
local nTime = os.time()
print("Current in game Time: "..textutils.formatTime( nTime, false ) )
print("")
print("Counter = "..counter)
sleep(1)
end
Which works bare the fact that the counter does not count it just goes to 2 and then stops does anyone know how to fix this or why.

my aim is to build it into a stop watch so it will be (current round: 0:0:0) if anyone fancys fixing the code for me in that format but i could probally figure it out should counter error be fixed

Re: Lua Please help

Posted: Sat Nov 03, 2012 6:55 am
by Ffenixw0rks
Code: Select all
 while true do
counter = 1 // Problem. Counter will be set to 1 on each loop
counter = counter + 1 
You should use
Code: Select all
 counter = 1
while true do
counter = counter + 1