×

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!
« ‹ 115 / 133 › »
[Lua] Peça scripts aqui!
Victorck6
« Citoyen »
1579102980000
    • Victorck6#6662
    • Profil
    • Derniers messages
    • Tribu
#2281
  0
Fly a dit :
Victorck6 a dit :
Um script de vivo ou morto, vivo a pessoa dança e morto a pessoa deita, e claro tem que ter o tempo x pra cada acão,

Tempo pra cada ação: x
admin que vai dizer vivo/morto: x
mapa da sala: x

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
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
--[[
Lista de administradores. Para adicionar um novo administrador use o formato -> ['Nick#tag'] = true

Exemplo: admin = { ['Tigrounette#0001'] = true }
]]
local admin = { ['Victorck6#6662'] = true }

local safe_players = { }

local round_is_released, game_current_emote_id, game_countdown_time

local game_default_countdown_time = 4 -- Tempo para um jogador poder executar uma ação (segundos)
local game_map = 0 -- Mapa do jogo (sem '@')

local function init()
for _, v in next, { 'AutoShaman', 'AutoNewGame', 'AutoTimeLeft' } do
tfm.exec['disable' .. v]()
end

ui.addTextArea(0, '', nil, 375, 350, 50, 50)

tfm.exec.newGame(game_map)
end

function eventNewGame()
round_is_released = false

tfm.exec.setGameTime(9e5)
end

function eventLoop(_, remaining)
if (remaining > 0) then
if (not round_is_released) then return end

game_countdown_time = (game_countdown_time - .5)
if (game_countdown_time == 0) then
for k in next, tfm.get.room.playerList do
if (not safe_players[k]) then
tfm.exec.killPlayer(k)
end
end

round_is_released = false
end

return ui.updateTextArea(0, "<p align='center'><font size='38'>" .. math.floor(game_countdown_time))
end

tfm.exec.newGame(game_map)
end

function eventEmotePlayed(player, id)
if (not round_is_released) then return end

if (game_current_emote_id == id) then
if (game_countdown_time > 0) then
safe_players[player] = true

return
end
end

tfm.exec.killPlayer(player)
end

function eventChatMessage(player, message)
if (not admin[player] or round_is_released) then return end

local commands = { ['vivo'] = 0, ['morto'] = 6 }
local id = commands[message]
if (not id) then
return
end

game_current_emote_id, game_countdown_time = id, game_default_countdown_time

round_is_released = true

safe_players = { }
end

function eventPlayerDied(player)
local a

for k, v in next, tfm.get.room.playerList do
if (not v.isDead) then
if (a) then
return
end
a = k
end
end

tfm.exec.giveCheese(a)
tfm.exec.playerVictory(a)
tfm.exec.setGameTime(4)
end

init()

Ele vai pra o mapa e de diferença só tem isso: https://prnt.sc/qo42er
Victorck6
« Citoyen »
1579108860000
    • Victorck6#6662
    • Profil
    • Derniers messages
    • Tribu
#2282
  0
Fly a dit :
Victorck6 a dit :
Um script de vivo ou morto, vivo a pessoa dança e morto a pessoa deita, e claro tem que ter o tempo x pra cada acão,

Tempo pra cada ação: x
admin que vai dizer vivo/morto: x
mapa da sala: x

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
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
--[[
Lista de administradores. Para adicionar um novo administrador use o formato -> ['Nick#tag'] = true

Exemplo: admin = { ['Tigrounette#0001'] = true }
]]
local admin = { ['Victorck6#6662'] = true }

local safe_players = { }

local round_is_released, game_current_emote_id, game_countdown_time

local game_default_countdown_time = 4 -- Tempo para um jogador poder executar uma ação (segundos)
local game_map = 0 -- Mapa do jogo (sem '@')

local function init()
for _, v in next, { 'AutoShaman', 'AutoNewGame', 'AutoTimeLeft' } do
tfm.exec['disable' .. v]()
end

ui.addTextArea(0, '', nil, 375, 350, 50, 50)

tfm.exec.newGame(game_map)
end

function eventNewGame()
round_is_released = false

tfm.exec.setGameTime(9e5)
end

function eventLoop(_, remaining)
if (remaining > 0) then
if (not round_is_released) then return end

game_countdown_time = (game_countdown_time - .5)
if (game_countdown_time == 0) then
for k in next, tfm.get.room.playerList do
if (not safe_players[k]) then
tfm.exec.killPlayer(k)
end
end

round_is_released = false
end

return ui.updateTextArea(0, "<p align='center'><font size='38'>" .. math.floor(game_countdown_time))
end

tfm.exec.newGame(game_map)
end

function eventEmotePlayed(player, id)
if (not round_is_released) then return end

if (game_current_emote_id == id) then
if (game_countdown_time > 0) then
safe_players[player] = true

return
end
end

tfm.exec.killPlayer(player)
end

function eventChatMessage(player, message)
if (not admin[player] or round_is_released) then return end

local commands = { ['vivo'] = 0, ['morto'] = 6 }
local id = commands[message]
if (not id) then
return
end

game_current_emote_id, game_countdown_time = id, game_default_countdown_time

round_is_released = true

safe_players = { }
end

function eventPlayerDied(player)
local a

for k, v in next, tfm.get.room.playerList do
if (not v.isDead) then
if (a) then
return
end
a = k
end
end

tfm.exec.giveCheese(a)
tfm.exec.playerVictory(a)
tfm.exec.setGameTime(4)
end

init()

Depois que inicio o script ele vai pra o mapa x, mas depois disso faz mais nada..
Fly
« Citoyen »
1579112520000
    • Fly#9225
    • Profil
    • Derniers messages
#2283
  0
Victorck6 a dit :
Fly a dit :
Victorck6 a dit :
Um script de vivo ou morto, vivo a pessoa dança e morto a pessoa deita, e claro tem que ter o tempo x pra cada acão,

Tempo pra cada ação: x
admin que vai dizer vivo/morto: x
mapa da sala: x

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
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
--[[
Lista de administradores. Para adicionar um novo administrador use o formato -> ['Nick#tag'] = true

Exemplo: admin = { ['Tigrounette#0001'] = true }
]]
local admin = { ['Victorck6#6662'] = true }

local safe_players = { }

local round_is_released, game_current_emote_id, game_countdown_time

local game_default_countdown_time = 4 -- Tempo para um jogador poder executar uma ação (segundos)
local game_map = 0 -- Mapa do jogo (sem '@')

local function init()
for _, v in next, { 'AutoShaman', 'AutoNewGame', 'AutoTimeLeft' } do
tfm.exec['disable' .. v]()
end

ui.addTextArea(0, '', nil, 375, 350, 50, 50)

tfm.exec.newGame(game_map)
end

function eventNewGame()
round_is_released = false

tfm.exec.setGameTime(9e5)
end

function eventLoop(_, remaining)
if (remaining > 0) then
if (not round_is_released) then return end

game_countdown_time = (game_countdown_time - .5)
if (game_countdown_time == 0) then
for k in next, tfm.get.room.playerList do
if (not safe_players[k]) then
tfm.exec.killPlayer(k)
end
end

round_is_released = false
end

return ui.updateTextArea(0, "<p align='center'><font size='38'>" .. math.floor(game_countdown_time))
end

tfm.exec.newGame(game_map)
end

function eventEmotePlayed(player, id)
if (not round_is_released) then return end

if (game_current_emote_id == id) then
if (game_countdown_time > 0) then
safe_players[player] = true

return
end
end

tfm.exec.killPlayer(player)
end

function eventChatMessage(player, message)
if (not admin[player] or round_is_released) then return end

local commands = { ['vivo'] = 0, ['morto'] = 6 }
local id = commands[message]
if (not id) then
return
end

game_current_emote_id, game_countdown_time = id, game_default_countdown_time

round_is_released = true

safe_players = { }
end

function eventPlayerDied(player)
local a

for k, v in next, tfm.get.room.playerList do
if (not v.isDead) then
if (a) then
return
end
a = k
end
end

tfm.exec.giveCheese(a)
tfm.exec.playerVictory(a)
tfm.exec.setGameTime(4)
end

init()

Depois que inicio o script ele vai pra o mapa x, mas depois disso faz mais nada..

O admin do script deve dizer vivo ou morto no chat
Victorck6
« Citoyen »
1579181040000
    • Victorck6#6662
    • Profil
    • Derniers messages
    • Tribu
#2284
  0
Fly a dit :
Victorck6 a dit :
Fly a dit :
Victorck6 a dit :
Um script de vivo ou morto, vivo a pessoa dança e morto a pessoa deita, e claro tem que ter o tempo x pra cada acão,

Tempo pra cada ação: x
admin que vai dizer vivo/morto: x
mapa da sala: x

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
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
--[[
Lista de administradores. Para adicionar um novo administrador use o formato -> ['Nick#tag'] = true

Exemplo: admin = { ['Tigrounette#0001'] = true }
]]
local admin = { ['Victorck6#6662'] = true }

local safe_players = { }

local round_is_released, game_current_emote_id, game_countdown_time

local game_default_countdown_time = 4 -- Tempo para um jogador poder executar uma ação (segundos)
local game_map = 0 -- Mapa do jogo (sem '@')

local function init()
for _, v in next, { 'AutoShaman', 'AutoNewGame', 'AutoTimeLeft' } do
tfm.exec['disable' .. v]()
end

ui.addTextArea(0, '', nil, 375, 350, 50, 50)

tfm.exec.newGame(game_map)
end

function eventNewGame()
round_is_released = false

tfm.exec.setGameTime(9e5)
end

function eventLoop(_, remaining)
if (remaining > 0) then
if (not round_is_released) then return end

game_countdown_time = (game_countdown_time - .5)
if (game_countdown_time == 0) then
for k in next, tfm.get.room.playerList do
if (not safe_players[k]) then
tfm.exec.killPlayer(k)
end
end

round_is_released = false
end

return ui.updateTextArea(0, "<p align='center'><font size='38'>" .. math.floor(game_countdown_time))
end

tfm.exec.newGame(game_map)
end

function eventEmotePlayed(player, id)
if (not round_is_released) then return end

if (game_current_emote_id == id) then
if (game_countdown_time > 0) then
safe_players[player] = true

return
end
end

tfm.exec.killPlayer(player)
end

function eventChatMessage(player, message)
if (not admin[player] or round_is_released) then return end

local commands = { ['vivo'] = 0, ['morto'] = 6 }
local id = commands[message]
if (not id) then
return
end

game_current_emote_id, game_countdown_time = id, game_default_countdown_time

round_is_released = true

safe_players = { }
end

function eventPlayerDied(player)
local a

for k, v in next, tfm.get.room.playerList do
if (not v.isDead) then
if (a) then
return
end
a = k
end
end

tfm.exec.giveCheese(a)
tfm.exec.playerVictory(a)
tfm.exec.setGameTime(4)
end

init()

Depois que inicio o script ele vai pra o mapa x, mas depois disso faz mais nada..

O admin do script deve dizer vivo ou morto no chat

Pegou, consigo alterar o mapa e o tempo, tem como trocar pra que isso não afete o rato do admin ? mas que afete aos outros ?

Mas o script pegou, obrigado mesmo.
Victorck6
« Citoyen »
1579181220000
    • Victorck6#6662
    • Profil
    • Derniers messages
    • Tribu
#2285
  0
E quando eu digo: morto/vivo e a pessoa se mover antes do fim do tempo ela morre... não sei se é erro mas a pessoa devia morrer só depois do fim do tempo mesmo, mesmo que faça outra reação, não sei se entendeu.
Jp_darkuss
« Citoyen »
1579299540000
    • Jp_darkuss#4806
    • Profil
    • Derniers messages
#2286
  0
Annye a dit :
Jp_darkuss a dit :
Annye a dit :
Queria um script na qual eu possa me teleportar aonde eu clico, e outras pessoas também, mas, só quem eu escolher. (Também seria bom se pudesse teleportar várias de uma vez)

Podia ser tipo:

!tp nome#0000 (Ai eu clico no local, e ela se teleporta pra lá)

!tp all (Para teleportar todas de uma vez)

Tipo como é em utility, mas, sem ser utility rs

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
51
local adm= {""}
local pos= {0, 0} --x, y
local can= {}
local dontRepeatCommand= 0
system.bindMouse(adm[1], true)
ui.addTextArea(0, ".", nil, 0, 0, 5, 5, 0xFF6666, 0xFF6666, 1, false)
eventChatCommand= function(player, c)
cmd= {}
leave= false
for i in ipairs(can) do
if (player== can[i]) then
leave= true
end
end
for i in string.gmatch(c, "%S+") do
table.insert(cmd, i)
end
if (cmd[1]=="can" and player== adm[1]) then
if (cmd[3]=="true") then
system.bindMouse(cmd[2], true)
table.insert(can, cmd[2])
print("[Aviso] O jogador "..cmd[2].." agora é capaz de usar o comando "..string.format("%q", "!tp playerName")..".")
else
system.bindMouse(adm[1], false)
for i in ipairs(can) do
if (cmd[2]== can[i]) then
table.remove(can, i)
end
end
print("[Aviso] O jogador "..cmd[2].." não poderá mais usar o comando "..string.format("%q", "!tp playerName")..".")
end
dontRepeatCommand= 1
elseif (c=="tp all" and player== adm[1] and dontRepeatCommand== 0) then
for i in pairs(tfm.get.room.playerList) do
tfm.exec.movePlayer(i, pos[1], pos[2], false, 0, 0, false)
end
dontRepeatCommand= 1
elseif (cmd[1]=="tp" and player== adm[1] and dontRepeatCommand== 0) then
tfm.exec.movePlayer(cmd[2], pos[1], pos[2], false, 0, 0, false)
dontRepeatCommand= 1
elseif (leave== true and cmd[1]=="tp" and dontRepeatCommand== 0) then
tfm.exec.movePlayer(cmd[2], pos[1], pos[2], false, 0, 0, false)
dontRepeatCommand= 1
end
dontRepeatCommand= 0
end
eventMouse= function(player, x, y)
pos[1]= x
pos[2]= y
ui.addTextArea(0, ".", nil, x, y, 5, 5, 0xFF6666, 0xFF6666, 1, false)
end


Comandos:
  • !tp name#0000: teleporta name#0000 para a posição selecionada (mouse).
  • !tp all: teleporta todos para a posição selecionada (mouse).
  • !can name#0000 boolean: libera ou não o uso de comandos para name#0000, se boolean for true, vai liberar, se for false vai bloquea-lo. Este se liberado só poderá usar o comando !tp name#0000 e ter acesso a função do mouse.

    Coloque seu nome em local adm= {""} entre as aspas e com a #.

  • Muito obrigada mesmo ^^

    Este script tinha um erro muito grave, por favor utilize este:

    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
    51
    52
    local adm= {""}
    local pos= {0, 0} --x, y
    local can= {}
    local dontRepeatCommand= 0
    system.bindMouse(adm[1], true)
    ui.addTextArea(0, ".", nil, 0, 0, 5, 5, 0xFF6666, 0xFF6666, 1, false)
    eventChatCommand= function(player, c)
    cmd= {}
    leave= false
    for i in ipairs(can) do
    if (player== can[i]) then
    leave= true
    end
    end
    for i in string.gmatch(c, "%S+") do
    table.insert(cmd, i)
    end
    if (cmd[1]=="can" and player== adm[1]) then
    if (cmd[3]=="true") then
    system.bindMouse(cmd[2], true)
    table.insert(can, cmd[2])
    print("[Aviso] O jogador "..cmd[2].." agora é capaz de usar o comando "..string.format("%q", "!tp playerName")..".")
    else
    system.bindMouse(cmd[2], false)
    for i in ipairs(can) do
    if (cmd[2]== can[i]) then
    table.remove(can, i)
    end
    end
    print("[Aviso] O jogador "..cmd[2].." não poderá mais usar o comando "..string.format("%q", "!tp playerName")..".")
    end
    dontRepeatCommand= 1
    elseif (c=="tp all" and player== adm[1] and dontRepeatCommand== 0) then
    for i in pairs(tfm.get.room.playerList) do
    tfm.exec.movePlayer(i, pos[1], pos[2], false, 0, 0, false)
    end
    dontRepeatCommand= 1
    elseif (cmd[1]=="tp" and player== adm[1] and dontRepeatCommand== 0) then
    tfm.exec.movePlayer(cmd[2], pos[1], pos[2], false, 0, 0, false)
    dontRepeatCommand= 1
    elseif (leave== true and cmd[1]=="tp" and dontRepeatCommand== 0) then
    tfm.exec.movePlayer(cmd[2], pos[1], pos[2], false, 0, 0, false)
    dontRepeatCommand= 1
    end
    dontRepeatCommand= 0
    end
    eventMouse= function(player, x, y)
    pos[1]= x
    pos[2]= y
    ui.addTextArea(0, ".", nil, x, y, 5, 5, 0xFF6666, 0xFF6666, 1, false)
    end
    system.disableChatCommandDisplay()

    Mesmas funções...
    Jp_darkuss
    « Citoyen »
    1579299780000
      • Jp_darkuss#4806
      • Profil
      • Derniers messages
    #2287
      0
    Jp_darkuss a dit :
    Preciso de ajuda com umas funções. Eu comecei programar em Javascript, e conheço dois comandos MUITO IMPORTANTES, ou falar sobre eles.

    Code Javascript

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    setTimeout(
    function() {
    //bloco;
    }, int
    ); //primeiro comando

    setInterval(
    function() {
    //bloco;
    }, int
    ) //segundo comando

    O primeiro comando (setTimeout()) consegue rodar sozinho sem afetar o resto do programa, assim como o segundo (setInterval()). O setTimeout() executa os comandos no bloco depois de se passar um certo tempo, expresso em milisegundos (int), ou seja, atrasa a execução. O setInterval() consegue fazer um loop, executando o bloco a cada (int) milisegundos. Minha pergunta é: existe alguma forma em Lua de produzir exatamente ou aproximadamente as ações das funções Javascript acima?

    Preciso de uma resposta à essas perguntas PFV!!
    Bolodefchoco
    « Sénateur »
    1579315800000
      • Bolodefchoco#0095
      • Profil
      • Derniers messages
      • Tribu
    #2288
      2
    Jp_darkuss a dit :
    Jp_darkuss a dit :
    Preciso de ajuda com umas funções. Eu comecei programar em Javascript, e conheço dois comandos MUITO IMPORTANTES, ou falar sobre eles.

    Code Javascript

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    setTimeout(
    function() {
    //bloco;
    }, int
    ); //primeiro comando

    setInterval(
    function() {
    //bloco;
    }, int
    ) //segundo comando

    O primeiro comando (setTimeout()) consegue rodar sozinho sem afetar o resto do programa, assim como o segundo (setInterval()). O setTimeout() executa os comandos no bloco depois de se passar um certo tempo, expresso em milisegundos (int), ou seja, atrasa a execução. O setInterval() consegue fazer um loop, executando o bloco a cada (int) milisegundos. Minha pergunta é: existe alguma forma em Lua de produzir exatamente ou aproximadamente as ações das funções Javascript acima?

    Preciso de uma resposta à essas perguntas PFV!!

    Você pode fazê-los sozinho, são bem simples.

    Para o meu evento, usei essa classe simples de timers:
    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
    local timer
    do
    local table_unpack = table.unpack

    timer = {
    _timers = {
    _count = 0
    }
    }

    timer.start = function(callback, ms, times, ...)
    local t = timer._timers
    t._count = t._count + 1

    t[t._count] = {
    id = t._count,
    callback = callback,
    args = { ... },
    defaultMilliseconds = ms,
    milliseconds = ms,
    times = times
    }
    t[t._count].args[#t[t._count].args + 1] = t[t._count]

    return t._count
    end

    timer.delete = function(id)
    timer._timers[id] = nil
    end

    timer.loop = function()
    local t
    for i = 1, timer._timers._count do
    t = timer._timers[i]
    if t then
    t.milliseconds = t.milliseconds - 500
    if t.milliseconds <= 0 then
    t.milliseconds = t.defaultMilliseconds
    t.times = t.times - 1

    t.callback(table_unpack(t.args))

    if t.times == 0 then
    timer.delete(i)
    end
    end
    end
    end
    end
    end

    eventLoop = function()
    timer.loop()
    end


    Para criar as duas funções, você pode usar:
    Code Lua

    1
    2
    3
    4
    5
    6
    7
    local setTimeout = function(callback, time)
    return timer.start(callback, time, 1)
    end

    local setInterval = function(callback, time)
    return timer.start(callback, time, 0)
    end

    Para interromper um interval, você pode definir self.times para 0. O timer sempre é passado como último argumento da callback. Exemplo:

    Code Lua

    1
    2
    3
    4
    5
    6
    7
    local x = 0
    setInterval(function(t)
    x = x + 1
    if x == 1 then
    t.times = 0
    end
    end, 4000)

    Também é possível com timer.delete(t.id), mas a outra opção é melhor

    Dernière modification le 1579316040000
    Nathallyms
    « Citoyen »
    1579371780000
      • Nathallyms#0000
      • Profil
      • Derniers messages
      • Tribu
    #2289
      0
    Oi Oi. Queria um script onde, eu digito !tp, e todos os jogadores da sala, se teleportam pra onde eu quiser, igual o utility
    Queria um outro, onde eu digito !qjs, e todos os jogadores, incluindo eu, ganhamos qjs, e pra tirar o qj, digitamos !off, ou algo do tipo.
    Queria um script de o chão é lava tbm. Pff, ficarei agradecida se fizessem. Eu preciso pros eventos da minha tribo.
    Jp_darkuss
    « Citoyen »
    1579388340000
      • Jp_darkuss#4806
      • Profil
      • Derniers messages
    #2290
      0
    Bolodefchoco a dit :
    Jp_darkuss a dit :
    Jp_darkuss a dit :
    Preciso de ajuda com umas funções. Eu comecei programar em Javascript, e conheço dois comandos MUITO IMPORTANTES, ou falar sobre eles.

    Code Javascript

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    setTimeout(
    function() {
    //bloco;
    }, int
    ); //primeiro comando

    setInterval(
    function() {
    //bloco;
    }, int
    ) //segundo comando

    O primeiro comando (setTimeout()) consegue rodar sozinho sem afetar o resto do programa, assim como o segundo (setInterval()). O setTimeout() executa os comandos no bloco depois de se passar um certo tempo, expresso em milisegundos (int), ou seja, atrasa a execução. O setInterval() consegue fazer um loop, executando o bloco a cada (int) milisegundos. Minha pergunta é: existe alguma forma em Lua de produzir exatamente ou aproximadamente as ações das funções Javascript acima?

    Preciso de uma resposta à essas perguntas PFV!!

    Você pode fazê-los sozinho, são bem simples.

    Para o meu evento, usei essa classe simples de timers:
    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
    local timer
    do
    local table_unpack = table.unpack

    timer = {
    _timers = {
    _count = 0
    }
    }

    timer.start = function(callback, ms, times, ...)
    local t = timer._timers
    t._count = t._count + 1

    t[t._count] = {
    id = t._count,
    callback = callback,
    args = { ... },
    defaultMilliseconds = ms,
    milliseconds = ms,
    times = times
    }
    t[t._count].args[#t[t._count].args + 1] = t[t._count]

    return t._count
    end

    timer.delete = function(id)
    timer._timers[id] = nil
    end

    timer.loop = function()
    local t
    for i = 1, timer._timers._count do
    t = timer._timers[i]
    if t then
    t.milliseconds = t.milliseconds - 500
    if t.milliseconds <= 0 then
    t.milliseconds = t.defaultMilliseconds
    t.times = t.times - 1

    t.callback(table_unpack(t.args))

    if t.times == 0 then
    timer.delete(i)
    end
    end
    end
    end
    end
    end

    eventLoop = function()
    timer.loop()
    end


    Para criar as duas funções, você pode usar:
    Code Lua

    1
    2
    3
    4
    5
    6
    7
    local setTimeout = function(callback, time)
    return timer.start(callback, time, 1)
    end

    local setInterval = function(callback, time)
    return timer.start(callback, time, 0)
    end

    Para interromper um interval, você pode definir self.times para 0. O timer sempre é passado como último argumento da callback. Exemplo:

    Code Lua

    1
    2
    3
    4
    5
    6
    7
    local x = 0
    setInterval(function(t)
    x = x + 1
    if x == 1 then
    t.times = 0
    end
    end, 4000)

    Também é possível com timer.delete(t.id), mas a outra opção é melhor

    Obg, vou praticar.
    Jp_darkuss
    « Citoyen »
    1579396920000
      • Jp_darkuss#4806
      • Profil
      • Derniers messages
    #2291
      0
    Nathallyms a dit :
    Oi Oi. Queria um script onde, eu digito !tp, e todos os jogadores da sala, se teleportam pra onde eu quiser, igual o utility
    Queria um outro, onde eu digito !qjs, e todos os jogadores, incluindo eu, ganhamos qjs, e pra tirar o qj, digitamos !off, ou algo do tipo.
    Queria um script de o chão é lava tbm. Pff, ficarei agradecida se fizessem. Eu preciso pros eventos da minha tribo.

    Script de tp

    Jp_darkuss a dit :
    Annye a dit :
    Queria um script na qual eu possa me teleportar aonde eu clico, e outras pessoas também, mas, só quem eu escolher. (Também seria bom se pudesse teleportar várias de uma vez)

    Podia ser tipo:

    !tp nome#0000 (Ai eu clico no local, e ela se teleporta pra lá)

    !tp all (Para teleportar todas de uma vez)

    Tipo como é em utility, mas, sem ser utility rs

    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
    51
    52
    local adm= {""}
    local pos= {0, 0} --x, y
    local can= {}
    local dontRepeatCommand= 0
    system.bindMouse(adm[1], true)
    ui.addTextArea(0, ".", nil, 0, 0, 5, 5, 0xFF6666, 0xFF6666, 1, false)
    eventChatCommand= function(player, c)
    cmd= {}
    leave= false
    for i in ipairs(can) do
    if (player== can[i]) then
    leave= true
    end
    end
    for i in string.gmatch(c, "%S+") do
    table.insert(cmd, i)
    end
    if (cmd[1]=="can" and player== adm[1]) then
    if (cmd[3]=="true") then
    system.bindMouse(cmd[2], true)
    table.insert(can, cmd[2])
    print("[Aviso] O jogador "..cmd[2].." agora é capaz de usar o comando "..string.format("%q", "!tp playerName")..".")
    else
    system.bindMouse(cmd[2], false)
    for i in ipairs(can) do
    if (cmd[2]== can[i]) then
    table.remove(can, i)
    end
    end
    print("[Aviso] O jogador "..cmd[2].." não poderá mais usar o comando "..string.format("%q", "!tp playerName")..".")
    end
    dontRepeatCommand= 1
    elseif (c=="tp all" and player== adm[1] and dontRepeatCommand== 0) then
    for i in pairs(tfm.get.room.playerList) do
    tfm.exec.movePlayer(i, pos[1], pos[2], false, 0, 0, false)
    end
    dontRepeatCommand= 1
    elseif (cmd[1]=="tp" and player== adm[1] and dontRepeatCommand== 0) then
    tfm.exec.movePlayer(cmd[2], pos[1], pos[2], false, 0, 0, false)
    dontRepeatCommand= 1
    elseif (leave== true and cmd[1]=="tp" and dontRepeatCommand== 0) then
    tfm.exec.movePlayer(cmd[2], pos[1], pos[2], false, 0, 0, false)
    dontRepeatCommand= 1
    end
    dontRepeatCommand= 0
    end
    eventMouse= function(player, x, y)
    pos[1]= x
    pos[2]= y
    ui.addTextArea(0, ".", nil, x, y, 5, 5, 0xFF6666, 0xFF6666, 1, false)
    end
    system.disableChatCommandDisplay()


    Comandos:
  • !tp name#0000: teleporta name#0000 para a posição selecionada (mouse).
  • !tp all: teleporta todos para a posição selecionada (mouse).
  • !can name#0000 boolean: libera ou não o uso de comandos para name#0000, se boolean for true, vai liberar, se for false vai bloquea-lo. Este se liberado só poderá usar o comando !tp name#0000 e ter acesso a função do mouse.

    Coloque seu nome em local adm= {""} entre as aspas e com a #.



  • O chão é lava << link

    Script dos queijos:

    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
    local adm= {""}
    eventChatCommand= function(player, c)
    cmd= {}
    for i in string.gmatch(c, "%S+") do
    table.insert(cmd, i)
    end
    if (cmd[1]=="cheeseAll" and player== adm[1]) then
    if (cmd[2]=="true") then
    for pos, i in next, tfm.get.room.playerList do
    tfm.exec.giveCheese(pos)
    end
    elseif (cmd[2]=="false") then
    for pos, i in next, tfm.get.room.playerList do
    tfm.exec.removeCheese(pos)
    end
    end
    elseif (cmd[1]=="cheese" and player== adm[1]) then
    if (cmd[3]=="true") then
    tfm.exec.giveCheese(cmd[2])
    elseif (cmd[3]=="false") then
    tfm.exec.removeCheese(cmd[2])
    end
    end
    end
    system.disableChatCommandDisplay()


    Comandos:

  • !cheeseAll boolean: dar ou retira o queijo de todos; se boolean for igual a true, dará um queijo. Caso seja false, o retirará.
  • !cheese name#0000 boolean: dar ou retira o queijo de name#0000; se boolean for igual a true, dará um queijo. Caso seja false, o retirará.

    Coloque seu nome com a # em local adm= {""} entre as aspas.

  • Dernière modification le 1579397220000
    Sasukegamer
    « Citoyen »
    1579422780000
      • Sasukegamer#5725
      • Profil
      • Derniers messages
    #2292
      0
    ANT LAG
    Aku
    « Citoyen »
    1579449240000
      • Aku#9575
      • Profil
      • Derniers messages
      • Tribu
    #2293
      0
    Queria um script digitar !r a pessoa reviver
    Fly
    « Citoyen »
    1579457040000
      • Fly#9225
      • Profil
      • Derniers messages
    #2294
      1
    Aku a dit :
    Queria um script digitar !r a pessoa reviver

    Code Lua

    1
    2
    3
    4
    5
    function eventChatCommand(player, command)
    if (command == 'r') then
    tfm.exec.respawnPlayer(player)
    end
    end
    Aku
    « Citoyen »
    1579466520000
      • Aku#9575
      • Profil
      • Derniers messages
      • Tribu
    #2295
      0
    vlw Fly
    Amosca
    « Citoyen »
    1579821480000
      • Amosca#0000
      • Profil
      • Derniers messages
    #2296
      0
    um scrip em q a pessoa escolhida podera escalar e as outras nao
    Fly
    « Citoyen »
    1579914060000
      • Fly#9225
      • Profil
      • Derniers messages
    #2297
      0
    Amosca a dit :
    um scrip em q a pessoa escolhida podera escalar e as outras nao

    Code Lua

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    local can_climb = 'Nick#0000' -- Jogador que poderá escalar

    function eventNewPlayer(player)
    if player ~= can_climb then
    system.bindKeyboard(player, 1, true)
    end
    end
    table.foreach(tfm.get.room.playerList, eventNewPlayer)

    function eventKeyboard(player)
    tfm.exec.movePlayer(player, 0, 0, false, 0, 15)
    end

    Os jogadores são impulsionados para baixo ao pular, exceto o jogador escolhido
    Victorck6
    « Citoyen »
    1579976040000
      • Victorck6#6662
      • Profil
      • Derniers messages
      • Tribu
    #2298
      0
    Fly a dit :
    Amosca a dit :
    um scrip em q a pessoa escolhida podera escalar e as outras nao

    Code Lua

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    local can_climb = 'Nick#0000' -- Jogador que poderá escalar

    function eventNewPlayer(player)
    if player ~= can_climb then
    system.bindKeyboard(player, 1, true)
    end
    end
    table.foreach(tfm.get.room.playerList, eventNewPlayer)

    function eventKeyboard(player)
    tfm.exec.movePlayer(player, 0, 0, false, 0, 15)
    end

    Os jogadores são impulsionados para baixo ao pular, exceto o jogador escolhido

    não pegou
    Favelada
    « Consul »
    1580064360000
      • Favelada#6672
      • Profil
      • Derniers messages
      • Tribu
    #2299
      0
    queria um script babadeiro pra colocar itens_diversos [tipo ovelha] no mapa

    Dernière modification le 1580064420000
    Esthergames
    « Citoyen »
    1580085480000
      • Esthergames#0147
      • Profil
      • Derniers messages
    #2300
      0
    Um script que tal determinado rato dê /mort ''morra'' à cada início de partida, sem precisar digitar nada...Obrigada!

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

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

    Version 1.27