Lua Please help

Questions/Tutorials for any programming language not covered in other sections.
2 posts Page 1 of 1
Contributors
User avatar
muttley1968
Hardcore Programmer
Hardcore Programmer
Posts: 622
Joined: Thu Jun 17, 2010 11:54 pm

Lua Please help
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
User avatar
Ffenixw0rks
VIP - Donator
VIP - Donator
Posts: 152
Joined: Sun Jun 19, 2011 2:51 pm

Re: Lua Please help
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 
Image
2 posts Page 1 of 1
Return to “Misc”