Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local name = "PixelBot"
- local comm = peripheral.find("command")
- local monitor = peripheral.find("monitor")
- term.redirect(monitor)
- function chat(text)
- comm.setCommand("sudo @a ping &7<&8Bot&7> &r" .. name .. "&7: &r" .. text)
- comm.runCommand()
- print("Me: " .. text)
- end
- function ping(text)
- comm.setCommand("sudo @a ping " .. text)
- comm.runCommand()
- end
- function setName(lname)
- name = lname
- end
- term.setCursorPos(1, 1)
- term.clear()
- print("PixelBot Beta 0.28")
- local complain = true
- local clrs = {
- ["4"] = colors.red,
- ["c"] = colors.red,
- ["6"] = colors.orange,
- ["e"] = colors.yellow,
- ["2"] = colors.green,
- ["a"] = colors.lime,
- ["b"] = colors.lightBlue,
- ["3"] = colors.cyan,
- ["1"] = colors.blue,
- ["9"] = colors.lightBlue,
- ["d"] = colors.magenta,
- ["5"] = colors.purple,
- ["f"] = colors.white,
- ["7"] = colors.lightGray,
- ["8"] = colors.gray,
- ["0"] = colors.black,
- ["r"] = colors.white
- }
- function colorPrint(t)
- local y = 1
- term.setTextColor(colors.white)
- for i = 1, #t do
- if t:sub(y, y) == "&" then
- local p = true
- for z, k in pairs(clrs) do
- if t:sub(y+1, y+1) == z then
- term.setTextColor(k)
- y = y + 1
- p = false
- end
- end
- if p then term.write("&") end
- else
- term.write(t:sub(y, y))
- end
- y = y + 1
- end
- local cx, cy = term.getCursorPos()
- term.setCursorPos(1, cy+1)
- end
- chat("Loaded!")
- while true do
- local ev = {os.pullEvent()}
- if ev[1] == "chat_message" then
- colorPrint(ev[3] .. ": " .. ev[4])
- end
- if ev[1] == "chatbox_command" then
- term.setTextColor(colors.lightBlue)
- print(" * " .. ev[3] .. " used " .. ev[4])
- term.setTextColor(colors.white)
- if ev[4]:sub(1, 14) == "PIXEL;setname " then
- setName(ev[4]:sub(15, #ev[4]))
- end
- if ev[4]:sub(1, 10) == "PIXEL;say " then
- chat(ev[4]:sub(11, #ev[4]))
- end
- if ev[4] == "togglecomplain" then
- if complain then
- ping("&cTehRockettek &6will no longer complain")
- complain = false
- else
- ping("&cTehRockettek &6will now complain... a lot.")
- complain = true
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement