Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local default_questions = {
- {
- title = 'O Transformice foi criado em que ano?',
- answer = '2010',
- options = {'2009', '2011', '2012'}
- },
- {
- title = 'O transformice foi criado em 2010?',
- answer = true
- },
- {
- title = 'Biscoito ou Bolacha?',
- answer = 'Biscoito',
- options = {'Bolacha'}
- },
- {
- title = 'Funcorps fazem parte da staff?',
- answer = false
- },
- {
- title = 'Feijão por cima do arroz, ou arroz por cima do feijão?',
- answer = 'Feijão por cima do arroz',
- options = {'Arroz por cima do feijão'}
- },
- }
- local commands = {
- ['skip'] = {desc = 'Pule uma pergunta'},
- ['say'] = {options = '[Mensagem]', desc = 'Envie uma mensagem customizada'}
- }
- local map = '<C><P /><Z><S><S P="0,0,0.3,0.2,0,0,0,0" L="3000" o="0" X="422" c="4" Y="191" T="12" H="3000" /><S L="799" X="400" H="29" Y="387" T="6" P="0,0,0.3,0.2,0,0,0,0" /><S L="40" X="21" H="196" Y="275" T="6" P="0,0,0,0,0,0,0,0" /><S L="40" H="196" X="780" Y="275" T="6" P="0,0,0,0,0,0,0,0" /><S P="0,0,0,0,0,0,0,0" L="94" o="ffffff" H="20" Y="79" T="12" X="400" /><S L="94" o="ffffff" H="20" X="400" Y="29" T="12" P="0,0,0,0,0,0,0,0" /><S P="0,0,0,0,90,0,0,0" L="70" o="ffffff" X="363" H="20" Y="54" T="12" lua="1" /><S P="0,0,0,0,90,0,0,0" L="70" o="ffffff" H="20" lua="0" Y="54" T="12" X="437" /><S P="0,0,0,0,0,0,0,0" L="10" o="0" H="175" Y="89" T="12" X="36" /><S L="10" o="0" H="175" X="765" Y="89" T="12" P="0,0,0,0,0,0,0,0" /></S><D><DS Y="58" X="402" /></D><O /></Z></C>'
- local command_list = ''
- local command_length = 0
- local questions = {}
- local skip = false
- for i in next, commands do
- system.disableChatCommandDisplay(i)
- command_length = command_length + 1
- command_list = ('%s\n<J>!%s</J><BL>%s : %s</BL>'):format(command_list, i, commands[i].options and ' <V>'..commands[i].options..'</V>' or '', commands[i].desc)
- end
- do
- local _, nickname = pcall(nil)
- owner = string.match(nickname, "(.-)%.")
- end
- function split (t, s)
- local a={}
- for i in string.gmatch(t, "[^" .. (s or "%s") .. "]+") do
- a[#a + 1] = i
- end
- return a
- end
- -- table copy
- function copy(a,b)if type(a)~='table'then return a end;if b and b[a]then return b[a]end;local c=b or{}local d=setmetatable({},getmetatable(a))c[a]=d;for e,f in pairs(a)do d[copy(e,c)]=copy(f,c)end;return d end
- -- Sleep
- do local a={}avl=function()local b={}for c,d in next,a do if not d[2]or d[2]<os.time()then if coroutine.status(d[1])=='dead'then b[#b+1]=c else local e,f=coroutine.resume(d[1])d[2]=f end end end;if b[1]then for c,d in next,b do a[d]=nil end end end;timer=function(g)local h=nil;a[#a+1]={coroutine.create(function()local i=function(j)coroutine.yield(os.time()+math.floor(j/500)*500)end;g(i)end),timeValue=nil}end end
- eventLoop = avl
- function resetQuestions()
- questions = copy(default_questions)
- end
- function generateGrounds(grounds, correct, options)
- local new_options = {}
- local correct_coords = {}
- for i = 1, grounds - 1 do
- new_options[#new_options + 1] = table.remove(options, math.random(#options))
- end
- new_options[#new_options + 1] = correct
- for i = 1, grounds do
- local dif = 800/grounds
- local x = i * dif
- local answer = tostring(table.remove(new_options, math.random(#new_options)))
- local textAreaX = x - (i == 1 and dif - 40 or dif) + 10
- local textAreaY = 200
- local textAreaWidth = (i == 1 and dif - 40 or i == grounds and dif - 30 or dif) - 20
- local textAreaHeight = 170
- if answer == correct then
- correct_coords = {x = textAreaX, y = textAreaY, width = textAreaWidth, height = textAreaHeight}
- end
- ui.addTextArea(i, '<p align="center"><font size="30">' .. answer .. '</font></p>', nil, textAreaX, textAreaY, textAreaWidth, textAreaHeight, 0xFFFFFF, 0xFFFFFF, 0, false)
- if i ~= grounds then
- tfm.exec.addPhysicObject(i + 2, x, 280, {type = 8, miceCollision = true, width = 10, height = 180})
- end
- end
- return correct_coords
- end
- function checkPlayers(killed)
- local alive = 0
- local last
- for name, data in next, tfm.get.room.playerList do
- if not data.isDead and not killed[name] then
- alive = alive + 1
- last = name
- end
- end
- return alive, last
- end
- function showMessage(message)
- ui.addTextArea(0, "<p align='center'><font size='30'>"..message.."</font></p>", nil, 50, 110, 700, 0, 1, 1, 0, true)
- end
- function eventNewGame()
- timer(function(sleep)
- sleep(10000)
- -- Questions loop
- while true do
- skip = false
- for name, data in next, tfm.get.room.playerList do
- tfm.exec.movePlayer(name, 400, 58)
- end
- ui.removeTextArea(0)
- for i = 0, 7 do
- tfm.exec.removePhysicObject(i)
- end
- if #questions == 0 then
- resetQuestions()
- end
- local question = table.remove(questions, math.random(#questions))
- local correct_coords = {}
- if type(question.answer) == 'boolean' then
- correct_coords = generateGrounds(2, question.answer and 'Sim' or 'Não', {not question.answer and 'Sim' or 'Não'})
- else
- local houses = math.random(#question.options > 3 and 3 or #question.options) + 1
- correct_coords = generateGrounds(houses, question.answer, question.options)
- end
- showMessage(question.title)
- for i = 1, 20 do
- if skip then break end
- sleep(500)
- end
- local killed = {}
- if not skip then
- for name, data in next, tfm.get.room.playerList do
- if not data.isDead then
- if not (data.x >= correct_coords.x and data.x <= correct_coords.x + correct_coords.width and data.y >= correct_coords.y and data.y <= correct_coords.y + correct_coords.height) then
- tfm.exec.killPlayer(name)
- killed[name] = true
- end
- end
- end
- end
- for i = 0, 4 do
- ui.removeTextArea(i)
- end
- if not skip then
- local players, last = checkPlayers(killed)
- if players == 1 then
- tfm.exec.giveCheese(last)
- tfm.exec.playerVictory(last)
- showMessage("Parabéns, "..last.."!")
- break
- elseif players == 0 then
- showMessage("Não há vencedor(a)!")
- break
- end
- sleep(5000)
- end
- end
- sleep(5000)
- ui.removeTextArea(0)
- tfm.exec.newGame(map)
- end)
- end
- function eventChatCommand(name, cmd)
- local args = split(cmd, ' ')
- if name == owner then
- if args[1] == 'say' and args[1] then
- table.remove(args, 1)
- local message = table.concat(args, ' ')
- tfm.exec.chatMessage(('<font color="#fe8446">[%s]</font> <J>%s</J>'):format(string.match(name, "(.-)#."), message))
- elseif args[1] == 'skip' then
- skip = true
- end
- end
- end
- function eventNewPlayer(name)
- if name == owner then
- tfm.exec.chatMessage('<ROSE>Olá, <font color="#fe8446">'..string.match(name, "(.-)#.")..'</font>! Você tem disponível '..command_length..' comandos:</ROSE>'..command_list, name)
- end
- end
- table.foreach(tfm.get.room.playerList, eventNewPlayer)
- for index, value in next, {'AutoShaman', 'AutoNewGame', 'AutoTimeLeft', 'PhysicalConsumables', 'AfkDeath', 'DebugCommand', 'AutoScore'} do
- tfm.exec['disable' .. value]()
- end
- tfm.exec.newGame(map)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement