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

Public Rednet

Started by schrolock, 17 July 2012 - 06:53 PM
schrolock #1
Posted 17 July 2012 - 08:53 PM
hey!
i have an tekkit server with my friend and wanted to make a big clock. we did it but the server isnt strong enough to let it run the whole time. so we made an big block of comuters. now we want to build a computer on every plot with an monitor and spread the clocksystem via rednet. i am not good with rednet. will it be able to spread an command via rednet to start the clocksystem on EVERY computer that contains the needed program and has it started. if this would be able it would be nice if someone can send it to me
KevinW1998 #2
Posted 17 July 2012 - 09:17 PM
You can do it using:

rednet.broadcast()
e.g.

rednet.open("right")
rednet.broadcast("start clock")
This will send to every computer in range of 64 blocks (16 during a storm)
If you want to send futher then you need to use like rednet repeater what broadcast the message another time OR
change the config on the server so you can send futher than 64 blocks!
OmegaVest #3
Posted 17 July 2012 - 09:24 PM
Hmm. Well, yes and no.

FIrst, get out your RP2 bundled cables. You will need these instead of wireless modems. The modems may be cheap, but they only have a 64 block range, and that means if the clocktower terminal is at Y128, no one is going to be able to receive the message. But, with cables, they have a range of 255 blocks. So, when you hit that far, put a repeater computer that merely takes in a signal and puts it back out to all other sides.

Then, just make the computers check for the present time by pinging the clocktower.


rednet.open(side) -- Where side is the side the cables/modem come in.

--Codehere

rednet.send(twr, "Time Ping")  -- Where twr is the clocktower's computer id. You can find it by using id in the shell. '
sleep(0.2)
msg = rednet.receive(10)  -- The number is the amount of time to wait for the computer to receive a message
hrs = tonumber(string.sub(msg, 1, 2))
mins = tonumber(sting.sub(msg, 4, 5))
secs = tonumber(string.sub(msg, 7, 8))

--display code
[code]

Then, on the other side, use:

[code]
local outRs, outIns, outEcs
if hrs < 10 then
   outRs = "0" .. hrs
end
if mins < 10 then
  outIns = "0" .. mins
end
if secs < 10 then
   outEcs = "0" .. secs
end


event, arg1, arg2 = os.pullEvent()
if event == "rednet_message" then
   if arg2 == "Time Ping" then
	  msgSnd = outRs .. " " .. outIns .. " " .. outEcs)
	  rednet.send(arg1, msgSnd)
   end
--other events, such as a timer to update the seconds (slow way)
end

This can either be a parallel function, or you can have the clock as a timer event. I would suggest the parallel. parallel.waitforAny() and have this function update the seconds when you have times them yourself. Bit complex, but it should work.
schrolock #4
Posted 17 July 2012 - 09:40 PM
Hmm. Well, yes and no.

FIrst, get out your RP2 bundled cables. You will need these instead of wireless modems. The modems may be cheap, but they only have a 64 block range, and that means if the clocktower terminal is at Y128, no one is going to be able to receive the message. But, with cables, they have a range of 255 blocks. So, when you hit that far, put a repeater computer that merely takes in a signal and puts it back out to all other sides.

Then, just make the computers check for the present time by pinging the clocktower.


rednet.open(side) -- Where side is the side the cables/modem come in.

--Codehere

rednet.send(twr, "Time Ping")  -- Where twr is the clocktower's computer id. You can find it by using id in the shell. '
sleep(0.2)
msg = rednet.receive(10)  -- The number is the amount of time to wait for the computer to receive a message
hrs = tonumber(string.sub(msg, 1, 2))
mins = tonumber(sting.sub(msg, 4, 5))
secs = tonumber(string.sub(msg, 7, 8))

--display code
[code]

Then, on the other side, use:

[code]
local outRs, outIns, outEcs
if hrs < 10 then
   outRs = "0" .. hrs
end
if mins < 10 then
  outIns = "0" .. mins
end
if secs < 10 then
   outEcs = "0" .. secs
end


event, arg1, arg2 = os.pullEvent()
if event == "rednet_message" then
   if arg2 == "Time Ping" then
	  msgSnd = outRs .. " " .. outIns .. " " .. outEcs)
	  rednet.send(arg1, msgSnd)
   end
--other events, such as a timer to update the seconds (slow way)
end

This can either be a parallel function, or you can have the clock as a timer event. I would suggest the parallel. parallel.waitforAny() and have this function update the seconds when you have times them yourself. Bit complex, but it should work.

the modem is no problem i changed its range to 9999999999 blocks
OmegaVest #5
Posted 18 July 2012 - 06:15 PM
I'll assume you're using the server's config.

Well, then the above code should still work. Just, put it as I described.
kazagistar #6
Posted 19 July 2012 - 02:30 PM
Also, the computers have an internal clock.