Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- BEGIN
- -- DEFINE 'SRH'
- -- BOOT SEQUENCE
- local whitelist = {
- justync7 = true,
- whateveryournameis = true,
- lurquhar1221 = true
- }
- local prefix = "$$^"
- local chatbox = peripheral.find("chatbox")
- function split(pString, pPattern)
- local Table = {} -- NOTE: use {n = 0} in Lua-5.0
- local fpat = "(.-)" .. pPattern
- local last_end = 1
- local s, e, cap = pString:find(fpat, 1)
- while s do
- if s ~= 1 or cap ~= "" then
- table.insert(Table,cap)
- end
- last_end = e+1
- s, e, cap = pString:find(fpat, last_end)
- end
- if last_end <= #pString then
- cap = pString:sub(last_end)
- table.insert(Table, cap)
- end
- return Table
- end
- function RunCommand(msg, player)
- print(user..":"..msg)
- args = split(msg, " ")
- if args[1] == "fuck" and args[2] == "you" then
- chatbox.tell(player, "Fuck you too!")
- elseif msg:sub(1,3) == "run" then
- local func, err = loadstring(msg:sub(5))
- if func then
- local ok, err = pcall(func)
- if not ok then
- chatbox.tell(player, "Error: "..tostring(err))
- else
- chatbox.tell(player, "Result: "..tostring(err))
- end
- else
- chatbox.tell(player, "Error loading function: "..tostring(err))
- end
- elseif msg:sub(1,4) == "calc" then
- local ok, err = pcall(msg:sub(6))
- if not ok then
- chatbox.tell(player, "Error: "..err)
- else
- chatbox.tell(player, "Result: "..err)
- end
- end
- end
- repeat
- e, side, user, msg = os.pullEvent("chat_message")
- if whitelist[user] and msg:sub(1,#prefix) == prefix then
- RunCommand(msg:sub(#prefix+1), user)
- end
- until e == "char" and side == keys.q
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement