Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- #mayhem
- G:
- • Kill the shaman
- • Avalanche
- • Don't touch the cheese
- • Mad Mice
- • Simon say
- • Survival
- ]]
- local maps = {"@5896722", "@5896725", "@5635429", "@5896728", "@5896731", "@5896733"}
- local lobby = {"@5468613"}
- local game = {"@999999"}
- local winner = {10, 20}
- local _modos = {
- {"Kill the shaman", 100},
- {"Avalanche", 60},
- {"Don't touch the cheese", 120},
- {"Mad mice", 30},
- {"Simon say", 40},
- {"Survival", 50},
- {"Lobby", 30}
- }
- local game_index = {"Kill the shaman", "Avalanche", "Don't touch the cheese", "Mad mice", "Simon say", "Survival"}
- local KILL,AVALANCHE,CHEESE,MAD,SIMON,SURVIVAL = 1,2,3,4,5,6
- local modos = {}
- for i=1,5 do modos[i] = {name = _modos[i][1], time = _modos[i][2]} end
- local playersInRoom = 0
- local round = 0
- local xmldom
- local lastMap
- local lastRound = "a"
- local gameStarted
- local gameLoaded
- local gameFinished
- local first
- local second
- local third
- -- Makinit's flattenFunctionTree
- do
- function flattenFunctionTree(tree, path)
- for name, value in pairs(tree) do
- if type(value) == "table" then
- flattenFunctionTree(value, path .. name .. "_")
- elseif type(value) == "function" then
- _G[path .. name] = value
- end
- end
- end
- local temp = {}
- for name, value in pairs(_G) do
- if value ~= _G then
- temp[name] = value
- end
- end
- flattenFunctionTree(temp, "")
- end
- function main()
- tfm_exec_disableAutoNewGame(true)
- tfm_exec_disableAutoTimeLeft(true)
- tfm_exec_disableAllShamanSkills(true)
- tfm_exec_disableAutoShaman(true)
- tfm_exec_disableAutoTimeLeft(true)
- math_randomseed(os.time())
- startGame()
- end
- function startGame()
- if lastRound == "Game" then
- local newMap;
- repeat
- newMap = table.random(maps)
- until newMap ~= lastMap
- lastMap = newMap
- tfm_exec_newGame(newMap)
- lastRound = "afasfa"
- else
- tfm_exec_newGame(table.random(game))
- tfm_exec_setGameTime(10)
- lastRound = "Game"
- end
- end
- function eventNewGame()
- round = round + 1
- gameLoaded = true
- print(lastRound)
- if round == 0 then
- winners(first, second, third)
- elseif round == 5 then
- round = 0
- end
- if lastRound == "afasfa" and gameStarted then
- local xml = tfm.get.room.xmlMapInfo.xml
- xmldom = parseXml(xml)
- gameMode = path(xmldom, "P")[1].attribute.g or 0
- gameMode = tonumber(gameMode) or gameMode + 0
- tfm_exec_setGameTime(modos[gameMode].time + 8)
- toDelete = game_index[gameMode]
- table.delete(game_index, toDelete)
- end
- end
- function eventLoop(time, left)
- if not gameLoaded then return end
- if time > 800 and not gameStarted and lastRound ~= "Game" then
- modeStart()
- gameStarted = true
- end
- if not gameFinished and left <= 0 then
- modeEnd()
- elseif gameFinished and left <= 0 then
- startGame()
- end
- end
- function modeEnd()
- tfm_exec_setGameTime(5)
- gameFinished = true
- end
- function modeStart()
- print("<bv>Go!")
- end
- function winners(first, second, third)
- first = first or 'No one'
- second = second or 'No one'
- third = third or 'No one'
- gameFinished = true
- gameStarted = false
- tfm_exec_newGame(table.random(winner))
- end
- function table.random(t, associative)
- associative = associative or false
- if associative then
- local t2 = {}
- for k in pairs(t) do
- t2[#t2 + 1] = k
- end
- return t[table.random(t2)]
- else
- return t[math_random(1,#t)]
- end
- end
- function table.find(tbl, element)
- if element == nil then
- return false
- end
- for key, value in pairs(tbl) do
- if value == element then
- return true
- end
- end
- return false
- end
- function table.delete(tbl, element)
- if type(tbl)=="table" then
- for a,b in pairs(tbl)do
- if tbl[a] == element then
- table_remove(tbl, a)
- break
- end
- end
- end
- end
- -- Makinit's xml library
- do
- local namePattern = "[%a_:][%w%.%-_:]*"
- function parseXml(xml)
- local root = {}
- local parents = {}
- local element = root
- for closing, name, attributes, empty, text in string_gmatch(xml, "<(/?)(" .. namePattern .. ")(.-)(/?)>%s*([^<]*)%s*") do
- if closing == "/" then
- local parent = parents[element]
- if parent and name == element.name then
- element = parent
- end
- else
- if name ~= "L" then
- local child = {name = name, attribute = {}}
- table_insert(element, child)
- parents[child] = element
- if empty ~= "/" then
- element = child
- end
- for name, value in string_gmatch(attributes, "(" .. namePattern .. ")%s*=%s*\"(.-)\"") do
- child.attribute[name] = value
- end
- end
- end
- if text ~= "" then
- local child = {text = text}
- table_insert(element, child)
- parents[child] = element
- end
- end
- return root[1]
- end
- function path(nodes, ...)
- nodes = {nodes}
- for i, name in ipairs(arg) do
- local match = {}
- for i, node in ipairs(nodes) do
- for i, child in ipairs(node) do
- if child.name == name then
- table_insert(match, child)
- end
- end
- end
- nodes = match
- end
- return nodes
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement