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

[LUA] Running gps.host from within a program

Started by Bandus, 02 April 2012 - 08:37 PM
Bandus #1
Posted 02 April 2012 - 10:37 PM
So, I can run gps.host from the command line putting the X Y Z coordinate as the args and that works fine, obviously.

My confusion is how to run that command through the lua interpreter as well as how to run it from within a program. I'm not sure how to "code" it so that the args are interpreted properly. Can someone show how that'd be done? Thanks!
MysticT #2
Posted 02 April 2012 - 10:43 PM
There's two options:
1) The easy way: shell.run("gps", "host", x, y, z)
2) The custom way: check the code of the gps program to know how it works.
Option 1 would just run the gps host like calling it from the shell (typing "gps host x y z" in the console).
Option 2 would be the one to use if you need to do something more advanced with the program, like hosting the gps and doing something else. Of course this would require some modification to the code, but nothing imposible.
Advert #3
Posted 02 April 2012 - 10:44 PM
The function you're looking for is shell.run. Try it; it shouldn't be hard to get it working.
Bandus #4
Posted 02 April 2012 - 10:48 PM
Indeed, I am familiar with the shell.run function. However, the issue was syntax. I was unaware of needing to seperate it such as: "gps" "host" x,y,z. Thanks!