Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- defaultLanguage = "es"
- tribeHouse = true
- roundTime = 123
- local gameFinished = true
- local gameStarted
- local gameLoaded
- local playersInRoom = 0
- local playersAlive
- local mice = {}
- local isAlive = {}
- -- messageBox by Hina
- local ui_msgbox_time = 8000
- local ui_msgbox_max = 5
- local ui_msgbox_x,ui_msgbox_y,ui_msgbox_w,ui_msgbox_h,ui_msgbox_dy = 100,50,600,20,35
- local ui_msgbox_c,ui_msgbox_bc,ui_msgbox_da = nil,nil,0.2
- local ui_msgbox_messages = {}
- maps = {
- '<C><P aie="" /><Z><S><S X="400" Y="395" L="800" H="50" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S X="400" Y="200" L="120" H="20" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S X="55" Y="265" L="30" H="150" T="9" P="0,0,,,,0,0,0" /><S X="745" Y="265" L="30" H="150" T="9" P="0,0,,,,0,0,0" /><S X="660" Y="110" L="40" H="20" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S X="140" Y="110" L="40" H="20" T="0" P="0,0,0.3,0.2,0,0,0,0" /></S><D><DC X="400" Y="175" /><DS X="400" Y="359" /></D><O /></Z></C>'
- ,
- '<C><P aie="" /><Z><S><S X="400" Y="395" L="800" H="50" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S X="400" Y="200" L="120" H="20" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S X="55" Y="265" L="30" H="150" T="9" P="0,0,,,,0,0,0" /><S X="745" Y="265" L="30" H="150" T="9" P="0,0,,,,0,0,0" /><S X="660" Y="110" L="40" H="20" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S X="140" Y="110" L="40" H="20" T="0" P="0,0,0.3,0.2,0,0,0,0" /></S><D><DC X="400" Y="175" /><DS X="400" Y="359" /></D><O /></Z></C>'
- }
- local text = {
- en = {
- shamanVictory = "%s killed all the mice. The Shaman wins!.";
- miceVictory = "%s failed. The mice win!";
- welcome = "<VP>Welcome to aieSurvivor! Have fun!";
- },
- es = {
- shamanVictory = "%s ha matado a todos los ratones. ¡El chamán gana!";
- miceVictory = "%s ha fallado. ¡Los ratones ganan!";
- welcome = "<VP>¡Bienvenid@ a aieSurvivor! ¡Diviértete!";
- }
- }
- _com = tfm.get.room.community
- function main()
- tfm.exec.disableAutoNewGame()
- tfm.exec.disableAutoTimeLeft()
- for n in pairs(tfm.get.room.playerList) do
- eventNewPlayer(n)
- end
- startGame()
- end
- function startGame()
- local newMap
- repeat
- newMap = math.random(#maps)
- until newMap ~= currentMap
- currentMap = newMap
- tfm.exec.newGame(maps[newMap])
- end
- function eventNewGame()
- gameLoaded = true
- gameStarted = false
- gameFinished = false
- tfm.exec.setGameTime(roundTime)
- playersAlive = playersInRoom
- isAlive = {}
- for name,m in pairs(mice) do
- isAlive[name] = true
- if tfm.get.room.playerList[name].isShaman then shaman = name end
- end
- end
- function endGame()
- gameFinished = true
- tfm.exec.setGameTime(5)
- if isAlive[shaman] and playersAlive == 1 then
- message(string.format(lang().shamanVictory, shaman), nil)
- for name in pairs(isAlive) do
- if name ~= shaman then tfm.exec.killPlayer(name) end
- end
- tfm.exec.playEmote(shaman, 0)
- else
- message(string.format(lang().miceVictory, shaman), nil)
- for name in pairs(isAlive) do
- if name ~= shaman then
- tfm.exec.giveCheese(name)
- tfm.exec.playerVictory(name)
- end
- tfm.exec.playEmote(shaman, 2)
- end
- end
- end
- function eventNewPlayer(name)
- playersInRoom = playersInRoom + 1
- mice[name] = {
- }
- message(lang().welcome, name)
- end
- function eventPlayerLeft(name)
- playersInRoom = playersInRoom - 1
- mice[name] = nil
- end
- function eventPlayerDied(name)
- if gameFinished then return end
- playersAlive = playersAlive - 1
- isAlive[name] = nil
- if name == shaman or playersAlive == 1 then
- endGame()
- end
- end
- function eventLoop(t,tr)
- if not gameLoaded then return end
- for i=1,ui_msgbox_max do
- local m = ui_msgbox_messages[i]
- if m and m.ts + ui_msgbox_time < os.time() then
- ui_msgbox_messages[i] = nil
- ui.removeTextArea(i, nil)
- end
- end
- if not gameStarted then
- if t > 3000 then
- gameStarted = true
- end
- return
- end
- if not gameFinished and tr <= 0 then
- endGame()
- elseif gameFinished and tr <= 0 then
- startGame()
- end
- end
- function message(msg, target)
- if tribeHouse then
- showMsg(msg, target)
- else
- tfm.exec.chatMessage(msg, target)
- end
- end
- function lang()
- return text[_com] or text[defaultLanguage]
- end
- -- messageBox by Hina
- function showMsg(msg, tgt)
- local box,j
- if ui_msgbox_messages[ui_msgbox_max] then ui_msgbox_messages[ui_msgbox_max] = nil end
- for i=#ui_msgbox_messages+1,1,-1 do
- if i==1 then
- ui_msgbox_messages[i] = {msg=msg, ts=os.time()}
- else
- ui_msgbox_messages[i] = ui_msgbox_messages[i-1]
- end
- j = i - 1
- ui.addTextArea(i, ui_msgbox_messages[i].msg, tgt, ui_msgbox_x, ui_msgbox_y + j*ui_msgbox_dy, ui_msgbox_w, ui_msgbox_h, ui_msgbox_c, ui_msgbox_bc, 1 - j*ui_msgbox_da, true)
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement