×

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
  • /
  • Archives
  • /
  • Seção Editor de Mapas e Modules
  • /
  • [Lua] Peça scripts aqui!
« ‹ 109 / 133 › »
[Lua] Peça scripts aqui!
Zabalaia
« Citoyen »
1568672520000
    • Zabalaia#0000
    • Profil
    • Derniers messages
    • Tribu
#2161
  0
Espero que n seja complicado eu n faço ideia d eprogramação, eu só queria uma esteira que quanto mais vc anda nela mais rapido o rato fica ;-;
Fantastic
« Citoyen »
1568917800000
    • Fantastic#9643
    • Profil
    • Derniers messages
    • Tribu
#2162
  0
Olá eu queria a ajuda de alguém que manja com Scripts para me ajudar a modificar algumas coisas no meu script, qualquer coisa me chamem no jogo
Sans_ink
« Citoyen »
1569807720000
    • Sans_ink#0000
    • Profil
    • Derniers messages
#2163
  0
Homemmulherrr a dit :
um script que vc aperta "espaço" é solta bolinhas de neve é tem um tempo uns 7 minutos cada jogador que atacar a bolinha de neve em outro jogador ganha 10 pontos. é cada vez que acaba o tempo se ainda tiver jogador o tempo automaticamente vai para 2 minutos. é que o mapa seja bem grande é cheio de obstaculo parecido com o module batata tipo os mapas de lá tem que ser grande é bom.
Por favor faz pra mim Obrigado.
Isabel79135
« Citoyen »
1570909320000
    • Isabel79135#8040
    • Profil
    • Derniers messages
#2164
  0
um script de o mestre mandou porfavor
Sklag
« Citoyen »
1570917660000
    • Sklag#2552
    • Profil
    • Derniers messages
    • Tribu
#2165
  0
Um script que pode usar dash eu n quero explosão e sim que muda a velocidade do player por apenas 5 segundos e depois mostra no chat que podera usar denovo em 10 segundos
Spiderwii
« Citoyen »
1571149860000
    • Spiderwii#0000
    • Profil
    • Derniers messages
    • Tribu
#2166
  0
To com uma duvida aqui, Como faço pra criar uma Lista de numeros e Depois Pegar um valor aleatório que está lista ?
Infectsoul
1571150940000
    • Infectsoul#2048
    • Profil
    • Derniers messages
    • Tribu
#2167
[Modéré par Kiwrimai, raison : Removido a pedido do autor.]

Dernière modification le 1575919440000
Jp_darkuss
« Citoyen »
1571187240000
    • Jp_darkuss#4806
    • Profil
    • Derniers messages
#2168
  0
Gente, preciso de ajuda. Estou com um script meu e ele está dando erro frequentemente, mas eu não consigo achar o erro. Olhem o script.
Script

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
ui.addTextArea(0, "Calculadora", nil, 150, 100, 100, 100, silver, black, 0.6, true)
eventChatCommand= function(player, c)
local cmd= {}
for i in string.gmatch(c, "%S+") do
table.insert(cmd, i)
end
if (cmd[1]=="add") then
ui.updateTextArea(0, cmd[2] + cmd[3], player)
elseif (cmd[1]=="sub") then
ui.updateTextArea(0, cmd[2] - cmd[3], player)
elseif (cmd[1]=="mult") then
ui.updateTextArea(0, cmd[2] * cmd[3], player)
elseif (cmd[1]=="div") then
ui.updateTextArea(0, cmd[2] / cmd[3], player)
elseif (cmd[1]=="pot") then
ui.updateTextArea(0, cmd[2] ^ cmd[3], player)
elseif (cmd[1]=="rad") then
if (cmd[2]=="2" or cmd[2]=="3" and type(tonumber(com[3]))=="number") then
if (cmd[2]=="2") then
rad= function(n)
for i= 0, n, 1 do
if (i * i== n) then
return i
break
elseif (i * i> n) then
return "The number "..n.." don't have rad²"
break
end
end
end
ui.updateTextArea(0, rad(tonumber(cmd[3])), player)
elseif (cmd[2]=="3")
rad= function(n)
for i= 0, n, 1 do
if (i * i * i== n) then
return i
break
elseif (i * i * i> n) then
return "The number "..n.." don't have rad³"
break
end
end
end
ui.updateTextArea(0, rad(tonumber(cmd[3])), player)
end
else
ui.updateTextArea(0, "Syntax error, please type the command correctly")
end
end
end


Toda vez que eu o rodo, o console do TFM responde o seguinte erro:
Erro
• [21:50] # [*Epickylp] Init Error : [string "Jp_darkuss#4806.lua"]:24: 'end' expected (to close 'if' at line 22)
, mas não consigo descobrir onde está o erro, pois o console diz que falta um "end" para fechar um "if", mas eu olhei e ele está sendo fechado; podem me ajudar?
Fly
« Citoyen »
1571252220000
    • Fly#8215
    • Profil
    • Derniers messages
    • Tribu
#2169
  0
Jp_darkuss a dit :
Gente, preciso de ajuda. Estou com um script meu e ele está dando erro frequentemente, mas eu não consigo achar o erro. Olhem o script.
Script

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
ui.addTextArea(0, "Calculadora", nil, 150, 100, 100, 100, silver, black, 0.6, true)
eventChatCommand= function(player, c)
local cmd= {}
for i in string.gmatch(c, "%S+") do
table.insert(cmd, i)
end
if (cmd[1]=="add") then
ui.updateTextArea(0, cmd[2] + cmd[3], player)
elseif (cmd[1]=="sub") then
ui.updateTextArea(0, cmd[2] - cmd[3], player)
elseif (cmd[1]=="mult") then
ui.updateTextArea(0, cmd[2] * cmd[3], player)
elseif (cmd[1]=="div") then
ui.updateTextArea(0, cmd[2] / cmd[3], player)
elseif (cmd[1]=="pot") then
ui.updateTextArea(0, cmd[2] ^ cmd[3], player)
elseif (cmd[1]=="rad") then
if (cmd[2]=="2" or cmd[2]=="3" and type(tonumber(com[3]))=="number") then
if (cmd[2]=="2") then
rad= function(n)
for i= 0, n, 1 do
if (i * i== n) then
return i
break
elseif (i * i> n) then
return "The number "..n.." don't have rad²"
break
end
end
end
ui.updateTextArea(0, rad(tonumber(cmd[3])), player)
elseif (cmd[2]=="3")
rad= function(n)
for i= 0, n, 1 do
if (i * i * i== n) then
return i
break
elseif (i * i * i> n) then
return "The number "..n.." don't have rad³"
break
end
end
end
ui.updateTextArea(0, rad(tonumber(cmd[3])), player)
end
else
ui.updateTextArea(0, "Syntax error, please type the command correctly")
end
end
end


Toda vez que eu o rodo, o console do TFM responde o seguinte erro:
Erro
• [21:50] # [*Epickylp] Init Error : [string "Jp_darkuss#4806.lua"]:24: 'end' expected (to close 'if' at line 22)
, mas não consigo descobrir onde está o erro, pois o console diz que falta um "end" para fechar um "if", mas eu olhei e ele está sendo fechado; podem me ajudar?

Sim, está fechado. O que está causando o erro é o break localizado após o return. Em Lua, o uso do return precisa ser obrigatoriamente a última declaração em um bloco.
O return já faz o trabalho de parar o loop, então vc não precisa usar break.
Spiderwii
« Citoyen »
1571255280000
    • Spiderwii#0000
    • Profil
    • Derniers messages
    • Tribu
#2170
  0
Como posso fazer a comparação ao Pegar o queijo algo aconteça?
Jp_darkuss
« Citoyen »
1571438880000
    • Jp_darkuss#4806
    • Profil
    • Derniers messages
#2171
  0
Fly a dit :
Jp_darkuss a dit :
Gente, preciso de ajuda. Estou com um script meu e ele está dando erro frequentemente, mas eu não consigo achar o erro. Olhem o script.
Script

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
ui.addTextArea(0, "Calculadora", nil, 150, 100, 100, 100, silver, black, 0.6, true)
eventChatCommand= function(player, c)
local cmd= {}
for i in string.gmatch(c, "%S+") do
table.insert(cmd, i)
end
if (cmd[1]=="add") then
ui.updateTextArea(0, cmd[2] + cmd[3], player)
elseif (cmd[1]=="sub") then
ui.updateTextArea(0, cmd[2] - cmd[3], player)
elseif (cmd[1]=="mult") then
ui.updateTextArea(0, cmd[2] * cmd[3], player)
elseif (cmd[1]=="div") then
ui.updateTextArea(0, cmd[2] / cmd[3], player)
elseif (cmd[1]=="pot") then
ui.updateTextArea(0, cmd[2] ^ cmd[3], player)
elseif (cmd[1]=="rad") then
if (cmd[2]=="2" or cmd[2]=="3" and type(tonumber(com[3]))=="number") then
if (cmd[2]=="2") then
rad= function(n)
for i= 0, n, 1 do
if (i * i== n) then
return i
break
elseif (i * i> n) then
return "The number "..n.." don't have rad²"
break
end
end
end
ui.updateTextArea(0, rad(tonumber(cmd[3])), player)
elseif (cmd[2]=="3")
rad= function(n)
for i= 0, n, 1 do
if (i * i * i== n) then
return i
break
elseif (i * i * i> n) then
return "The number "..n.." don't have rad³"
break
end
end
end
ui.updateTextArea(0, rad(tonumber(cmd[3])), player)
end
else
ui.updateTextArea(0, "Syntax error, please type the command correctly")
end
end
end


Toda vez que eu o rodo, o console do TFM responde o seguinte erro:
Erro
• [21:50] # [*Epickylp] Init Error : [string "Jp_darkuss#4806.lua"]:24: 'end' expected (to close 'if' at line 22)
, mas não consigo descobrir onde está o erro, pois o console diz que falta um "end" para fechar um "if", mas eu olhei e ele está sendo fechado; podem me ajudar?

Sim, está fechado. O que está causando o erro é o break localizado após o return. Em Lua, o uso do return precisa ser obrigatoriamente a última declaração em um bloco.
O return já faz o trabalho de parar o loop, então vc não precisa usar break.

Obrigado!
Jp_darkuss
« Citoyen »
1571439120000
    • Jp_darkuss#4806
    • Profil
    • Derniers messages
#2172
  0
Fly#8215, acabei de tirar o break e o erro ainda ocorre; tem mais algum?
Ps: O erro continua igual no console...
Jp_darkuss
1571451840000
    • Jp_darkuss#4806
    • Profil
    • Derniers messages
#2173
[Modéré par Naiyme, raison : Triple post.]
Fly
« Citoyen »
1571498940000
    • Fly#8215
    • Profil
    • Derniers messages
    • Tribu
#2174
  0
Jp_darkuss a dit :
Fly#8215, acabei de tirar o break e o erro ainda ocorre; tem mais algum?
Ps: O erro continua igual no console...

Não é só um break. Linhas 24, 27, 37 e 40
Spiderwii
« Citoyen »
1571507940000
    • Spiderwii#0000
    • Profil
    • Derniers messages
    • Tribu
#2175
  0
Existe ma maneira de remover um objeto sham apos Xtempo apos Spawn ?
Jp_darkuss
« Citoyen »
1571526900000
    • Jp_darkuss#4806
    • Profil
    • Derniers messages
#2176
  0
Obrigado Fly, agora está funcionando!
Burlazento21
« Citoyen »
1571953800000
    • Burlazento21#0000
    • Profil
    • Derniers messages
#2177
  0
Ola quero script de x1 de equipes vanilla sem shaman e se puder os comandos
Thefrogplayer
« Citoyen »
1571956860000
    • Thefrogplayer#2537
    • Profil
    • Derniers messages
#2178
  0
cria um script de barra de vida

quando o jogador tomar dano de algum objeto
ele toma dano e quando chegar a 0 o jogador morre
Mashmellliiiiiw
1572622620000
    • Mashmellliiiiiw#7990
    • Profil
    • Derniers messages
    • Tribu
#2179
[Modéré par Naiyme, raison : Sem relação com o tópico.]
Fly
« Citoyen »
1572627960000
    • Fly#8215
    • Profil
    • Derniers messages
    • Tribu
#2180
  0
Spiderwii a dit :
Existe ma maneira de remover um objeto sham apos Xtempo apos Spawn ?

Sim
Exemplo com objetos de shaman
Code Lua

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
local object_list = { }

local countdown = 5000 -- Tempo em milissegundos

function eventLoop()
for i = #object_list, 1, -1 do
if (object_list[i][2] <= (os.time() - countdown)) then
tfm.exec.removeObject(object_list[i][1])

table.remove(object_list, i)
end
end
end

function eventSummoningEnd(_, __, ___, ____, _____, object)
object_list[#object_list + 1] = { object.id, os.time() }
end

Burlazento21 a dit :
Ola quero script de x1 de equipes vanilla sem shaman e se puder os comandos

Script x1 (Esh 2017) - Versão Vanilla
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
tfm.exec.disableAutoShaman()
tfm.exec.disableAutoNewGame()
tfm.exec.disableAutoTimeLeft()

local ADMINISTRADOR = "Burlazento21#0000"
local WINS = 10 -- Máximo de pontos para vencer o jogo
system.disableChatCommandDisplay("np", true)

--[[
Comandos:
!team1 players / !team2 players
Adiciona jogadores ao time um ou time dois

!np @code
Adiciona um mapa na lista

!score team1 number / !score team2 number
Altera o número de pontos do time um ou time dois
]]

local teams = {
[1] = {},
[2] = {},
}
local points = {
[1] = 0,
[2] = 0,
}
local isfirst = false
local gameRunning = false
local winTime = false
local playersInGame = {}
local maps = {
1, 2, 6, 7, 8, 9, 10, 11, 12, 13, 14, 33, 34, 35, 36, 37, 38, 40, 41, 42, 43, 44, 45, 49, 53, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 67, 68, 69, 70, 71, 73, 74, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 88, 73, 74, 75, 76, 77, 78, 89, 92, 95, 96, 100, 114, 117, 118, 119, 202, 203, 204, 205, 206, 120, 121, 122, 123, 124, 125, 126, 127, 136, 138, 142, 145, 147, 148, 149, 150, 151, 200, 19, 22, 23, 24, 27, 28, 29, 30, 31, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 6602124
}
local colors = {
[1] = "ff6347",
[2] = "19b5fe"
}
local queue = {}

function newMap()
local mapcode = maps[math.random(#maps)]
if #queue > 0 then
mapcode = queue[1]
table.remove(queue, 1)
end
tfm.exec.newGame(mapcode)
for player, data in pairs(tfm.get.room.playerList) do
if not playersInGame[player] then
tfm.exec.killPlayer(player)
end
end
tfm.exec.setGameTime(60)
end

function eventPlayerWon(player)
if not isfirst then
isfirst = true
tfm.exec.setGameTime(5)
if table.contains(teams[1], player) then
tfm.exec.setGameTime(5)
for i = 0, 3 do
defaultEffect(9, {13}, math.random(800), math.random(400), 20)
end
points[1] = points[1]+1
elseif table.contains(teams[2], player) then
tfm.exec.setGameTime(5)
for i = 0, 3 do
defaultEffect(9, {9}, math.random(800), math.random(400), 20)
end
points[2] = points[2]+1
else
isfirst = false
end
winner = false
if points[1] >= WINS then
winner = 1
elseif points[2] >= WINS then
winner = 2
end
if winner then
gameRunning = false
winTime = os.time()
ui.addTextArea(20, string.format("<p align='center'><font size='37' color='#000000'>TEAM %s IS THE WINNER!", winner), nil, 0, 171, 800, 500, 0, 0, 0, true)
ui.addTextArea(21, string.format("<p align='center'><font size='37' color='#000000'>TEAM %s IS THE WINNER!", winner), nil, 1, 170, 800, 500, 0, 0, 0, true)
ui.addTextArea(22, string.format("<p align='center'><font size='37' color='#%s'>TEAM %s IS THE WINNER!", colors[winner], winner), nil, 1, 170, 800, 500, 0, 0, 0, true)
end
displayScore()
end
end

function eventLoop(elapsed, remain)
if gameRunning then
remain = remain/1000
if remain < 0 then
remain = 100
newMap()
end
else
if winTime then
if winTime > os.time()-30000 then
for i = 0, 2 do
defaultEffect(9, {11, 9, 0, 13}, math.random(800), math.random(400), 80)
end
else
winTime = false
ui.removeTextArea(20)
ui.removeTextArea(21)
ui.removeTextArea(22)
displayTeams()
teams = {
[1] = {},
[2] = {},
}
points = {
[1] = 0,
[2] = 0,
}
playersInGame = {}
end
end
end
end

function eventChatCommand(player, command)
if player:lower() == ADMINISTRADOR:lower() then
args = string.split(command, " ")
if args[1] == "team1" then
table.remove(args, 1)
teams[1] = {}
points[1] = 0
for index, player in pairs(args) do
table.insert(teams[1], player)
playersInGame[player] = true
end
displayTeams()

elseif args[1] == "team2" then
table.remove(args, 1)
teams[2] = {}
points[2] = 0
for index, player in pairs(args) do
table.insert(teams[2], player)
playersInGame[player] = true
end
displayTeams()

elseif args[1] == "score" then
if args[2] and args[3] then
local team = tonumber(args[2]:match("team(%d+)") or 0)
if team > 0 and team < 3 then
local newScore = tonumber(args[3]) or points[team]
points[team] = newScore
displayScore()
end
end
elseif args[1] == "np" then
if args[2] then
table.insert(queue, args[2])
end
end
end
end

function eventNewGame()
if gameRunning then
isfirst = false
for i, p in pairs(teams[1]) do
tfm.exec.setNameColor(p, "0x"..colors[1])
end
for i, p in pairs(teams[2]) do
tfm.exec.setNameColor(p, "0x"..colors[2])
end
displayScore()
end
end

function displayScore()
ui.addTextArea(17, string.format("<p align='center'><font size='23' color='#000000'>%s x %s", points[1], points[2]), nil, 0, 21, 800, 30, 0, 0, 0, true)
ui.addTextArea(18, string.format("<p align='center'><font size='23' color='#000000'>%s x %s", points[1], points[2]), nil, 1, 20, 800, 30, 0, 0, 0, true)
ui.addTextArea(19, string.format("<p align='center'><font size='23'><font color='#%s'>%s<N> x <font color='#%s'>%s", colors[1], points[1], colors[2], points[2]), nil, 0, 20, 800, 30, 0, 0, 0, true)
end

function displayTeams()
ui.addTextArea(1, "", nil, 199, 69, 400, 260, 0x5A7A8B, 0x5A7A8B, 1, true)
ui.addTextArea(2, "", nil, 201, 71, 400, 260, 0x0E1417, 0x0E1417, 1, true)
ui.addTextArea(3, "", nil, 200, 70, 400, 260, 0x324650, 0x324650, 1, true)
ui.addTextArea(4, "", nil, 209, 79, 142, 22, 0x324650, 0x5A7A8B, 1, true)
ui.addTextArea(5, "<p align='center'><V>Team 1", nil, 210, 80, 140, 20, 0x324650, 0x324650, 1, true)
ui.addTextArea(6, "", nil, 449, 79, 142, 22, 0x324650, 0x5A7A8B, 1, true)
ui.addTextArea(7, "<p align='center'><V>Team 2", nil, 450, 80, 140, 20, 0x324650, 0x324650, 1, true)
ui.addTextArea(8, "<p align='center'><font color='#5A7A8B'>|</font>", nil, 210, 102, 140, 200, 0, 0, 0, true)
ui.addTextArea(9, "<p align='center'><font color='#5A7A8B'>|</font>", nil, 450, 102, 140, 200, 0, 0, 0, true)
ui.addTextArea(10, "", nil, 209, 120, 140, 200, 0x5A7A8B, 0x5A7A8B, 1, true)
ui.addTextArea(11, "<p align='center'><font color='#"..colors[1].."'>"..table.concat(teams[1], "\n"), nil, 210, 121, 138, 198, 0x324650, 0x324650, 1, true)
ui.addTextArea(12, "", nil, 451, 120, 140, 200, 0x5A7A8B, 0x5A7A8B, 1, true)
ui.addTextArea(13, "<p align='center'><font color='#"..colors[2].."'>"..table.concat(teams[2], "\n"), nil, 452, 121, 138, 198, 0x324650, 0x324650, 1, true)
ui.addTextArea(14, "<p align='center'><font color='#5A7A8B'>____ ____</font>", nil, 330, 200, 140, 200, 0, 0, 0, true)
ui.addTextArea(15, "", nil, 380, 202, 40, 20, 0x5A7A8B, 0x5A7A8B, 1, true)
ui.addTextArea(16, "<p align='center'><V>VS", nil, 381, 203, 38, 18, 0x324650, 0x324650, 1, true)
ui.addTextArea(16, "<p align='center'><V><a href='event:iniciarJogo'>GO", ADMINISTRADOR, 381, 203, 38, 18, 0x324650, 0x324650, 1, true)
end

function eventTextAreaCallback(id, player, callback)
if callback == 'iniciarJogo' then
if #teams[2] > 0 and #teams[1] > 0 then
gameRunning = true
for i = 1, 16 do
ui.removeTextArea(i)
end
defaultEffect(9, {9}, 400, 212, 80)
newMap()
end
end
end

function string.split(s, pattern, n)
local st = {}
for sb in string.gmatch(s, "[^"..pattern.."]+") do
if not n or n > -1 then
table.insert(st,sb)
else
st[#st] = st[#st]..pattern..sb
end
n = n and n-1 or false
end
return st
end

function table.contains(tableT, element)
for _, value in pairs(tableT) do
if value == element then
return true
end
end
return false
end

defaultEffect=function(id,p,x,y,rand) -- thanks for the function santah
local minDist = 1
local outerBorder = 20
local maxDist = 30
local totalParticles = rand and 40 or (id == -1 and 35 or 75)
for i = 1, totalParticles do
if rand then
id = p[math.random(#p)]
end
local dist = math.min(math.random(minDist, maxDist), outerBorder)
local angle = math.random(0, 360)
local r = math.rad(angle)
local dx = math.cos(r)
local dy = math.sin(r)
local vx = dist * dx / 10
local vy = dist * dy / 10
local ax = -vx / dist / 15
local ay = (-vy / dist / 15) + 0.05
if id == -1 then
tfm.exec.displayParticle(9, x + dx, y + dy, vx, vy, ax, ay, nil)
tfm.exec.displayParticle(1, x + dx, y + dy, vx, vy, ax, ay, nil)
else
tfm.exec.displayParticle(id, x + dx, y + dy, vx, vy, ax, ay, nil)
end
end
end

displayTeams()

function eventPlayerDied()
local alive = 0
for k,v in pairs(tfm.get.room.playerList) do
if not v.isDead then
alive = alive+1
end
end
if alive < 2 then
tfm.exec.setGameTime(5)
end
end

Thefrogplayer a dit :
cria um script de barra de vida

quando o jogador tomar dano de algum objeto
ele toma dano e quando chegar a 0 o jogador morre

Ao chegar perto de um objeto o jogador sofrerá dano.
O sistema de colisão não é válido com todos os objetos.
Script
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
local players_hp = { }

local function is_colliding(x, y, x2, y2, range)
local distance = ((x - x2) ^ 2) + ((y - y2) ^ 2)
return math.sqrt(distance) <= range
end

local function display_player_hp(player)
ui.addTextArea(0, '<r>HP: ' .. players_hp[player] .. ' / 100', player, 10, 20, nil, nil, 0, 0)
end

function eventNewPlayer(player)
if (not players_hp[player]) then
players_hp[player] = 100
end

display_player_hp(player)
end

table.foreach(tfm.get.room.playerList, eventNewPlayer)

function eventNewGame()
for player in next, tfm.get.room.playerList do
players_hp[player] = 100

display_player_hp(player)
end
end

function eventLoop()
for obj, prop in next, tfm.get.room.objectList do
for player, data in next, tfm.get.room.playerList do
if (not data.isDead) then
if (players_hp[player] > 0) then
if is_colliding(prop.x, prop.y, data.x, data.y, 50) then
players_hp[player] = (players_hp[player] - 1)

display_player_hp(player)
end
else
tfm.exec.killPlayer(player)
end
end
end
end
end

Dernière modification le 1572628140000
  • Forums
  • /
  • Transformice
  • /
  • Archives
  • /
  • Seção Editor de Mapas e Modules
  • /
  • [Lua] Peça scripts aqui!
« ‹ 109 / 133 › »
© Atelier801 2018

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

Version 1.27