Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.clear()
- term.setCursorPos(1,1)
- print("Nova Alarms - v1.0")
- local admin = "Lewisk3"
- local state = "on"
- local chat = peripheral.wrap("right")
- local alarm = peripheral.wrap("left")
- local log = ".log"
- local cmd = "alarm:"
- local function update()
- local ev, sd, pl, st = os.pullEvent()
- if(ev == "chatbox_command")then
- if(pl == admin)then
- if(st:sub(1,#cmd) == cmd)then
- state = st:sub(#cmd+1,#st)
- chat.tell(admin,"Alarm state set to: " .. state)
- end
- end
- end
- if(state=="on" and rs.getInput("front") and not alarm.isPlaying())then
- print("Alarm triggered!")
- chat.tell(admin,"Alarm has triggered!")
- alarm.start()
- local f = fs.open(log,"w")
- f.writeLine(os.time() .. ": alarm triggered.")
- f.close()
- elseif(alarm.isPlaying() and state ~= "on")then
- chat.tell(admin,"Stopping alarm...")
- print("Stopping alarm")
- alarm.stop()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement