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

shell.run() in an API returns attempt to index ? (a nil value)

Started by Cloud Ninja, 28 June 2015 - 12:00 AM
Cloud Ninja #1
Posted 28 June 2015 - 02:00 AM
So im attempting to create my own GUI API (kind of like bedrock) but whenever i have a shell.run() in it it errors: gui(API name for now):53:attempt to index ? (a nil value)

Full API can be seen here as far as ive coded (some code has been changed since, but): http://pastebin.com/8xmWadA3

heres the problem code


function buttons(sx,sy,ex,ey,Obox,oc,ic,func)
run = func
if Obox == nil then
paintutils.drawFilledBox(sx,sy,ex,ey,ic)
else
paintutils.drawFilledBox(sx,sy,ex,ey,ic)
paintutils.drawBox(sx,sy,ex,ey,oc)
end
term.setTextColor(colors.white)
evnt, btn, x, y = os.pullEvent("mouse_click")
--if x >= sx and x <= ex and y >= sy and y <= ey then
term.setTextColor(colors.white)
term.setBackgroundColor(colors.black)
term.clear()
term.setCursorPos(1,1)
<Where it errors>
shell.run(func)
end

Its no where near done, so excuse the messiness and horrible indentation and such. Whenever i call this function, it errors and throws attempt to index ?
Edited on 28 June 2015 - 01:04 AM
HPWebcamAble #2
Posted 28 June 2015 - 02:59 AM
'shell.run()' executes a string as if you had typed it into a computer's terminal.
Passing it a function will cause it to error, but not the one you got

Did you overwrite the 'shell' variable anywhere else in your program?

Could you post the rest of your code too?


Its no where near done, so excuse the messiness and horrible indentation
When you are making something as expansive as Bedrock, you should keep things EXTREMELY organized from the beginning. Just a tip :)/>
Cloud Ninja #3
Posted 28 June 2015 - 03:02 AM
'shell.run()' executes a string as if you had typed it into a computer's terminal.
Passing it a function will cause it to error, but not the one you got

Did you overwrite the 'shell' variable anywhere else in your program?

Could you post the rest of your code too?

Its no where near done, so excuse the messiness and horrible indentation
When you are making something as expansive as Bedrock, you should keep things EXTREMELY organized from the beginning. Just a tip :)/>

First part: Will update my post with the pastebin soon, but no, i do not believe i have overwritten shell anywhere else.
Heres the pastebin for the time being: http://pastebin.com/8xmWadA3
Bomb Bloke #4
Posted 28 June 2015 - 03:29 AM
APIs do not have access to either the shell nor multishell tables. shell.run() probably isn't what you want here, anyway (nor is os.run(), for that matter, which I assume by now you've discovered "works"); better to just run func as a function - much more dynamic!
Lyqyd #5
Posted 28 June 2015 - 03:31 AM
For reference, this hasn't changed since the last time you asked this question and were told that the shell "API" isn't a real API and therefore isn't available to APIs.
Cloud Ninja #6
Posted 28 June 2015 - 03:36 AM
For reference, this hasn't changed since the last time you asked this question and were told that the shell "API" isn't a real API and therefore isn't available to APIs.
I understand that now but this isnt directly related to the question i asked before, and the other one was for another program, and didnt know if it was going to be program specific. I just wanna make sure that i get this one solved. Sorry if its a bit spammy or anything.

Off topic below

Lyqyd, when will i be able to get my post lock off? Its annoying me (i understand i did it to myself, im not trying to act priviledged) and i just want it gone :/
Lyqyd #7
Posted 28 June 2015 - 05:34 AM
APIs are APIs, and the shell table isn't going to be available to one just because it's a different API.

Your posting hasn't been too bad lately. The mod preview will expire in seven days.
Cloud Ninja #8
Posted 28 June 2015 - 01:21 PM
Thank you Lyqyd.

So im currently working with BombBloke on this (im horrible with learning new things but hes walking me through it a bit) so im going to say thread closed, as well as the previous one.