This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
KingofGamesYami's profile picture

loadstring() questions

Started by KingofGamesYami, 17 May 2014 - 02:18 PM
KingofGamesYami #1
Posted 17 May 2014 - 04: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?
Zudo #2
Posted 17 May 2014 - 06:13 PM
Why not use shell.run() ?
KingofGamesYami #3
Posted 17 May 2014 - 07:07 PM
The program I am making… is complicated. https://github.com/KingofGamesYami/Advance-Turtle-Operating-Environment/blob/master/apis/waypoint.lua

Anyone that wishes to contribute can make a pull request
Lignum #4
Posted 17 May 2014 - 07: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.