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

Having trouble with a basic clock program

Started by Courageousodin, 25 May 2017 - 09:34 PM
Courageousodin #1
Posted 25 May 2017 - 11:34 PM
Wrote a clock program for my terminal glasses and it was working fine. server Im on restarts and when i log back on suddenly its broken

error message:

clock:15 attempt to index ? (a nil value)


CODE:

glass = peripheral.wrap("left")
function addBox()
  glass.addBox(1,20,80,10,0xFFFFFF,0.2)
end

function drawTime()
  time = textutils.formatTime(os.time(), false)
  glass.addText(5,21,"TIME: " .. time, 0xFF0000)
  end

function start()
  while true do
  glass.clear()
  addBox()
  drawTime()
  glass.sync()
  sleep(0,1)
  end
end

start()
Bomb Bloke #2
Posted 26 May 2017 - 12:18 AM
Assuming line 15 reads "glass.clear()", that indicates that peripheral.wrap("left") returned nil, which means the computer did not detect a peripheral to its left.

If the glasses bridge is still sitting there, trying breaking and replacing it.
Courageousodin #3
Posted 26 May 2017 - 03:47 PM
THis worked, thanks! it seems i need to do this everytime i log off and on though, very wierd.