×

Langue

Fermer
Atelier 801
  • Forums
  • Dev Tracker
  • Connexion
    • English Français
      Português do Brasil Español
      Türkçe Polski
      Magyar Română
      العربية Skandinavisk
      Nederlands Deutsch
      Bahasa Indonesia Русский
      中文 Filipino
      Lietuvių kalba 日本語
      Suomi עברית
      Italiano Česky
      Hrvatski Slovensky
      Български Latviešu
      Estonian
  • Langue
  • Forums
  • /
  • Transformice
  • /
  • Modules
  • /
  • [Tutorial] Rotação de mapas com categorias
[Tutorial] Rotação de mapas com categorias
Bolodefchoco
« Sénateur »
1553263740000
    • Bolodefchoco#0095
    • Profil
    • Derniers messages
    • Tribu
#1
  2
Em maps.queue você deve inserir a sequência dos números das categorias na ordem desejada.
Exemplo: Caso você deseje as categorias 1, 2, 2, 3 e 4 → { 1, 2, 2, 3, 4 }.
Você pode criar um valor-tabela para que seja aleatório

Uma categoria pode ser feita com
Code Lua

1
2
3
[id] = {
queue = { 1234, 4567, 7890, ... }, -- Maps
}

Você também pode inserir uma função que é executada toda vez que um mapa dessa categoria será carregado (antes)
Code Lua

1
2
3
4
5
6
[id] = {
queue = { 1234, 4567, 7890, ... }, -- Maps
fBefore = function(mapCode)
print("O mapa " .. mapCode .. " vai começar!")
end
}

Você também pode inserir uma função que é executada toda vez que um mapa dessa categoria é carregado (depois)
Code Lua

1
2
3
4
5
6
[id] = {
queue = { 1234, 4567, 7890, ... }, -- Maps
fAfter = function(mapCode)
print("O mapa " .. mapCode .. " começou!")
end
}

- Não há suporte para edição runtime da tabela maps
- Comportamento de fAfter editável (disparado sempre) caso você remova as linhas 97, 98, 99 e 101


https://github.com/Lautenschlager-id/Transformice/blob/master/Others/MapRotationCategory.lua
Code Lua

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
local maps = {
-- When queue gets a table value, it'll return a random value when processed.
queue = { 1, 2, 3, { 1, 2, 3 } },

[1] = {
queue = { }, -- Maps goes herem
fBefore = function(mapCode)
-- Triggered before the map gets started
end,
fAfter = function(mapCode)
-- Trigered after the map is started
end
},
[2] = {
queue = { }
},
[3] = {
queue = { }
}
}
do
local shuffle = function(list)
local index
for i = #list, 1, -1 do
index = math.random(i)
list[index], list[i] = list[i], list[index]
end
end
local set = function(list)
local out = { }
for _, index in next, list do
out[index] = true
end
return out
end

maps.queue._next = 1
maps.queue._lastCat = nil
maps.queue._len = #maps.queue
for i = 1, #maps do
shuffle(maps[i].queue)
maps[i] = {
_next = 1, -- Don't change
fBefore = maps[i].fBefore,
fAfter = maps[i].fAfter,
queue = maps[i].queue,
_queueLen = #maps[i].queue,
_hashedQueue = set(maps[i].queue)
}
end

maps = setmetatable(maps, {
__call = function(this, category)
category = tonumber(category)
local hasCat = not not category
if not hasCat or not this[category] then
category = this.queue[this.queue._next]
if type(category) == "table" then
category = category[math.random(#category)]
end
this.queue._next = this.queue._next % maps.queue._len + 1
end
this.queue._lastCat = category

local map
if hasCat then
map = this[category].queue[math.random(this[category]._queueLen)]
else
map = this[category].queue[this[category]._next]

if this[category]._next == this[category]._queueLen then
shuffle(this[category].queue)
this[category]._next = 1
else
this[category]._next = this[category]._next + 1
end
end

if this[category].fBefore then
this[category].fBefore(map)
end

return map
end
})
end

local alive, nextMap = 0
eventNewGame = function()
nextMap = nil
do
local category = maps.queue._lastCat
if maps[category].fAfter then
local currentMap = tonumber(tfm.get.room.currentMap)
local isMap = maps[category]._hashedQueue[currentMap]
if not isMap and tfm.get.room.xmlMapInfo then
isMap = maps[category]._hashedQueue[tfm.get.room.xmlMapInfo.mapCode] or maps[category]._hashedQueue[tonumber(tfm.get.room.xmlMapInfo.mapCode)]
end
if isMap then
maps[category].fAfter(currentMap)
end
end
end
alive = 0
for _ in next, tfm.get.room.playerList do
alive = alive + 1
end
end

eventLoop = function(currentTime, remainingTime)
if alive < 1 or remainingTime < 500 then
if not nextMap then
nextMap = maps()
end
tfm.exec.newGame(nextMap)
end
end

eventPlayerDied = function()
alive = alive - 1
end
eventPlayerRespawn = function()
alive = alive + 1
end

tfm.exec.disableAutoNewGame()
tfm.exec.setGameTime(0)


Rotação de exemplo

Code Lua

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
local maps = {
queue = { 1, 2, 2, 2, 1 },
[1] = { -- Todos shaman
queue = { 1260419 },
fAfter = function()
for player in next, tfm.get.room.playerList do
tfm.exec.setShaman(player)
end
end
},
[2] = { -- Sem shaman em mapas P5
queue = { 317282 },
fBefore = function()
tfm.exec.disableAutoShaman()
end,
fAfter = function()
tfm.exec.disableAutoShaman(false)
end
}
}

Dernière modification le 1554505440000
Rip
« Citoyen »
1553267520000
    • Rip#8110
    • Profil
    • Derniers messages
    • Tribu
#2
  0
Mt bom
  • Forums
  • /
  • Transformice
  • /
  • Modules
  • /
  • [Tutorial] Rotação de mapas com categorias
© Atelier801 2018

Equipe Conditions Générales d'Utilisation Politique de Confidentialité Contact

Version 1.27