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

[Request] backround GPS

Started by dcleondc, 10 October 2012 - 03:31 AM
dcleondc #1
Posted 10 October 2012 - 05:31 AM
hello i want to know if someone can make a program that makes it so the startup runs the GPS host in the background but looks like a normal startup screen where you can run anyprogram and have the host running in the background
faubiguy #2
Posted 10 October 2012 - 05:51 AM
I think that this will work:

parallel.waitForAny(function() os.run({print = function() end}, "rom/programs/gps", "host", "<x>", "<y>", "<z>") end, function() term.clear() term.setCursorPos(1,1) shell.run("shell") end)
Just put it in the startup.

You'll have to substitute the <x>, <y>, and <z> with the coordinates you want for the gps host.
dcleondc #3
Posted 10 October 2012 - 10:20 PM
i already have a program that is named "host" that runs the gps program with the cords, so how would i make it so i runs "host" in the background
faubiguy #4
Posted 10 October 2012 - 10:41 PM
where it says
"rom/programs/gps", "host", "<x>", "<y>", "<z>"
Just replace "rom/programs/gps" with the full path to "host" and put any arguments to host after that, where "host", "<x>", "<y>", "<z>" is now.
dcleondc #5
Posted 10 October 2012 - 11:38 PM
did, and it gave me a error
faubiguy #6
Posted 10 October 2012 - 11:43 PM
Do you have the path and all arguments in quotes, with commas, like in the code above? What was the error?
dcleondc #7
Posted 11 October 2012 - 03:36 AM
error is

host:1: attempt to index ? (a nil value)
but if i just run host it works fine
Lyqyd #8
Posted 11 October 2012 - 04:43 AM
error is

host:1: attempt to index ? (a nil value)
but if i just run host it works fine

You'll probably need to modify the table passed to os.run to have an __index metamethod pointing to _G.
dcleondc #9
Posted 11 October 2012 - 04:48 AM
error is

host:1: attempt to index ? (a nil value)
but if i just run host it works fine

You'll probably need to modify the table passed to os.run to have an __index metamethod pointing to _G.
what?
Lyqyd #10
Posted 11 October 2012 - 05:15 AM

backEnvMeta = {__index = _G}
backEnv = {write = function() end}
setmetatable(backEnv, backEnvMeta)
parallel.waitForAll(function() os.run(backEnv, "host", 12, 13, 14) end, whateverElseYouAreRunning)
faubiguy #11
Posted 11 October 2012 - 02:51 PM
Doesn't os.run automatically set the index to _G? The code I put works fine when I tested it. It still can't hurt to set the index metamethod to _G though.