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

Multiple Updating Monitors

Started by salkinxd, 17 August 2017 - 12:18 AM
salkinxd #1
Posted 17 August 2017 - 02:18 AM
Hi, I am trying to use a program I wrote on 2 different Monitors (connected via Wired Modems), but the shell.run function only lets one at a time run!
I have no Idea how I can use the parallel API to work with my Program.
So, I don't know how I can have two while functions running at the same time…

This is my Code:

updaterate = 0.1
flowrate = 50
m = {}
for i=1,16 do
  if peripheral.isPresent("monitor_"..i) then
	table.insert(m,"monitor_"..i)
  end
end
for s=1,#m do
  shell.run("monitor", m[s], "turb", updaterate, flowrate)
end
Bomb Bloke #2
Posted 17 August 2017 - 07:44 AM
The parallel API is ill-suited to situations where you want to run different scripts on different monitors. You're better off just using shell.openTab() instead of shell.run().

You could also use peripheral.find() to hunt down all attached monitors for you:

local updaterate = 0.1
local flowrate = 50

peripheral.find("monitor", function(name) shell.openTab("monitor", name, "turb", updaterate, flowrate) end)

Another option is to build a special combined terminal object that writes to all your monitors (like this one), redirect to it, then run a single instance of your "turb" script. So long as you don't want to track separate button presses or something like that, this'd be most efficient.
Edited on 17 August 2017 - 05:52 AM