Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local data = {
- system = {
- n = {},
- chairs = {},
- currentChair = nil
- },
- players = {},
- playersinroom = 0,
- time = 45,
- maps = {
- rotation = {7280261},
- xml = {
- mapcode = '',
- author = '',
- xmlinfo = ''
- }
- },
- maydecrease = false,
- round = 0,
- noplayersxml = '<C><P /><Z><S><S L="800" H="10" X="400" Y="300" T="14" P="0,0,0.3,0.2,0,0,0,0" /><S L="10" X="805" H="400" Y="200" T="14" P="0,0,,,0,0,0,0" /><S L="10" H="400" X="-5" Y="200" T="14" P="0,0,,,0,0,0,0" /></S><D /><O /></Z></C>',
- loadstr = ''
- }
- table.foreach({"MinimalistMode", "MortCommand", "PhysicalConsumables", "AutoTimeLeft", "AutoNewGame", "AfkDeath", "AutoShaman", "AutoScore"}, function(k, v) tfm.exec['disable'..v]() end)
- function playersCount()
- local n = 0
- for k in next, tfm.get.room.playerList do
- n = n + 1
- end
- data.playersinroom = n
- for i = 1, (n - 1) do
- table.insert(data.system.n, i)
- end
- if (#data.system.n > 0) then
- tfm.exec.newGame(data.maps.rotation[math.random(#data.maps.rotation)])
- end
- end
- playersCount()
- function setChairs()
- local chairscode = ''
- local x = {60, 135, 210, 285, 360, 435, 510, 585, 660, 735}
- for k, v in next, data.system.n do
- data.system.chairs[v] = {}
- data.system.chairs[v].color = string.format('%x', math.random(0x000000, 0xffffff))
- data.system.chairs[v].code = string.format('<P P="0,0" C="%s" Y="320" T="19" X="%s" />', data.system.chairs[v].color, x[v])
- data.system.chairs[v].x = x[v]
- data.system.chairs[v].y = 320
- data.system.chairs[v].busy = false
- chairscode = chairscode .. data.system.chairs[v].code
- end
- local xml = data.maps.xml.xmlinfo
- xml = xml:gsub('<P', '<P Ca=""')
- xml = (xml:find('<D />') and xml:gsub('<D />', string.format('<D>%s</D>', chairscode)) or xml:find('<D>') and xml:gsub('<D>', string.format('<D>%s', chairscode)))
- data.round = data.round + 1
- tfm.exec.newGame(xml)
- ui.removeTextArea(666, nil)
- end
- function playerWin(name)
- tfm.exec.giveCheese(name)
- tfm.exec.playerVictory(name)
- end
- function table.delete(t, v)
- for key, value in ipairs(t) do
- if (v == t[key]) then
- table.remove(t, key)
- end
- end
- end
- function eventNewGame()
- data.maydecrease = true
- data.loadstr = ''
- data.time = 45
- data.start = true
- if (data.round == 0) then
- ui.addTextArea(666, "", nil, -2500, -2500, 5000, 5000, 0x6A7495, 0x6A7495, 1, true)
- local xml = tfm.get.room.xmlMapInfo.xml
- if xml then
- data.maps.xml.mapcode = tfm.get.room.currentMap
- data.maps.xml.author = tfm.get.room.xmlMapInfo.author
- data.maps.xml.xmlinfo = xml
- end
- ui.setMapName("Loading")
- elseif (data.round > 0) then
- ui.setMapName(string.format("<j>%s <bl>- %s <font color='#60608F'>| <n>Cadeiras : <v>%s/%s", data.maps.xml.author, data.maps.xml.mapcode, #data.system.n, data.playersinroom))
- tfm.exec.setGameTime(data.time)
- tfm.exec.addPhysicObject(0, 400, 327, {type = 14, width = 800, height = 10})
- tfm.exec.addPhysicObject(1, 400, 140, {type = 14, width = 800, height = 10})
- for k, v in next, data.players do
- if (v.chair ~= 0) then
- ui.removeTextArea(v.chair, nil)
- v.chair = 0
- end
- end
- elseif (data.round == 10) then
- data.round = 0
- end
- end
- function eventNewPlayer(name)
- data.players[name] = {
- chair = 0
- }
- system.bindKeyboard(name, 32, true)
- tfm.exec.setPlayerScore(name, 0)
- end
- table.foreach(tfm.get.room.playerList, eventNewPlayer)
- function eventPlayerLeft(name)
- data.players[name] = nil
- if (data.players[name].chair ~= 0) then
- data.players[name].chair = 0
- if data.system.chairs[data.players[name].chair] then
- data.system.chairs[data.players[name].chair].busy = false
- end
- ui.removeTextArea(data.players[name].chair, nil)
- end
- end
- function eventLoop(elapsed, remaining)
- local elapsed, remaining = (elapsed/1000), (remaining/1000)
- data.time = (data.time - 0.5)
- if (data.round > 0) then
- if (math.floor(remaining) <= 5) then
- table.foreach(data.players, function(k, v) if (v.chair == 0) then tfm.exec.killPlayer(k) end end)
- end
- if data.maydecrease then
- if (data.time > 20) then
- if not tostring(data.time):find('.5') then
- local arrow = {x = 0, y = 0}
- data.system.currentChair = data.system.n[math.random(#data.system.n)]
- arrow.x, arrow.y = data.system.chairs[data.system.currentChair].x, (data.system.chairs[data.system.currentChair].y - 50)
- tfm.exec.addShamanObject(0, arrow.x, arrow.y)
- end
- elseif (data.time == 20) then
- tfm.exec.removePhysicObject(1)
- elseif (data.time == 0) then
- if (#data.system.n > 1) then
- table.delete(data.system.n, data.system.currentChair)
- setChairs()
- end
- end
- end
- elseif (data.round == 0) then
- data.loadstr = (data.loadstr ~= '...' and data.loadstr .. '.' or '.')
- ui.setMapName("Loading" .. data.loadstr)
- if (data.time < 42) then
- setChairs()
- end
- end
- end
- function eventKeyboard(name, key, down, x, y)
- for k, v in next, data.system.n do
- if (#data.system.chairs > 0) then
- if (math.abs(data.system.chairs[v].x - x) <= 18) and not data.system.chairs[v].busy and (data.players[name].chair == 0) then
- data.players[name].chair = v
- data.system.chairs[v].busy = true
- ui.addTextArea(v, "<p align='center'><font size='10' color='#" .. data.system.chairs[v].color .. "'>" .. name, nil, (data.system.chairs[v].x - 50), (data.system.chairs[v].y + 10), 100, nil, nil, nil, 50, true)
- tfm.exec.setNameColor(name, '0x' .. data.system.chairs[v].color)
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement