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

Parallel API help

Started by Bedrockbreaker, 05 August 2016 - 05:53 PM
Bedrockbreaker #1
Posted 05 August 2016 - 07:53 PM
I have a script that controls some spawners via rednet relay computers. The trouble is, when I run my main computer with the "MobSpawners" script (which runs on my huge monitor), I can't use the normal terminal, which I know is how it does things. But I want to be able to use my terminal while the script is running. I am pretty sure that parallel API can help here but if not, I will just let it be.

Script for MobSpawners:
http://pastebin.com/g4U1L2fP
Lupus590 #2
Posted 05 August 2016 - 11:12 PM
http://www.computerc...i/Parallel_(API)

example usage:

function func1()
  while true do
	print("example")
	sleep(1)
  end
end
function func2()
  while true do
	print("stuff")
	sleep(1)
  end
end

parallel.waitForAny(func1, func2) --# correct way
parallel.waitForAny(func1(), func2()) --# common mistake
--#you can also use waitForAll if that is better for your needs
Edited on 05 August 2016 - 09:14 PM
Thefdjurt #3
Posted 05 August 2016 - 11:17 PM
snip
I think the OP is going to want to use the Multishell API (only on advanced comps).
In your startup all you need to write is

spawnertab= shell.openTab("MobSpawners")
and you will have shell and your script running at the same time.
Edited on 05 August 2016 - 09:19 PM
Bedrockbreaker #4
Posted 06 August 2016 - 02:05 AM
Thanks, Thefdjurt! That is actually what I wanted!