Jump to content




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


  • You cannot reply to this topic
7 replies to this topic

#1 Cloud Ninja

  • Members
  • 361 posts

Posted 28 June 2015 - 01: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 by CloudNinja, 28 June 2015 - 02:04 AM.


#2 HPWebcamAble

  • Members
  • 933 posts
  • LocationWeb Development

Posted 28 June 2015 - 01: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?


View PostCloudNinja, on 28 June 2015 - 01:00 AM, said:

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 :)

#3 Cloud Ninja

  • Members
  • 361 posts

Posted 28 June 2015 - 02:02 AM

View PostHPWebcamAble, on 28 June 2015 - 01:59 AM, said:

'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?

View PostCloudNinja, on 28 June 2015 - 01:00 AM, said:

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

#4 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 28 June 2015 - 02: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!

#5 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 28 June 2015 - 02: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.

#6 Cloud Ninja

  • Members
  • 361 posts

Posted 28 June 2015 - 02:36 AM

View PostLyqyd, on 28 June 2015 - 02:31 AM, said:

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 :/

#7 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 28 June 2015 - 04: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.

#8 Cloud Ninja

  • Members
  • 361 posts

Posted 28 June 2015 - 12: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.





3 user(s) are reading this topic

0 members, 3 guests, 0 anonymous users