Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local module = {
- _NAME = "first"
- }
- local mode = {}
- do
- local addImage = tfm.exec.addImage
- tfm.exec.addImage = function(...)
- local id = addImage(...)
- if id then
- system.objects.image[id] = true
- end
- return id
- end
- local removeImage = tfm.exec.removeImage
- tfm.exec.removeImage = function(id)
- removeImage(id)
- system.objetos.imagem[id] = nil
- end
- local addTextArea = ui.addTextArea
- ui.addTextArea = function(id, ...)
- addTextArea(id, ...)
- system.objetos.textarea[id] = true
- end
- local addPopup = ui.addPopup
- ui.addPopup = function(id, ...)
- addPopup(id, ...)
- system.objetos.popup[id] = true
- end
- end
- eventOnModeChange = function()
- for id in next, system.objects.image do
- tfm.exec.removeImage(id)
- end
- for id in next, system.objects.textarea do
- ui.removeTextArea(id)
- end
- for id in next, system.objects.popup do
- ui.addPopup(id, "", nil, -1500, -1500)
- end
- system.objetos = {
- textarea = {},
- popup = {},
- imagem = {}
- }
- end
- local getModule = function(moduleName, triggerEvent)
- local exists = not not mode[moduleName]
- if exists then
- module._NAME = moduleName
- if triggerEvent then
- eventOnModeChange()
- end
- end
- return exists
- end
- system.admin = {}
- local normalizePlayerName = function(playerName)
- return playerName:lower():gsub("%a", string.upper, 1)
- end
- local roomSettings= {}
- roomSettings[1] = {
- char = "&",
- execute = function(moduleName)
- if moduleName then
- getModule(moduleName, false)
- end
- end
- }
- roomSettings[2] = {
- char = "@",
- execute = function(playerName)
- if playerName then
- if #playerName > 2 then
- system.admin[normalizePlayerName(playerName)] = true
- end
- end
- end
- }
- local isRoom = string.byte(tfm.get.room.name, 2) ~= 3
- local roomAttributes = isRoom and string.match(tfm.get.room.name, "%*?#" .. module._NAME .. "%d+(.*)")
- local setRoomSettings = function()
- if roomAttributes then
- for playerName in string.gmatch(roomAttributes, roomSettings[2].char .. "(%+?[a-zA-Z0-9_]+#%d%d%d%d)") do
- roomSettings[2].execute(playerName)
- end
- roomSettings[1].execute(string.match(roomAttributes, roomSettings[1].char .. "([%a_]+)"))
- if #roomSettings > 2 then
- local characters = ""
- for id, setting in next, roomSettings do
- if id > 2 then
- characters = characters .. setting.char
- end
- end
- for char, value in string.gmatch(roomAttributes, "([" .. characters .. "])([^" .. characters .. "]+)") do
- for id, setting in next, roomSettings do
- if setting.char == char then
- setting.execute(string.gmatch(value, "%S+"))
- break
- end
- end
- end
- end
- end
- end
- mode.first = {
- time = 0,
- printf = function(where, who, message)
- print(string.format("[#%s] [%s] %s", where, who, message))
- end,
- reset = function()
- mode.first.time = 10000
- end,
- init = function()
- tfm.exec.disableAutoShaman()
- mode.first.printf("chat", "game", "this sheeet started")
- mode.first.time = 10000
- end,
- eventLoop = function(time)
- mode.first.time = time
- end,
- eventNewGame = function()
- mode.first.printf("tribe", "game", "yaaaay come to play guys")
- end
- }
- local officialEvents = {}
- officialEvents.eventChatCommand = function(name, command)
- if command == "modules" then
- local modules = ""
- for moduleName in next, mode do
- modules = modules .. moduleName .. "\n"
- end
- tfm.exec.chatMessage("The modules in this room are:\n" .. modules, name)
- end
- end
- local eventNames = {"eventLoop", "eventNewGame", "eventPlayerDied", "eventPlayerGetCheese", "eventPlayerVampire", "eventPlayerWon", "eventPlayerLeft", "eventEmotePlayed", "eventKeyboard", "eventMouse", "eventPopupAnswer", "eventTextAreaCallback", "eventChatCommand", "eventChatMessage", "eventSummoningStart", "eventSummoningEnd", "eventSummoningCancel", "eventNewPlayer", "eventPlayerRespawn", "eventColorPicked"}
- local events = {}
- foo = function() end
- initialize = function(refresh)
- events = {}
- for _, event in next, eventNames do
- events[event] = mode[module._NAME][event] or foo
- end
- if refresh then
- if mode[module._NAME].reset then
- mode[module._NAME].reset()
- end
- end
- mode[module._NAME].init()
- table.foreach(tfm.get.room.playerList, eventNewPlayer)
- end
- for _, event in next, eventNames do
- _G[event] = function(...)
- if officialEvents[event] then
- officialEvents[event](...)
- end
- events[event](...)
- end
- end
- setRoomSettings()
- initialize(false)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement