Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local SirenAreaCode
- local SirenCodeTable = {"175", "217", "218", "219", "220"}
- local SCodeFounded
- local lStatus
- term.clear()
- term.setCursorPos(1, 1)
- local function SirensACode(tTable, tText)
- local resault = "(Not found!)"
- for i=1, #tTable do
- if tText == tTable[i] then
- resault = tTable[i]
- end
- end
- return resault
- end
- local modem = {peripheral.find("modem")}
- for i = 1, #modem do modem[i].open(rednet.CHANNEL_REPEAT) end
- local tower = {peripheral.find("bitnet_tower", function(name, object) return object.isTowerComplete() end)}
- local repeated, msgID, timerID, myEvent = 0, {}, {}
- if #modem == 0 and #tower == 0 then error("No modems/towers found.")
- else
- print("Welcome To The Siren Server!!!!!\nThis Program programmed By Yossi Yuval\nFor I.D.F!\nThis system is still in Beta!\nThis will be tested by I.D.F\n\n\n\n")
- local SirenAreaFile2 = fs.open("SCode", "r")
- SirenAreaCode2 = SirenAreaFile2.readAll()
- SirenAreaFile2.close()
- print("| Siren Area Code: ".SirenAreaCode2 ." |")
- end
- local function RedstoneSetSignal(signal)
- if signal == "on" then
- if peripheral.isPresent("top") then
- if disk.hasAudio("top") then
- disk.playAudio("top")
- else
- print("Disk Drive doesn't has the audio disk.\nPlease put in the '13' Song disk.")
- os.reboot()
- end
- else
- error("No disk drive found on Top.\nPlease Place the disk drive on the top of the computer.")
- os.reboot()
- end
- elseif signal == "off" then
- if peripheral.isPresent("top") then
- disk.stopAudio("top")
- else
- error("No disk drive found on Top.\nPlease Place the disk drive on the top of the computer.")
- end
- end
- end
- while true do
- myEvent = {os.pullEvent()}
- -- Message arriving via tower:
- if myEvent[1] == "bitnet_message" then
- local SirenAreaFile = fs.open("SCode", "r")
- SirenAreaCode = SirenAreaFile.readAll()
- SirenAreaFile.close()
- SCodeFounded = string.match(myEvent[3], SirenAreaCode)
- if string.match(myEvent[3], "on") then
- lStatus = string.match(myEvent[3], "on")
- elseif string.match(myEvent[3], "off") then
- lStatus = string.match(myEvent[3], "off")
- end
- print(SCodeFounded)
- if SirensACode(SirenCodeTable, SCodeFounded) ~= "(Not found!)" then
- RedstoneSetSignal(lStatus)
- print("Status: "..lStatus.." | AreaCode: "..SCodeFounded.." |")
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement