Jump to content




shell.run() problem,


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

#1 blipman17

  • Members
  • 92 posts

Posted 13 June 2012 - 06:16 PM

hello,
i've got a startupprogram that should work, but i don't get it working.
the error is a nil value error (think evereybody know wat it is) but i don't have any clue's any more.
my startupprogram search to a file called startupprogram.txt,
if it finds it, it shows the programname and after a few seconds it runs it.
at least it should run it.
it says that he can't index a nil value.
but i don't see any value that doesn't exist.

this is my startupprogram.

Spoiler

and this is my startupprogram.txt
it's not mutch, i know.

Spoiler

the file startupprogram.txt is in the lua\rom\apis map.
and it is really not about my program chestdispencer.
and when i print whattodo just before shell.run(whattodo), it prints chestdispencer.

does anyone have a clue?

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 13 June 2012 - 07:04 PM

So you're trying to tell it to run the name of the program, rather than running the program? Why the extra steps? Why not just put shell.run("chestdispenser") in your startup?

Also, stop starting new topics about the same problem.

#3 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 13 June 2012 - 07:10 PM

fs.open won't search the file for you, you need to give it the full path. It can't open the file, so it returns nil, always check the file handle before using it:
local file = fs.open("path", "r")
if file then
  -- use the file (file.read, file.write, etc)
  file.close() -- don't forget this
else
  print("Error opening file")
end

Also,

View PostLyqyd, on 13 June 2012 - 07:04 PM, said:

So you're trying to tell it to run the name of the program, rather than running the program? Why the extra steps? Why not just put shell.run("chestdispenser") in your startup?

Also, stop starting new topics about the same problem.
that. Just save it as startup and it should work. And ask in the same topic instead of making a new one.

Edit: One more thing: don't save files on the apis folder if they are not apis, cause the os will try to load them.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users