Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --< import / using >--
- --[[ NOTE: I only did this because I'm lazy af ]]--
- import ('System.IO') -- Imported for File reading and writing
- --< import / using >--
- --< Init Function >--
- -- Why this you might ask?... wait, uh.
- function init()
- local a = File.ReadAllLines("Lua\\login.txt") -- A sample of System.IO on lua.
- Console:WriteLine("Console initialized!.. Connecting to Server")
- Connect:ToServer(a[0],a[1])
- Console:WriteLine("Connected to Server... connecting to the World")
- Connect:ToEE(a[2])
- Bot:Send("init")
- end
- --< Init Function >--
- --< Global Variables >--
- Players = {}
- BotId = -1
- Owner = ""
- BotPrefix = "[Melody]: "
- --< Global Variables >--
- --< Global Functions >--
- function Say(msg)
- Bot:Send("say", BotPrefix..msg)
- end
- function PM(plr, msg)
- Bot:Send("say", "/pm "..plr.." "..BotPrefix..msg)
- end
- function Cmd(msg)
- Bot:Send("say", "/"..msg)
- end
- --< Global Functions >--
- --< onMessage Voids >--
- function onInit(msg)
- BlockWorld:HandleMessage(msg)
- BotId = msg:GetInt(5)
- Owner = msg:GetString(0)
- Say("Sucessfully Connected!")
- Bot:Send("init2")
- end
- function onAdd(msg)
- local username = msg:GetString(1)
- local userid = msg:GetInt(0)
- if Players[userid] == nil then
- Players[userid] = username
- Say(username.." joined the world!")
- end
- end
- function onLeft(msg)
- local userid = msg:GetInt(1)
- if Players[userid] ~= nil then
- local username = Players[userid]
- Players[userid] = nil
- Say(username.." left the world!")
- end
- end
- function onSay(msg)
- local userid = msg:GetInt(0)
- local message = msg:GetString(1)
- if Players[userid] == nil then
- return
- end
- local username = Players[userid]
- local isCommand = false
- local stringspl = {}
- --< Check if message is command >--
- local prefixes = {
- ".","!","~"
- }
- for i,v in pairs(prefixes) do
- if string.sub(message, 1, 1) == v then
- isCommand = true
- for word in string.sub(message, 2,-1):gmatch("%w+") do table.insert(stringspl, word) end
- break
- end
- end
- --< Check if message is command >--
- if isCommand then
- if stringspl[1] == "test" then
- Say("It's working!")
- end
- end
- end
- --< onMessage Voids >--
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement