Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Alarm
- -- by SukaiPoppuGo
- --
- -- Emmet un message d'alerte dans le chat (message privé) à une heure donnée en temps local
- -- Require mod PeripheralPlusOne
- -- Optional mod Plethora (display on a sign as cheap monitor)
- --
- -------------------------------------------
- -- Pause on boot
- print("init")
- sleep(os.clock()<2 and 2-os.clock() or 0)
- print("run")
- -------------------------------------------
- -- PARAMS
- -- Définit l'heure où doit sonner l'alarme. Temps en heure décimale
- local alarm = 2 + (55/60)
- -- Nom du joueur à qui est destiné le message
- local player = "Votre nom ici"
- -- Contenu du message
- local message = "Reboot dans 5min"
- assert(peripheral.find("chatBox"),"chatBox introuvable")
- repeat
- local h = os.time("local")
- local diff = h < alarm and alarm - h or 24 - h + alarm
- local delay = os.startTimer(diff * 60 * 60)
- repeat
- local t = os.time("local")
- term.setCursorPos(1,1)
- term.clear()
- local sTime = textutils.formatTime(t,true)
- local sAlarm = textutils.formatTime(h+diff-t, true)
- print(" time:",sTime)
- print("alarm:",sAlarm)
- --Monitor du pauvre
- local monitor = peripheral.find("minecraft:sign")
- if monitor then
- monitor.setSignText("","§ltime: "..sTime,"§lalarm: "..sAlarm)
- end
- local tick = os.startTimer(20)
- local e,p
- repeat
- e,p = os.pullEventRaw()
- if e == "terminate" then
- local monitor = peripheral.find("minecraft:sign")
- if monitor then
- monitor.setSignText("","§4§lTerminated")
- end
- printError("Terminated")
- return
- end
- until e == "timer" and p == tick
- until e == "timer" and p == delay
- print("Alarm")
- local chatBox = peripheral.find("chatBox")
- assert("chatBox","chatBox introuvable")
- chatBox.tell(player,message)
- sleep(20)
- until false
Advertisement
Add Comment
Please, Sign In to add comment