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

need help running programs on multiple monitors and wireless turtles

Started by Asianchickenisha, 01 January 2013 - 08:11 AM
Asianchickenisha #1
Posted 01 January 2013 - 09:11 AM
So I'm going to do a New Years thing tonight and I was trying to get a 60 second countdown on every monitor that I have placed. So then when the countdown ends I want the program to tell 3 different turtles to dance and I want the computer to emit a constant redstone signal which turns on an array of lights.

Here is what I have so far:

local mon = peripheral.wrap("top")
mon.clear()
local j = 60

repeat

if j > 0 then
j = j - 1
end

mon.setTextScale(5)
mon.setCursorPos(1,1)
mon.clear()
mon.write(j)
sleep(1)
until j == 0

if j == 0 then
mon.clear()
mon.write("!!2013!!")
end


I figured I could put the emit constant redstone signal under the if j == 0. Also I don't really know how to make the 3 turtles dance at the end of the countdown. But that's the least important matter I really need to know how I can run any program on multiple monitors at the same time so I can show the countdown on monitors everywhere and so I run programs on multiple computer at the same time in the future. I don't have much experience programming so sorry if I sound foolish but I have to finish this today. Thank you for your response.
zekesonxx #2
Posted 01 January 2013 - 09:45 AM
Turtles:


rednet.open("right")
id, msg = rednet.receive()
if msg == "dance" then
shell.run("dance")
end
Asianchickenisha #3
Posted 01 January 2013 - 10:27 AM
Thanks I added that to all of the turtles and got them to dance at the same time. I just need to know how to run the countdown on all computer though.
zekesonxx #4
Posted 01 January 2013 - 11:00 AM
Server Computer:


local j = 60
rednet.open("SIDE HERE")

while true do
  rednet.broadcast(j)
  if j == 0 then
    rednet.broadcast("dance")
  end
end

Monitor Computers:

local isRun = true

local mon = peripheral.wrap("top")
mon.clear()
rednet.open("SIDE HERE")
while isRun do
  id, j = rednet.receive()

  mon.setTextScale(5)
  mon.setCursorPos(1,1)
  mon.clear()
  mon.write(j)

  if j == 0 then
    mon.clear()
    mon.write("!!2013!!")
    os.pullEvent("candy_apples") --Not a actual event, this will make the computer sleep infinately.
  end
end
remiX #5
Posted 01 January 2013 - 01:01 PM
Server Computer:


local j = 60
rednet.open("SIDE HERE")

while true do
  rednet.broadcast(j)
  if j == 0 then
	rednet.broadcast("dance")
  end
end

You may want to decrement j :P/>

And instead of pulling a random event, just make isRun = false