Jump to content




Attempt to index ? (A nil value)


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

#1 SGunner2014

  • Members
  • 113 posts
  • LocationMaidstone, UK

Posted 23 September 2014 - 08:52 PM

I have a feeling that I'm being really derpy here, but when I try to launch my program from the start screen I made, it draws up this error on line 9 of this file. I can't seem to figure out why it does this, however. If I try to launch it from the shell, it works fine though.

while true do
term.clear()
bground = paintutils.loadImage("os8/assets/wbground.nfp")
paintutils.drawImage(bground,1,1)
term.setCursorPos(1,1)
term.setTextColor(colors.black)
term.setBackgroundColor(colors.white)
if fs.exists("os8/assets/appStore.list") == true then fs.delete("os8/assets/appStore.list") end
shell.run("pastebin get y1RAbu4D os8/assets/appStore.list") --#It says it gets the error here
term.clear()
print("APP STORE - APP LIST")
local h = fs.open("os8/assets/appStore.list", "r")
local app1Line1 = h.readLine()
local app1Line2 = h.readLine()
local app1Line3 = h.readLine()
local app2Line1 = h.readLine()
local app2Line2 = h.readLine()
local app2Line3 = h.readLine()
print("App name: "..app1Line1)
print("Made by: "..app1Line2)
print("LAUNCH")
print("")
print("App name: "..app2Line1)
print("Made by: "..app2Line2)
print("LAUNCH")
local event, button, x, y = os.pullEvent("mouse_click")
if button == 1 and x>=1 and x<=6 and y==4 then
  local exist = fs.exists("os8/apps/"..app1Line2..".app")
  if exist == true then
	local tabID = multishell.launch({}, "os8/apps/"..app1Line2..".app")
	multishell.setTitle(tabID, app1Line1)
	h.close()
	multishell.setFocus(tabID)
  elseif exist == false then
	term.clear()
	paintutils.drawImage(bground,1,1)
	term.setCursorPos(1,1)
	print(app1line1)
	print("is not installed. Would you like to install?")
	term.setCursorPos(20,9)
	print("YES")
	term.setCursorPos(20,9)
	print("NO")
	while true do
	local event, button, x, y = os.pullEvent("mouse_click")
	if button == 1 and x>=20 and x<=22 and y==9 then
	  shell.run("pastebin get "..app1Line3.." "..app1Line3)
	  term.clear()
	  paintutils.drawImage(bground,1,1)
	  term.setCursorPos(1,1)
	  write("D")
	  sleep(0.1)
	  write("o")
	  sleep(0.1)
	  write("n")
	  sleep(0.1)
	  write("e")
	  sleep(2)
	  break
	end
	end
  end
end
end

Any suggestions?

Thanks,
- Sam

PS I can list the code for the start screen if needed.

Edited by SGunner2014, 23 September 2014 - 08:53 PM.


#2 Bomb Bloke

    Hobbyist Coder

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

Posted 23 September 2014 - 09:15 PM

Presumably your start screen script is using os.run() but isn't setting the desired environment. You may find it easier to use shell.run() instead.

#3 SGunner2014

  • Members
  • 113 posts
  • LocationMaidstone, UK

Posted 23 September 2014 - 09:20 PM

View PostBomb Bloke, on 23 September 2014 - 09:15 PM, said:

Presumably your start screen script is using os.run() but isn't setting the desired environment. You may find it easier to use shell.run() instead.

My start screen script is using multishell.launch() to launch the program. I'm using this so I can integrate multitasking into my OS.

Any ideas?

Thanks,
- Sam

#4 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 23 September 2014 - 10:26 PM

The problem Bomb Bloke mentioned is the issue. Multishell's launch function requires you to pass the environment table, so if you're not passing the correct environment, the shell "API" won't be present. Please post your start screen script.

#5 SGunner2014

  • Members
  • 113 posts
  • LocationMaidstone, UK

Posted 24 September 2014 - 06:49 PM

Here's the startup script:

  local tabID = multishell.launch({}, "os8/assets/appStore.app")
  multishell.setTitle(tabID, "App Store")
  multishell.setFocus(tabID)
end
end
end

P.S Please note that the ends are part of a bigger picture.

EDIT: Posted the wrong bit of code

Edited by SGunner2014, 24 September 2014 - 06:52 PM.


#6 Bomb Bloke

    Hobbyist Coder

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

Posted 24 September 2014 - 10:56 PM

Give this a try:

local tabID = multishell.launch({["shell"] = shell}, "os8/assets/appStore.app")

This adds a pointer to the "shell" table to the environment of the launched script.

#7 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 24 September 2014 - 11:59 PM

The multishell "API" should also be included when providing complete environments to programs:

local tabID = multishell.launch({shell = shell, multishell = multishell}, "os8/assets/appStore.app")


#8 SGunner2014

  • Members
  • 113 posts
  • LocationMaidstone, UK

Posted 25 September 2014 - 03:29 PM

Okay, thanks guys, I'll give that a go now :)

EDIT: Okay, tried it and it works. Thanks once again :)

Edited by SGunner2014, 25 September 2014 - 03:41 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users