Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --# slave/silo
- --# User config section
- local hostName = "Andrew2060_Silo_System" --# must match master variable
- local protocolName = "Andrew2060_Silo" --# must match master variable
- local arm == "true"
- --# End of user config section
- local silo = peripheral.wrap("back")
- if not silo then error("can't find silo") end
- --# peripheral dummy functions (because I don't have the mod)
- local function silo.getMissileType()
- peripheral.call("back", "getMissile")
- end
- local function silo.getArmStatus()
- local ArmStatus = arm
- end
- local function silo.setArmState(newState)
- local ArmStatus = newState
- end
- local function silo.fire()
- peripheral.call("back", "fire")
- end
- --# end of peripheral dummy functions
- local masterServer = rednet.lookup(protocolName, hostName)
- if not masterServer then error("can't find master server") end
- local function getSiloState()
- return {os.getComputerID, silo.getMissileType(), tostring(silo.getMissileArmStatus())}
- end
- rednet.send(masterServer, getSiloState(), protocolName) --# send first message so that the master server knows about this silo
- while true do
- local message = {rednet.recive()}
- if message[3] == protocolName then
- --# message is expected protocol, continue
- if message[1] == masterServer then
- --# the message if from our master server, continue
- if message[2] == "arm" then silo.setArmState(true)
- elseif message[2] == "disarm" then silo.setArmState(false)
- elseif message[2] == "fire" then silo.fire()
- else --# bad message, ignore
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment