function drawPixel(x, y, color) term.setBackgroundColor(color) term.togglePixel(x, y) end function drawDriveIcon(x, y, text) drawPixel(x, y, color) term.setCursorPos(x, y+2) term.setBackgroundColor(colors.white) term.setTextColor(colors.black) term.write(text) end function bufferBackground() term.clear() paintutils.drawLine(1, 1, 51, 1, colors.lightBlue) paintutils.drawFilledBox(1, 2, 100, 100, colors.white) end bufferBackground() drawDriveIcon(3, 3, "C:") while true do local event, button, xPos, yPos = os.pullEvent() if event == "mouse_click" then end endCan you maybe explain, I bug tested it, and it leads me to the error being driven by term.togglePixel() but...I dunno why.
Window:57: Expected number
#1
Posted 18 April 2015 - 12:19 PM
#2
Posted 18 April 2015 - 12:31 PM
"term.setBackgroundColor(color)" is where you're triggering the error - because "color" isn't a number, it's nil. You never set it to anything.
CC doesn't have a term.togglePixel function at all, so I'd expect an "attempt to call nil" on that third line - but you're currently crashing out before you get there.
#3
Posted 18 April 2015 - 12:37 PM
Bomb Bloke, on 18 April 2015 - 12:31 PM, said:
"term.setBackgroundColor(color)" is where you're triggering the error - because "color" isn't a number, it's nil. You never set it to anything.
CC doesn't have a term.togglePixel function at all, so I'd expect an "attempt to call nil" on that third line - but you're currently crashing out before you get there.
http://www.computerc...l-manipulation/
Edited by Lightning, 18 April 2015 - 12:38 PM.
#4
Posted 18 April 2015 - 01:02 PM
You can view the functions currently available in the "term" table here.
Lightning, on 18 April 2015 - 12:37 PM, said:
Where, exactly? Not in this script, it isn't.
Edited by Bomb Bloke, 18 April 2015 - 02:21 PM.
#5
Posted 18 April 2015 - 02:37 PM
But the variable color isn't declared there, and that's how you're getting this error.
#6
Posted 18 April 2015 - 02:44 PM
Bomb Bloke, on 18 April 2015 - 01:02 PM, said:
You can view the functions currently available in the "term" table here.
Lightning, on 18 April 2015 - 12:37 PM, said:
Where, exactly? Not in this script, it isn't.
But I have a new problem. I got rid of that code.
Code:
function list(directory) local a local b a = fs.list(directory) for i=1, #a do if fs.isDir(a[i]) then b[i] = "true" end end return a, b endI get:
Explorer:7: index expected, got nil
#7
Posted 18 April 2015 - 03:03 PM
Lightning, on 18 April 2015 - 02:44 PM, said:
function list(directory) local a local b a = fs.list(directory) for i=1, #a do if fs.isDir(a[i]) then b[i] = "true" end end return a, b endI get:
Explorer:7: index expected, got nil
On the line where you define 'local b' change it to this:
local b = {} --# Makes it an empty table
Lua won't let you try to use a nil variable like a table (hence the error)
#8
Posted 18 April 2015 - 03:09 PM
How would I test if a file is a folder?
#10
Posted 18 April 2015 - 03:26 PM
Bomb Bloke, on 18 April 2015 - 03:18 PM, said:
is fs.isDir the one? I can't seem to use it.
function list(directory) local a local b = {} a = fs.list(directory) for i=1, #a do if fs.isDir(a[i]) then b[i] = "true" else b[i] = "false" end end return a, b endb ALWAYS equals "true". Is there any fix?
Wait, nevermind.
Edited by Lightning, 18 April 2015 - 03:52 PM.
#11
Posted 18 April 2015 - 06:19 PM
Lightning, on 18 April 2015 - 03:26 PM, said:
Bomb Bloke, on 18 April 2015 - 03:18 PM, said:
is fs.isDir the one? I can't seem to use it.
function list(directory) local a local b = {} a = fs.list(directory) for i=1, #a do if fs.isDir(a[i]) then b[i] = "true" else b[i] = "false" end end return a, b endb ALWAYS equals "true". Is there any fix?
Wait, nevermind.
Why are you using "true" instead of true? (string vs boolean)
Edited by flaghacker, 18 April 2015 - 06:19 PM.
#12
Posted 18 April 2015 - 09:20 PM
flaghacker, on 18 April 2015 - 06:19 PM, said:
Lightning, on 18 April 2015 - 03:26 PM, said:
Bomb Bloke, on 18 April 2015 - 03:18 PM, said:
is fs.isDir the one? I can't seem to use it.
function list(directory) local a local b = {} a = fs.list(directory) for i=1, #a do if fs.isDir(a[i]) then b[i] = "true" else b[i] = "false" end end return a, b endb ALWAYS equals "true". Is there any fix?
Wait, nevermind.
Why are you using "true" instead of true? (string vs boolean)
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users