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

Attempt to index ? (a nil value)

Started by almightyantagonist, 10 November 2012 - 10:41 AM
almightyantagonist #1
Posted 10 November 2012 - 11:41 AM
ive got a clock program that was running yesterday, but now doesnt want to cooperate.
my program is called "startup"

function infiniteLoop()
while true do

m = peripheral.wrap("left")
m.setTextScale(3)
local time = os.time()
time = textutils.formatTime (time, false)
mon.clear()
mon.setCursorPos(1,1)
mon.write(time)
sleep(1)
end
end
infiniteLoop()



and the error message that it gives me is "startup:8: attempt to index ? (a nil value)"

any ideas that could help would be greatly appreciated.
Kingdaro #2
Posted 10 November 2012 - 11:58 AM
You're wrapping the peripheral as "m" but you try to use it later as "mon".

Just change your first two monitor-related lines to "mon" instead of "m".

mon = peripheral.wrap("left")
mon.setTextScale(3)