236 posts
Posted 09 December 2012 - 09:27 AM
why does this function:
function ProgramLable()
term.setCursorPos(21,18)
term.setBackgroundColor(colors.yellow)
print("PROGRAMS")
term.setBackgroundColor(colors.lightBlue)
event, p1, p2, p3 = os.pullEvent(mouse_click)
if p2==21 and p3==18 then
shell.run("programs/programMenu")
end
end
errors that the shell.run line errors attemt to index ? a nil value
?????
1688 posts
Location
'MURICA
Posted 09 December 2012 - 09:28 AM
It might be a problem with the program it's running. Post the text of the programMenu program.
236 posts
Posted 09 December 2012 - 09:31 AM
---[[Copyright Makerimages, all of the code here was made or adapted by Makerimages and you may not distribute this code without prior written premission from Makerimages]]---
term.setCursorPos(1,1)
term.setBackgroundColor(colors.lightBlue)
term.clear()
term.setBackgroundColor(colors.yellow)
local width=4
local size={term.getSize()}
for w=1,width do
term.setCursorPos(1,size[2]-w+1)
for x=1,size[1] do
write(' ')
end
end
term.setBackgroundColor(colors.lightBlue)
term.setCursorPos(10,1)
print("Programs you have installed")
is the internals of the programMenu
290 posts
Location
St.Louis, MO
Posted 09 December 2012 - 09:45 AM
---[[Copyright Makerimages, all of the code here was made or adapted by Makerimages and you may not distribute this code without prior written premission from Makerimages]]---
term.setCursorPos(1,1)
term.setBackgroundColor(colors.lightBlue)
term.clear()
term.setBackgroundColor(colors.yellow)
local width=4
local size={term.getSize()}
for w=1,width do
term.setCursorPos(1,size[2]-w+1)
for x=1,size[1] do
write(' ')
end
end
term.setBackgroundColor(colors.lightBlue)
term.setCursorPos(10,1)
print("Programs you have installed")
is the internals of the programMenu
instead of
local size={term.getSize()}
try
local sizeX,sizeY = term.getCursorPos()
local size={sizeX,sizeY}
local sizeX,sizeY = term.getSize()
local size={sizeX,sizeY}
It should work, though i haven't tested it
1688 posts
Location
'MURICA
Posted 09 December 2012 - 09:47 AM
There doesn't seem to be any problem - I ran both scripts and they worked fine.
instead of
local size={term.getSize()}
try
local sizeX,sizeY = term.getCursorPos()
local size={sizeX,sizeY}
It should work, though i haven't tested it
What he did is valid though.
236 posts
Posted 09 December 2012 - 10:01 AM
hmmm, still no work
27 posts
Posted 09 December 2012 - 02:24 PM
You need to put mouse_click in quotation marks:
event, p1, p2, p3 = os.pullEvent("mouse_click")
Otherwise Lua thinks you're addressing a variable called mouse_click, which wasn't declared beforehand.
1604 posts
Posted 09 December 2012 - 02:53 PM
If the function is inside an api, you can't use the shell api, so that's why it says "attempt to index a nil value" (shell doesn't exist).
236 posts
Posted 09 December 2012 - 09:20 PM
that was it, thanks now it works