6 posts
Posted 04 June 2012 - 03:43 PM
Two quick questions.
1) How would I let my program accept arguments (ie be able to run "program args" in shell). Can't see any of the programs here have a main() function so there's some other way I suppose.
2) Is there a way to have a functioning monitor anywhere else than next to a terminal? A remote monitor.
52 posts
Posted 04 June 2012 - 03:50 PM
From the default pastebin file:
local tArgs = { ... }
if #tArgs < 2 then
printUsage()
return
end
So, basically, get the arguments into a table with
local Variable = { ... --[[That means all the arguments]] }
Then continue as normal
That printUsage is a local function that tells the user the arguments it accepts, not really relevant to the question
146 posts
Location
the Netherlands
Posted 04 June 2012 - 04:38 PM
You can use arguments this way:
tArgs = { ... }
print(tArgs[1]) -- prints only the first argument
for i = 1, #tArgs do -- prints all arguments given
print(tArgs[i])
end
and about the remote monitor, this isn't possible. But you can use rednet to send messages between two terminals with one having a monitor beside it.
some simple code for the monitor side:
rednet.open('right')
mon = peripheral.wrap('back')
while true do
_, _, msg = os.pullEvent('rednet_message')
mon.write(msg)
end
6 posts
Posted 04 June 2012 - 06:47 PM
Thanks guys. It's true that rednet sort of counts as a remote control since any remote control method would most likely require a block placed beside the monitor anyways. Would be nice to have the wireless modems like with turtles or ribbon cables like with redpower computers though, but it's not as big of a concern.