Jump to content




loadstring() questions


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

#1 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 17 May 2014 - 03:18 PM

lets say I have a program that needs command arguments. It's saved as "program" (yes I know thats a lame name)

local prg = fs.open("program", "r")
local stuff = loadstring(prg.readAll())
stuff()
how could I pass the command arguments to a program loaded this way? Or is it impossible?

#2 Zudo

  • Members
  • 800 posts
  • LocationUK

Posted 17 May 2014 - 05:13 PM

Why not use shell.run() ?

#3 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 17 May 2014 - 06:07 PM

The program I am making... is complicated. https://github.com/K...is/waypoint.lua

Anyone that wishes to contribute can make a pull request

#4 Lignum

  • Members
  • 558 posts

Posted 17 May 2014 - 06:14 PM

local prg = fs.open("program", "r")
local stuff = loadstring(prg.readAll())
prg.close()

stuff({ "arg1", "arg2" })
Not sure whether that would work but it makes sense to me. Also, you should always close your files. The garbage collector does take care of it but it takes a while for it to take care of it.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users