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

Monitor program isn't giving arguments.

Started by Kingdaro, 04 February 2013 - 08:12 AM
Kingdaro #1
Posted 04 February 2013 - 09:12 AM
So I wanted to make a nice rednet receiving program to run in the background and on my monitor, however it requires the use of arguments (so that I can just throw it on any computer and run it without changing the code) and when I try to use the monitor program to run it, the arguments aren't given. I'm thinking it's on my end, but I try it without using the monitor program and it works fine. I tried editing and painting with the monitor, and arguments weren't given there either.





How would I go about fixing this? Would I need to download another version of the program?
remiX #2
Posted 04 February 2013 - 09:34 AM
Weird,,, according to the program in my FTB folder the usage is:
print( "Usage: monitor <side> <program> <arguments>" )

It states that <arguments> are allowed… but yours seems to only been accepting up to the second argument
theoriginalbit #3
Posted 04 February 2013 - 01:20 PM
its a bug in the code when the devs made it.
GopherAtl #4
Posted 05 February 2013 - 03:06 AM
You say you want to run it in the background, I'm guessing that means as a coroutine, with another shell running on the computer terminal? If so, this would not work as you expect anyway, as monitor simply redirects once before running the program, so any other coroutines running would also be redirected. My own coroutine API, goroutines, could do this, though; with the API loaded you could simply call goroutine.spawnWithRedirect, passing the wrapped monitor as the redirect and shell.run as the function, with your program and any arguments. Goroutines will handle switching redirect targets automatically, so you could run any number of programs on different monitors. I'm on my phone right now, so can't give proper sample code, but there is detailed documentation in my APIs thread and I'll be glad to help more later when I'm back at a computer.

</shamelessselfpromotion>
Kingdaro #5
Posted 05 February 2013 - 05:44 AM
I've already addressed that and fixed my program accordingly so it doesn't redirect the terminal. However I'd still like to be able to efficiently use the monitor program.
GopherAtl #6
Posted 05 February 2013 - 06:59 AM
then you'll just have to fix the monitor program. The problem is it passes the args to coroutine.create, rather than to coroutine.resume. You can get it to pass them on the first call to resume easily though, just change line 37 to

local event={...}

and voila! works.
Kingdaro #7
Posted 05 February 2013 - 07:32 AM
Awesome! Thanks.