Guest User

startup.lua

a guest
Aug 24th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.55 KB | None | 0 0
  1. print("init")
  2. sleep(os.clock()<2 and 2-os.clock() or 0)
  3. print("run")
  4.  
  5. local alarm = 2 + (55/60)
  6. local player = "SukaiPoppuGo"
  7. local message = "Reboot dans 5min"
  8.  
  9. assert(peripheral.find("chatBox"),"chatBox introuvable")
  10.  
  11. repeat
  12.     local h = os.time("local")
  13.     local diff = h < alarm and alarm - h or 24 - h + alarm
  14.     local delay = os.startTimer(diff * 60 * 60)
  15.    
  16.     repeat
  17.         local t = os.time("local")
  18.        
  19.         term.setCursorPos(1,1)
  20.         term.clear()
  21.         local sTime = textutils.formatTime(t,true)
  22.         local sAlarm = textutils.formatTime(h+diff-t, true)
  23.                
  24.         print(" time:",sTime)
  25.         print("alarm:",sAlarm)
  26.        
  27.         --Monitor du pauvre
  28.         local monitor = peripheral.find("minecraft:sign")
  29.         if monitor then
  30.             monitor.setSignText("","§ltime: "..sTime,"§lalarm: "..sAlarm)
  31.         end
  32.        
  33.         local tick = os.startTimer(20)
  34.         local e,p
  35.         repeat
  36.             e,p = os.pullEventRaw()
  37.             if e == "terminate" then
  38.                 local monitor = peripheral.find("minecraft:sign")
  39.                 if monitor then
  40.                     monitor.setSignText("","§4§lTerminated")
  41.                 end
  42.                 printError("Terminated")
  43.                 return
  44.             end
  45.         until e == "timer" and p == tick
  46.     until e == "timer" and p == delay
  47.    
  48.     print("Alarm")
  49.     local chatBox = peripheral.find("chatBox")
  50.     assert("chatBox","chatBox introuvable")
  51.     chatBox.tell(player,message)
  52.     sleep(20)
  53. until false
Advertisement
Add Comment
Please, Sign In to add comment