Posted 11 February 2013 - 10:18 PM
Title: Error: can someone please help me with this attempt to index bug?
This keeps the computer ID at the top of the screen whenever something new is printed.
I works if I keep string.len(ID) out of the function. what am I doing wrong :S
This keeps the computer ID at the top of the screen whenever something new is printed.
function sortPrint(string)
local tx, ty = term.getSize()
local ID = ("Computer ID = ".. tostring(os.computerID()))
local nx = (tx/2) - (string.len(ID)/2)
print(string)
local x, y = term.getCursorPos()
term.setCursorPos(nx, 1)
term.clearLine()
term.write(ID)
term.setCursorPos(x,y)
end
I get a "attempt to index ? (a number value)" error on line 4 whenever it gets calledI works if I keep string.len(ID) out of the function. what am I doing wrong :S
Edited by