Larvix

arenaControl

Nov 13th, 2024 (edited)
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.90 KB | None | 0 0
  1. startPhrase = "let the trial commence"
  2.  
  3. term.clear()
  4. term.setCursorPos(1,1)
  5. cable = "left"
  6. monitor = "top"
  7. mon = peripheral.wrap(monitor)
  8. mon.clear()
  9. mon.setTextScale(1)
  10. mon.setBackgroundColor(colors.black)
  11. mon.setTextColor(colors.white)
  12. x,y = mon.getSize()
  13.  
  14. function borderMonitor()
  15. mon.setBackgroundColor(colors.gray)
  16. mon.setTextColor(colors.black)
  17. for a = 1,x do
  18.     mon.setCursorPos(a,1)
  19.     mon.write("-")
  20.     mon.setCursorPos(a,y)
  21.     mon.write("-")
  22. end
  23.  
  24. for b = 1,y do
  25.     mon.setCursorPos(1,b)
  26.     mon.write("|")
  27.     mon.setCursorPos(x,b)
  28.     mon.write("|")
  29. end
  30. mon.setCursorPos(1,1)
  31. mon.write(string.char(7))
  32. mon.setCursorPos(x,1)
  33. mon.write(string.char(7))
  34. mon.setCursorPos(1,y)
  35. mon.write(string.char(7))
  36. mon.setCursorPos(x,y)
  37. mon.write(string.char(7))
  38.  
  39. mon.setBackgroundColor(colors.black)
  40. mon.setTextColor(colors.white)
  41. end
  42.  
  43. borderMonitor()
  44. running = true
  45. while running do
  46.     --wait for event to happen
  47.     evt = {os.pullEvent()}
  48.     --if event matches start conditions
  49.     if evt[1] == "chat_message" and ((string.match(evt[2], "yogo_dude") or string.match(evt[2], "Reign01")) and (string.match(string.lower(evt[3]),startPhrase))) then
  50.         --notify in pc who started it
  51.         print("Phrase recieved from "..evt[2])
  52.         --store chest/tape_drive blocks
  53.         c = peripheral.wrap("projecte:alchemical_chest_1094")
  54.         t = "tape_drive_17"
  55.         --look through chest
  56.         for s,i in pairs(c.list()) do
  57.         --if we found tape
  58.             if i.name == "computronics:tape" then
  59.         --give to drive, starting music
  60.                 c.pushItems(t,s)
  61.             end
  62.         end
  63.         write("Trial Beings in: ")
  64.         x,y = term.getCursorPos()
  65.         for i = 5,1,-1 do
  66.             write(i)
  67.             term.setCursorPos(x,y)
  68.             sleep(1)
  69.         end
  70.         print("0")
  71.         --get start time
  72.         startH = os.date("%H")
  73.         startM = os.date("%M")
  74.         startS = os.date("%S")
  75.         --run wave program
  76.         shell.run("wave.lua")
  77.         --get end time
  78.         endH = os.date("%H")
  79.         endM = os.date("%M")
  80.         endS = os.date("%S")
  81.         --remove tape, stopping music
  82.         c.pullItems(t,1)
  83.        
  84.         --calulate time (mins+secs)
  85.         timeM = (endM + 60*(endH-startH))-startM
  86.         timeS = endS - startS
  87.         if timeS < 0 then
  88.             timeM = timeM - 1
  89.             timeS = timeS + 60
  90.         end
  91.         --print time taken
  92.         line1 = "Trial Complete!"
  93.         line2 = "Time: "..timeM.."m"..timeS.."s"
  94.         monX,monY = mon.getSize()
  95.         monX = monX-2
  96.         monY = monY-2
  97.         m = window.create(mon,2,2,monX,monY,true)
  98.         cY = (monY-1)/2
  99.         m.setCursorPos((monX+2-#line1)/2,cY)
  100.         m.write(line1)
  101.         m.setCursorPos((monX+2-#line2)/2,cY+1)
  102.         m.write(line2)
  103.         --wait for next start
  104.         print("Waiting for phrase...")
  105.     end
  106. end
Advertisement
Add Comment
Please, Sign In to add comment