Skip to content

Instantly share code, notes, and snippets.

@Zerquix18
Created October 1, 2015 18:05
Show Gist options
  • Save Zerquix18/fb0873e8d79228a2cb66 to your computer and use it in GitHub Desktop.
Save Zerquix18/fb0873e8d79228a2cb66 to your computer and use it in GitHub Desktop.
-- Made by Zerquix! A nostalgic guy :)
tfm.exec.disableAutoNewGame(true)
tfm.exec.disableAutoShaman(true)
tfm.exec.disableAllShamanSkills(true)
tfm.exec.setGameTime(120) -- 2 mins
-- old survivor maps --
maps = {'@276534', '@279689', '@280120', '@280159', '@281431', '@281479', '@281492', '@281649', '@289932', '@289964', '@290388', '@290546', '@290725', '@290865', '@290971', '@290974', '@291399', '@291643', '@292592', '@292672', '@292678', '@293222', '@293487', '@295988', '@296033', '@299123', '@300404', '@302224', '@304198', '@304482', '@305748', '@305753', '@306106', '@306360', '@306382', '@307925', '@307930', '@311496', '@390383', '@390386', '@390649', '@390657', '@391057', '@391643', '@391664', '@391738', '@392616', '@392646', '@393406', '@395246', '@397066', '@478116', '@479091', '@481676', '@489470', '@489829', '@908739', '@521931', '@490248', '@540495', '@500312', '@495880' }
shaman = '' -- current sham
players = {} -- all players in the room
messages = {
EN = {
"• [Moderation] Beware of %s!",
"• [Moderation] Aww, %s has died. T_T",
"• [Moderation] Good job, %s, your turn now!",
"• [Moderation] Time's up, %s has failed. ^_^",
"Get em', Tiger! *-*" -- <3
},
ES = {
"• [Moderación] Cuidado con %s!",
"• [Moderación] Aww, %s ha muerto. T_T",
"• [Moderación] ¡Buen trabajo, %s, ahora es tu turno!",
"• [Moderación] Se acabó el tiempo, %s ha fallado. ^_^",
"¡Ve por ellos, tigre! *-*"
},
BR = {
"• [Moderação] Cuidado com o %s!",
"• [Moderação] Aww, %s morreu. T_T",
"• [Moderação] Bom trabalho, %s, agora é a sua vez!",
"• [Moderação] Acabou o tempo, %s falhou. ^_^",
"Pegue-os, Tigrão! *-*"
},
FR = {
"• [Modération] Attention à %s!",
"• [Modération] Aww, %s est morte. T_T",
"• [Modération] Bien joué, %s, maintenant, à ton tour !",
"• [Modération] Le temps s'est écoulé, %s a échoué. ^_^",
"Prends-les, Tigre ! *-*"
}
}
--
function in_array(needle, haystack)
for k,v in pairs(haystack) do
if v == needle then
return true
end
end
return false
end
--
lang = tfm.get.room.community
if not in_array( lang, {'EN', 'ES'} ) then
lang = 'EN'
end
messages = messages[lang]
--
function random( ist )
return ist[ math.random( #ist ) ]
end
function printf(s,...)
print( string.format(s, ...) )
end
function eventNewPlayer( player )
table.insert(players, player)
end
function eventPlayerLeft( player )
for k,v in ipairs(players) do
if v == player then
table.remove(players, k)
end
end
for k,v in ipairs(alive) do
if v == player then
table.remove(alive, k)
end
end
if shaman == player then
while time > 114 do end -- cause you can't call newGame() if 3s hasnt passed
shaman = ''
tfm.exec.newGame(random(maps))
return
end
end
function eventNewGame()
alive = {}
for k,v in ipairs(players) do
table.insert(alive, v)
end
time = 117
if shaman ~= '' and shaman ~= nil then
tfm.exec.setShaman(shaman)
tfm.exec.setUIShamanName(shaman)
printf(messages[1], shaman)
shaman = ''
return
end
lol = random(players)
tfm.exec.setShaman( lol )
tfm.exec.setUIShamanName(lol)
printf(messages[1], lol)
end
function eventPlayerDied( player )
while time > 114 do end -- because you can't call exec.newGame in 3s
if tfm.get.room.playerList[player].isShaman then
if #players > 1 then
for k,v in ipairs(players) do
if not tfm.get.room.playerList[v].isShaman then
shaman = v
break
end
end
end
printf(messages[2], player)
tfm.exec.newGame( random(maps) )
return
end
test = false
for k,v in pairs(alive) do
if v == player then
key = k
test = true
end
end
if test then
table.remove(alive, key)
end
if #alive == 1 then -- the shaman is the only one
tfm.exec.newGame( random(maps) )
return
end
if #alive == 2 then -- shaman and someone else
for key,value in ipairs(alive) do
if tfm.get.room.playerList[value].isShaman then
table.remove(alive, key) --remove the shaman
end
end
shaman = alive[1] -- last one!
printf(messages[3], shaman)
tfm.exec.newGame( random(maps) )
return
end
end
function eventLoop()
if time == nil then
return -- sometimes this function is executed before eventNewGame
end
time = time - 0.5
if 0 == time then
for k,v in ipairs(alive) do
if tfm.get.room.playerList[v].isShaman then
table.remove(alive, k) -- remove the shaman
printf(messages[4], v)
end
end
if #alive ~= 0 then
shaman = random(alive)
end
tfm.exec.newGame(random(maps))
end
end
tfm.exec.newGame( random(maps) )
for name,player in pairs(tfm.get.room.playerList) do
eventNewPlayer(name)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment