Advertisement
RiseAboveHate

Siren_Client_1.16_BitNet_Tower

Dec 12th, 2014
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.39 KB | None | 0 0
  1. local SirenAreaCode
  2.  
  3. local SirenCodeTable = {"175", "217", "218", "219", "220"}
  4. local SCodeFounded
  5. local lStatus
  6.  
  7. term.clear()
  8. term.setCursorPos(1, 1)
  9.  
  10. local function SirensACode(tTable, tText)
  11.         local resault = "(Not found!)"
  12.         for i=1, #tTable do
  13.                 if tText == tTable[i] then
  14.                         resault = tTable[i]
  15.                 end    
  16.         end
  17.         return resault
  18. end
  19.  
  20.  
  21. local modem = {peripheral.find("modem")}
  22. for i = 1, #modem do modem[i].open(rednet.CHANNEL_REPEAT) end
  23.  
  24. local tower = {peripheral.find("bitnet_tower", function(name, object) return object.isTowerComplete() end)}
  25.  
  26. local repeated, msgID, timerID, myEvent = 0, {}, {}
  27.  
  28. if #modem == 0 and #tower == 0 then error("No modems/towers found.")
  29. else
  30.     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")
  31. local SirenAreaFile2 = fs.open("SCode", "r")
  32. SirenAreaCode2 = SirenAreaFile2.readAll()
  33. SirenAreaFile2.close()
  34. print("| Siren Area Code: ".SirenAreaCode2 ." |")
  35. end
  36.  
  37. local function RedstoneSetSignal(signal)
  38.     if signal == "on" then         
  39.         if peripheral.isPresent("top") then    
  40.             if disk.hasAudio("top") then           
  41.                 disk.playAudio("top")              
  42.             else           
  43.                 print("Disk Drive doesn't has the audio disk.\nPlease put in the '13' Song disk.")
  44.                 os.reboot()        
  45.             end            
  46.         else             
  47.           error("No disk drive found on Top.\nPlease Place the disk drive on the top of the computer.")
  48.           os.reboot()        
  49.         end        
  50.     elseif signal == "off" then
  51.  
  52.         if peripheral.isPresent("top") then        
  53.             disk.stopAudio("top")              
  54.         else  
  55.           error("No disk drive found on Top.\nPlease Place the disk drive on the top of the computer.")
  56.         end
  57.    
  58.     end
  59. end
  60.  
  61. while true do
  62.  
  63.     myEvent = {os.pullEvent()}
  64.    
  65.     -- Message arriving via tower:
  66.     if myEvent[1] == "bitnet_message" then
  67.         local SirenAreaFile = fs.open("SCode", "r")
  68.         SirenAreaCode = SirenAreaFile.readAll()
  69.         SirenAreaFile.close()
  70.         SCodeFounded = string.match(myEvent[3], SirenAreaCode)
  71.         if string.match(myEvent[3], "on") then
  72.             lStatus = string.match(myEvent[3], "on")
  73.         elseif string.match(myEvent[3], "off") then
  74.             lStatus = string.match(myEvent[3], "off")
  75.         end
  76.         print(SCodeFounded)
  77.         if SirensACode(SirenCodeTable, SCodeFounded) ~= "(Not found!)" then
  78.             RedstoneSetSignal(lStatus)
  79.             print("Status: "..lStatus.." | AreaCode: "..SCodeFounded.." |")
  80.         end
  81.     end            
  82. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement