Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --big brother base
- --this program handles the base operations of the big brother system. these functions includes communications, file management, security, propoganda, etc
- --this program is for Minecraft 1.16.5, CC Tweaked
- local modem = peripheral.find("modem") or error("No modem attached", 0)
- local Broadcasting = false
- modem.open(43)
- function start()
- print("checking power status")
- modem.transmit(32, 43, "power_check")
- local event, side, channel, replyChannel, message, distance
- repeat
- event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
- until channel == 43
- if message == "power_status.online" then
- print("power online")
- Boot()
- else
- print("power offline")
- print("shutting down....")
- os.sleep(5)
- os.shutdown()
- end
- end
- function Boot()
- print("checking security systems")
- modem.transmit(33,43, "security_check")
- local event, side, channel, replyChannel, message, distance
- repeat
- event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
- until channel == 43
- if message == "security_status.online" then
- print("security Online")
- print("starting alert broadcast")
- parallel.waitForAll(Broadcast("Boot.dfpwm",5),Main)
- else
- end
- end
- function Main()
- term.clear()
- term.setCursorPos(1,1)
- print("System Online")
- while true do
- local event, a, b, c, d, e, f, g = os.pullEvent()
- if event == "modem_message") then
- if d == "power_status.offline" then
- print("power offline")
- print("shutting down.....")
- os.sleep(7)
- os.shutdown()
- elseif string.find(d,"PublicAnnouncement_") then
- modem.transmit(8,43,string.sub(d,19,string.len(d)))
- if Broadcasting == false then Broadcast("PublicAnnouncement.dfpwm",5) end
- end
- else
- if os.time() > 5.5 and os.time() < 6.1 then
- if Broadcasting == false then Broadcast("Morning.dfpwm",5) end
- elseif os.time() > 19.5 and os.time() < 20.1 then
- if Broadcasting == false then Broadcast("Afternoon.dfpwm",5) end
- end
- end
- os.queueEvent("pass")
- end
- end
- function Broadcast(file,channel)
- Broadcasting = true
- local dfpwm = require "cc.audio.dfpwm"
- local decoder = dfpwm.make_decoder()
- for input in io.lines(file, 16 * 1024) do
- local decoded = decoder(input)
- modem.transmit(channel,43,textutils.serialize(decoded))
- end
- Broadcasting = false
- end
- start()
Add Comment
Please, Sign In to add comment