Mariomarco

HousePC

May 31st, 2013
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.76 KB | None | 0 0
  1. local chatbox = peripheral.wrap("bottom")
  2. local monitor = peripheral.wrap("top")
  3. local auth = peripheral.wrap("left")
  4. local listen = false
  5. local permitEveryone = false
  6.  
  7. local function cls(periph)
  8.     periph.clear()
  9.     periph.setCursorPos(1,1)
  10. end
  11.  
  12. local function newLine(periph)
  13.     local cx, cy = periph.getCursorPos()
  14.     periph.setCursorPos(1,cy +1)
  15. end
  16.  
  17. local function terminate()
  18.     cls(term)
  19.     term.write("Click Player detector to terminate!")
  20.     local event, p1 = os.pullEvent("player")   
  21.     if p1 == "mariomarco" then
  22.         newLine(term)
  23.         term.write("Bye bye...")
  24.         exit()
  25.     end
  26. end
  27.  
  28.     cls(monitor)
  29.     cls(term)
  30. while true do
  31.     local event, p1, p2, p3 = os.pullEventRaw()
  32.     redstone.setOutput("right", true)
  33.     if p1 == nil then p1 = "" end
  34.     if p2 == nil then p2 = "" end
  35.     if p3 == nil then p3 = "" end
  36.     if listen == true then
  37.         cls(monitor)
  38.         monitor.write("Pulled " .. event)
  39.         newLine(monitor)
  40.         monitor.write(p1 .. " " .. p2 .. " " .. p3)
  41.         newLine(monitor)
  42.     end
  43.     if event == "chat" then
  44.         if p1 == "mariomarco" and permitEveryone == false then
  45.             if p2 == "rob allow Everyone" then permitEveryone = true end
  46.             if p2 == "rob stop listening" then listen = false end
  47.             if p2 == "rob start listening" then listen = true end
  48.             if p2 == "rob toggle listening" then listen = not(listen) end
  49.             if p2 == "rob redownload" then shell.run("startup") end
  50.             if p2 == "rob terminate" then terminate() end
  51.             if p2 == "rob time" then
  52.                 local site = http.get("http://mariomarco.funpic.de/others/TIME.php?format=G:i")
  53.                 if site == nil then
  54.                     chatbox.say("site down")
  55.                 else
  56.                     chatbox.say(site.readAll())
  57.                     site.close()
  58.                 end
  59.             end
  60.             if p2 == "rob time2" then
  61.                 local site = http.get("http://mariomarco.funpic.de/others/TIME.php?format=G:i:s")
  62.                 if site == nil then
  63.                     chatbox.say("site down")
  64.                 else
  65.                     chatbox.say(site.readAll())
  66.                     site.close()
  67.                 end
  68.             end
  69.         end
  70.         if p1 == "mariomarco" or permitEveryone == true then
  71.             if p1 == "mariomarco" then
  72.             if p2 == "rob disallow Everyone" then permitEveryone = false end
  73.             if p2 == "rob redownload" then shell.run("startup") end
  74.             if p2 == "rob terminate" then terminate() end
  75.             end
  76.             if p2 == "rob time" then
  77.                 local site = http.get("http://mariomarco.funpic.de/others/TIME.php?format=G:i")
  78.                 if site == nil then
  79.                     chatbox.say("site down")
  80.                 else
  81.                     chatbox.say(site.readAll())
  82.                     site.close()
  83.                 end
  84.             end
  85.             if p2 == "rob time2" then
  86.                 local site = http.get("http://mariomarco.funpic.de/others/TIME.php?format=G:i:s")
  87.                 if site == nil then
  88.                     chatbox.say("site down")
  89.                 else
  90.                     chatbox.say(site.readAll())
  91.                     site.close()
  92.                 end
  93.             end
  94.         end
  95.     end
  96.     redstone.setOutput("right", false)
  97.     if event == "terminate" then
  98.         terminate()
  99.     end
  100. end
Advertisement
Add Comment
Please, Sign In to add comment