Hey guys I've run into a problem again. I was trying to load an image of a pop-up window but then it came up with this error: paintutils:94: attempt to get the length of nil. I don't know why I'm getting this error as I put in the right arguments and I don't even have 94 lines of code yet(getting close though!). So here is the code
function searchwindow()
paintutils.loadImage('window')
paintutils.drawImage('window', 25, 8)
end
local programs = fs.list('rom/programs')
local options = {'Shutdown', 'Reboot','Programs'}
local menuopen = false -- variable for checking if the menu is open, to see if we have to draw it
local programsopen = false
while true do
-- we're going to draw everything before taking mouse input
-- clear the screen and prepare for the new screen to be drawn, with the color black
term.setBackgroundColor(colors.lightBlue)
term.clear()
if search == true then
searchwindow()
end
-- get the width and height of the screen - is more helpful than memorizing numbers
-- it also makes it adaptable to other monitor sizes.
local w,h = term.getSize()
-- draw a line on the bottom of the taskbar from right to left
paintutils.drawLine(1, h, w, h, colors.blue)
-- draw the start button with black text and a lime (light green) background
term.setTextColor(colors.black)
term.setBackgroundColor(colors.lime)
term.setCursorPos(1, h)
write('Start')
-- draw the start menu, but ONLY if menuopen is true.
if menuopen then
term.setBackgroundColor(colors.white)
term.setTextColor(colors.black)
-- a for loop basically says:
-- repeat the following, starting at 1 and ending at the number of options (2 in this case)
for i=1, #options do
-- set our cursor to the left, and a y position based on i
-- so the first time, it'll be h (51) - 1, or 50
-- then h - 2, 49
term.setCursorPos(1, h - i)
-- print the ith of options
-- so on the first loop, i will be 1, and this will say print(options[1])
-- and then options[2]
print(options[i])
end
if search == true then
searchwindow()
end
end
-- here's where we take mouse input.
-- use os.pullEvent to get the event pulled, the mouse button pressed, then the mouse x and y
local event, button, mousex, mousey = os.pullEvent('mouse_click')
if menuopen then
if button == 1 and mousex < 9 and mousey == 18 then
term.setBackgroundColor(colors.black)
term.setTextColor(colors.white)
term.setCursorPos(1, 18)
term.write(options[1])
sleep(0.5)
os.shutdown()
elseif button == 1 and mousex < 7 and mousey == 17 then
term.setBackgroundColor(colors.black)
term.setTextColor(colors.white)
term.setCursorPos(1, 17)
term.write(options[2])
sleep(0.5)
os.reboot()
elseif button == 1 and mousex < 9 and mousey == 16 then
search = true
-- check if we're within bounds of the start button
elseif button == 1 and mousey < 17 or button == 1 and mousey == 17 and mousex > 6 or button == 1 and mousey == 18 and mousex > 8 then
-- set menuopen to the oppsite of menuopen
-- so if menuopen is true, menuopen is now false.
menuopen = not menuopen
end
elseif not menuopen then
if button == 1 and mousey == 19 and mousex < 6 then
menuopen = true
if search == true then
search = true
end
end
end
end
I don't know what the &gt and &lt mean but they don't show up in the game, only when I copied them onto the fourms.