Hey everyone.

A long time ago I wrote a script for a wireless redstone server, and me and 2 friends of mine had great fun with it, but we lost our world, and I had to rewrite it all for a different setup we made.
Since we had so much fun with it I figured i'd post it here so others may enjoy it too.

Setup and explanation

The idea is as follows: there are 2 computers, the first one is a transmission server, the second one is a receive server. both computers have 2 bundled redstone cables attached to it at the left and right side of the computers. since each bundled cable can be split up into 16 colors, there are 32 inputs or outputs per computer.

Here's a picture of the setup how we have it right now.



(full size: http://i.imgur.com/VYEyL.png )

As you can see the computer outputs a redstone signal to the front side for the blue lights, but this can be easily removed by removing the line at the top with 'redstone.setOutput("front", false).

The transmission server has this setup with transmitters, and the receive servers has the same setup with receivers.
What these scripts allow you to do is send a signal to the transmission server to enable/disable a specific output like so:


-- Enable 4th output at left side:
rednet.send(1, "1L8")
-- Enable 3rd output at left side:
rednet.send(1, "1L4")
-- Disable 3rd output at right side:
rednet.send(1, "0R4")

The message you send to the server, is made up with as first character, the state, 0 or 1, then the side, L or R ( for left or right ) and then the exact color, using the color numbers (1,2,4,8,16 etc)

The message sent to the receive server is quite similar except for the first character, since this server reads the output of the specified redstone port and tells you if it's on or off


-- Read 4th output at left side
rednet.send(1, "L8")
id, msg = rednet.receive()
if msg=="ON" then print("L8 is on")
elseif msg=="OFF" then print("L8 is off")
else print("Invalid answer")
-- Read 3rd output at left side
rednet.send(1, "L4")
id, msg = rednet.receive()
if msg=="ON" then print("L8 is on")
elseif msg=="OFF" then print("L8 is off")
else print("Invalid answer")
-- Read 3rd output at right side
rednet.send(1, "R4")
id, msg = rednet.receive()
if msg=="ON" then print("L8 is on")
elseif msg=="OFF" then print("L8 is off")
else print("Invalid answer")

Here is a video of the server in action:

http://www.youtube.com/watch?v=ZApCIgWAMqM

this is about all info I can think of right now, if you have anymore questions feel free to ask.

Scripts

Here are the actual scripts finally. Also don't forget you might want to change the rednet.open() line and remove or edit the redstone.setOutput() line (both near the top)

Listen Server

print(os.getComputerID())
rednet.open("bottom")
redstone.setOutput("front", true)
function getinbounds(varColorInt, varSideInt)
if varSideInt >= 32768 then varSideInt = varSideInt - 32768 if varColorInt=="32768" then return true end end
if varSideInt >= 16384 then varSideInt = varSideInt - 16384 if varColorInt=="16384" then return true end end
if varSideInt >= 8192 then varSideInt = varSideInt - 8192 if varColorInt=="8192" then return true end end
if varSideInt >= 4096 then varSideInt = varSideInt - 4096 if varColorInt=="4096" then return true end end
if varSideInt >= 2048 then varSideInt = varSideInt - 2048 if varColorInt=="2048" then return true end end
if varSideInt >= 1024 then varSideInt = varSideInt - 1024 if varColorInt=="1024" then return true end end
if varSideInt >= 512 then varSideInt = varSideInt - 512 if varColorInt=="512" then return true end end
if varSideInt >= 256 then varSideInt = varSideInt - 256 if varColorInt=="256" then return true end end
if varSideInt >= 128 then varSideInt = varSideInt - 128 if varColorInt=="128" then return true end end
if varSideInt >= 64 then varSideInt = varSideInt - 64 if varColorInt=="64" then return true end end
if varSideInt >= 32 then varSideInt = varSideInt - 32 if varColorInt=="32" then return true end end
if varSideInt >= 16 then varSideInt = varSideInt - 16 if varColorInt=="16" then return true end end
if varSideInt >= 8 then varSideInt = varSideInt - 8 if varColorInt=="8" then return true end end
if varSideInt >= 4 then varSideInt = varSideInt - 4 if varColorInt=="4" then return true end end
if varSideInt >= 2 then varSideInt = varSideInt - 2 if varColorInt=="2" then return true end end
if varSideInt >= 1 then varSideInt = varSideInt - 1 if varColorInt=="1" then return true end end
return false

end
function getstatus(varSide, varColor)
if varSide=="r" then return getinbounds(varColor, redstone.getBundledInput("right")) end
if varSide=="l" then return getinbounds(varColor, redstone.getBundledInput("left")) end
  return false
end
-- returns true/false
function resolveinput(rninput)
-- find side
sideVar = string.sub(rninput, 1, 1)
sideVar = string.lower(sideVar)
if sideVar~="r" and sideVar ~="l" then return nil end
-- sideVar is the side (l/r) --

-- find ID of color
colorVar = string.sub(rninput, 2)
if colorVar~="1" and colorVar~="2" and colorVar~="4" and colorVar~="8" and colorVar~="16" and colorVar~="32" and colorVar~="64" and colorVar~="128" and colorVar~="256" and colorVar~="512" and colorVar~="1024" and colorVar~="2048" and colorVar~="4096" and colorVar~="8192" and colorVar~="16384" and colorVar~="32768" then return nil end
-- colorVar is color number

return getstatus(sideVar, colorVar)
end
while true do

id, msg = rednet.receive()
print("received '"..msg.."' from ID: "..id)
if string.lower(msg)=="ping" then
   rednet.send(id, "PONG")
else
   resolveAns = resolveinput(msg)
   if resolveAns then rednet.send(id, "ON")
   elseif not resolveAns then rednet.send(id, "OFF")
   else rednet.send(id, "INVALID") end
end
end

Transmission Server

print(os.getComputerID())
rednet.open("bottom")
redstone.setOutput("front", true)
L0 = false
L1 = false
L2 = false
L3 = false
L4 = false
L5 = false
L6 = false
L7 = false
L8 = false
L9 = false
La = false
Lb = false
Lc = false
Ld = false
Le = false
Lf = false
R0 = false
R1 = false
R2 = false
R3 = false
R4 = false
R5 = false
R6 = false
R7 = false
R8 = false
R9 = false
Ra = false
Rb = false
Rc = false
Rd = false
Re = false
Rf = false
function combineL()
combinedInt = 0
if L0 then combinedInt = combinedInt + 1 end
if L1 then combinedInt = combinedInt + 2 end
if L2 then combinedInt = combinedInt + 4 end
if L3 then combinedInt = combinedInt + 8 end
if L4 then combinedInt = combinedInt + 16 end
if L5 then combinedInt = combinedInt + 32 end
if L6 then combinedInt = combinedInt + 64 end
if L7 then combinedInt = combinedInt + 128 end
if L8 then combinedInt = combinedInt + 256 end
if L9 then combinedInt = combinedInt + 512 end
if La then combinedInt = combinedInt + 1024 end
if Lb then combinedInt = combinedInt + 2048 end
if Lc then combinedInt = combinedInt + 4096 end
if Ld then combinedInt = combinedInt + 8192 end
if Le then combinedInt = combinedInt + 16384 end
if Lf then combinedInt = combinedInt + 32768 end
return combinedInt
end
function combineR()
combinedInt = 0
if R0 then combinedInt = combinedInt + 1 end
if R1 then combinedInt = combinedInt + 2 end
if R2 then combinedInt = combinedInt + 4 end
if R3 then combinedInt = combinedInt + 8 end
if R4 then combinedInt = combinedInt + 16 end
if R5 then combinedInt = combinedInt + 32 end
if R6 then combinedInt = combinedInt + 64 end
if R7 then combinedInt = combinedInt + 128 end
if R8 then combinedInt = combinedInt + 256 end
if R9 then combinedInt = combinedInt + 512 end
if Ra then combinedInt = combinedInt + 1024 end
if Rb then combinedInt = combinedInt + 2048 end
if Rc then combinedInt = combinedInt + 4096 end
if Rd then combinedInt = combinedInt + 8192 end
if Re then combinedInt = combinedInt + 16384 end
if Rf then combinedInt = combinedInt + 32768 end
return combinedInt
end
function setvariable(varoption, varside, varcolor)
if varside=="l" then
  if varcolor=="1" then L0 = varoption end
  if varcolor=="2" then L1 = varoption end
  if varcolor=="4" then L2 = varoption end
  if varcolor=="8" then L3 = varoption end
  if varcolor=="16" then L4 = varoption end
  if varcolor=="32" then L5 = varoption end
  if varcolor=="64" then L6 = varoption end
  if varcolor=="128" then L7 = varoption end
  if varcolor=="256" then L8 = varoption end
  if varcolor=="512" then L9 = varoption end
  if varcolor=="1024" then La = varoption end
  if varcolor=="2048" then Lb = varoption end
  if varcolor=="4096" then Lc = varoption end
  if varcolor=="8192" then Ld = varoption end
  if varcolor=="16384" then Le = varoption end
  if varcolor=="32768" then Lf = varoption end
end
if varside=="r" then
  if varcolor=="1" then R0 = varoption end
  if varcolor=="2" then R1 = varoption end
  if varcolor=="4" then R2 = varoption end
  if varcolor=="8" then R3 = varoption end
  if varcolor=="16" then R4 = varoption end
  if varcolor=="32" then R5 = varoption end
  if varcolor=="64" then R6 = varoption end
  if varcolor=="128" then R7 = varoption end
  if varcolor=="256" then R8 = varoption end
  if varcolor=="512" then R9 = varoption end
  if varcolor=="1024" then Ra = varoption end
  if varcolor=="2048" then Rb = varoption end
  if varcolor=="4096" then Rc = varoption end
  if varcolor=="8192" then Rd = varoption end
  if varcolor=="16384" then Re = varoption end
  if varcolor=="32768" then Rf = varoption end
end
end
-- returns combined int or nil when wrong input
function resolveinput(rninput)
-- find if option should go on or off --
if string.len(rninput) < 3 then return nil end
optionVar0 = string.sub(rninput, 1, 1)
optionVar = false
if optionVar0=="1" then optionVar = true
elseif optionVar0=="0" then optionVar = false
else return nil end
-- optionVar is if it should be on or off --

-- find side
sideVar = string.sub(rninput, 2, 2)
sideVar = string.lower(sideVar)
if sideVar~="r" and sideVar ~="l" then return nil end
-- sideVar is the side (l/r) --

-- find ID of color
colorVar = string.sub(rninput, 3)
if colorVar~="1" and colorVar~="2" and colorVar~="4" and colorVar~="8" and colorVar~="16" and colorVar~="32" and colorVar~="64" and colorVar~="128" and colorVar~="256" and colorVar~="512" and colorVar~="1024" and colorVar~="2048" and colorVar~="4096" and colorVar~="8192" and colorVar~="16384" and colorVar~="32768" then return nil end
-- colorVar is color number

setvariable(optionVar, sideVar, colorVar)
redstone.setBundledOutput("left", combineL())
redstone.setBundledOutput("right", combineR())
return true
end
while true do

id, msg = rednet.receive()
print("received '"..msg.."' from ID: "..id)
if string.lower(msg)=="ping" then
   rednet.send(id, "PONG")
else
   resolveAns = resolveinput(msg)
   if resolveAns then rednet.send(id, "YES")
   else rednet.send(id, "NO") end
end
end

Credits:
  • Idea by roemba and bemacized.
  • Original code by roemba, later rewritten by me to remove a few bugs and rewritten again after we lost it