Jump to content




[Lua] [Error] Custom Startup Not Loading Shell API


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

#1 KillaVanilla

  • Members
  • 303 posts

Posted 30 August 2012 - 10:40 PM

I'm trying to make a custom network-loading script that runs on startup. the only problem with this, though, is that it can't use the shell API's functions. This also happens with any programs run by the downloaded shell.

From what I've seen of the code, this shouldn't happen, as the shell program itself loads the shell API, and then runs the startup program.

Below is the code:
-- Network Boot System
local timeout = 10
local side = "top"
rednet.open(side)
function advancedOptions()
print("Select a boot file:")
bootID = io.read()
return bootID
end
function doBoot()
local bootFile = "default"
term.clear()
term.setCursorPos(1,1)
print("NETWORK BOOT CLIENT")
print("Press any key within 5 seconds to select a boot file.")
os.startTimer(5)
while true do
  event = os.pullEvent()
  if event == "timer" then
   print("Boot file not selected. Going to default...")
   break
  end
  if event == "key" then
   bootFile = advancedOptions()
   break
  end
end
rednet.broadcast("boot:"..bootFile)
bootServer, bootshell, distance = rednet.receive(timeout)
if bootshell == nil then
  print("ERROR: Could not contact boot server!")
  shell.exit()
end
print("Boot server contacted. Boot Server ID:"..bootServer)
shell = fs.open("shell", "w")
shell.write(bootshell)
shell.close()
print("Boot file downloaded! Running shell...")
os.sleep(2)
term.clear()
term.setCursorPos(1,1)
shell.setPath("/")
rednet.close(side)
os.sleep(2)
os.run({},"shell")
end
doBoot()


#2 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 30 August 2012 - 10:49 PM

You overwrite the shell api in this line:
shell = fs.open("shell", "w")
Change the variable name and it should work.

#3 KillaVanilla

  • Members
  • 303 posts

Posted 30 August 2012 - 10:57 PM

Thank you!





3 user(s) are reading this topic

0 members, 3 guests, 0 anonymous users