Advertisement
Guest User

startup

a guest
Mar 25th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.20 KB | None | 0 0
  1. local name = "PixelBot"
  2. local comm = peripheral.find("command")
  3. local monitor = peripheral.find("monitor")
  4. term.redirect(monitor)
  5.  
  6. function chat(text)
  7.   comm.setCommand("sudo @a ping &7<&8Bot&7> &r" .. name .. "&7: &r" .. text)
  8.   comm.runCommand()
  9.   print("Me: " .. text)
  10. end
  11.  
  12. function ping(text)
  13.   comm.setCommand("sudo @a ping " .. text)
  14.   comm.runCommand()
  15. end
  16.  
  17. function setName(lname)
  18.   name = lname
  19. end
  20.  
  21. term.setCursorPos(1, 1)
  22. term.clear()
  23. print("PixelBot Beta 0.28")
  24.  
  25. local complain = true
  26.  
  27. local clrs = {
  28.   ["4"] = colors.red,
  29.   ["c"] = colors.red,
  30.   ["6"] = colors.orange,
  31.   ["e"] = colors.yellow,
  32.   ["2"] = colors.green,
  33.   ["a"] = colors.lime,
  34.   ["b"] = colors.lightBlue,
  35.   ["3"] = colors.cyan,
  36.   ["1"] = colors.blue,
  37.   ["9"] = colors.lightBlue,
  38.   ["d"] = colors.magenta,
  39.   ["5"] = colors.purple,
  40.   ["f"] = colors.white,
  41.   ["7"] = colors.lightGray,
  42.   ["8"] = colors.gray,
  43.   ["0"] = colors.black,
  44.   ["r"] = colors.white
  45. }
  46.  
  47. function colorPrint(t)
  48.   local y = 1
  49.   term.setTextColor(colors.white)
  50.   for i = 1, #t do
  51.     if t:sub(y, y) == "&" then
  52.       local p = true
  53.       for z, k in pairs(clrs) do
  54.         if t:sub(y+1, y+1) == z then
  55.           term.setTextColor(k)
  56.           y = y + 1
  57.           p = false
  58.         end
  59.       end
  60.       if p then term.write("&") end
  61.     else
  62.       term.write(t:sub(y, y))
  63.     end
  64.     y = y + 1
  65.   end
  66.   local cx, cy = term.getCursorPos()
  67.   term.setCursorPos(1, cy+1)
  68. end
  69.  
  70. chat("Loaded!")
  71. while true do
  72.   local ev = {os.pullEvent()}
  73.   if ev[1] == "chat_message" then
  74.     colorPrint(ev[3] .. ": " .. ev[4])
  75.   end
  76.   if ev[1] == "chatbox_command" then
  77.     term.setTextColor(colors.lightBlue)
  78.     print(" * " .. ev[3] .. " used " .. ev[4])
  79.     term.setTextColor(colors.white)
  80.     if ev[4]:sub(1, 14) == "PIXEL;setname " then
  81.       setName(ev[4]:sub(15, #ev[4]))
  82.     end
  83.     if ev[4]:sub(1, 10) == "PIXEL;say " then
  84.       chat(ev[4]:sub(11, #ev[4]))
  85.     end
  86.     if ev[4] == "togglecomplain" then
  87.       if complain then
  88.         ping("&cTehRockettek &6will no longer complain")
  89.         complain = false
  90.       else
  91.         ping("&cTehRockettek &6will now complain... a lot.")
  92.         complain = true
  93.       end
  94.     end
  95.   end
  96. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement