×

Language

Close
Atelier 801
  • Forums
  • Dev Tracker
  • Log in
    • 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
  • Language
  • Forums
  • /
  • Transformice
  • /
  • Modules
  • /
  • [Script] Joint Translator
[Script] Joint Translator
Bolodefchoco
« Senator »
1514767440000
    • Bolodefchoco#0095
    • Profile
    • Last posts
    • Tribe
#1
  6

JOINT TRANSLATOR
Script aqui


Este script permite que códigos XML sejam traduzidos para joints inseridas com lua, atribuindo-lhe a capacidade de definir a posição do desenho, além de sua camada (background ou foreground). Também poderá inserir funções a serem executadas ao tocar no desenho.

O script requer 4 funções básicas que não devem ser substituídas:


  • string.split -> Fragmenta uma string numa tabela (regex)
  • math.intersects -> Verifica se um ponto (x, y) se encontra entre os pontos (x1, y1) e (x2, y2)
  • math.minmax -> Retorna os dois valores inseridos em ordem decrescente
  • table.copy -> Copia simploriamente uma tabela e retorna a cópia


Há 4 funções no script:

• translateJoint(id, xml, x, y, foreground, f)
Desenha as joints
* id (int) -> ID do desenho. Este valor pode não ser inserido ao chamar a função, ID terá o valor seguinte do ID anterior. [0, 1, 2, ...]
* xml (string) -> O XML ou ID do desenho. Existem desenhos já prontos no script, e são eles: "bomb", "cannon", "cheese", "chicken", "ghost", "hole", "mouse", "portal_blue", "portal_orange", "troll"
* x (int) -> Posição horizontal do desenho
* y (int) -> Posição vertical do desenho
* foreground (boolean) -> Boleano para decidir a camada. True para Primeiro Plano, False para Plano de Fundo, Nil para automático. Pode ser uma função e agirá como o parâmetro abaixo.
* f (function) -> Uma função(playerName, playerData) que se executa quando um jogador tocar o desenho

Retorna:
#1 (Int) ID
#2 (Int) Número de linhas

Lua code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
eventNewGame = function()
-- Obrigatório
tfm.exec.addPhysicObject(0, 0, 0, { type = 14, miceCollision = false, groundCollision = false })

-- Desenha um queijo que atribui queijo a quem tocar.
translateJoint(0, "cheese", 300, 330, function(playerName)
tfm.exec.giveCheese(playerName)
end)

-- Desenha uma toca e atribui vitória a quem tocar.
translateJoint("hole", 210, 320, true, function(player)
tfm.exec.playerVictory(player)
end)

-- Desenha um canhão que não faz nada.
-- Ele irá apagar o desenho anterior, "hole", porque "hole" também tem ID 1
-- (mesmo que não tenha sido definido na chamada).
translateJoint(1, "cannon", 400, 200)

-- Desenha um "Oi"
local xml = '<C><P/><Z><S /><D /><O /><L><JD P1="184,76"P2="158,118"c="ffffff,2"/><JD P1="156,120"P2="205,160"c="ffffff,2"/><JD P1="205,160"P2="237,128"c="ffffff,2"/><JD P1="237,128"P2="184,77"c="ffffff,2"/><JD P1="260,162"P2="261,123"c="ffffff,2"/><JD P1="258,108"P2="261,104"c="ffffff,2"/><JD P1="261,103"P2="261,98"c="ffffff,2"/><JD P1="261,97"P2="254,96"c="ffffff,2"/><JD P1="252,96"P2="249,98"c="ffffff,2"/><JD P1="249,99"P2="249,102"c="ffffff,2"/><JD P1="251,104"P2="253,106"c="ffffff,2"/><JD P1="255,106"P2="257,107"c="ffffff,2"/><L /></L></Z></C>'
translateJoint(10, xml, 100, 200, true)
end

• removeJoint(id)
Remove um desenho
* id (int) -> ID do desenho a ser removido

Retorna:
#1 (Boolean) Se foi removido ou não

Lua code

1
2
3
4
5
6
7
8
9
eventNewGame = function()
-- Obrigatório
tfm.exec.addPhysicObject(0, 0, 0, { type = 14, miceCollision = false, groundCollision = false })

-- Desenha um queijo que desaparece quando alguém tocá-lo.
translateJoint(0, "cheese", 200, 330, function()
removeJoint(0)
end)
end

• executeJoint
Executa uma vez as funções de todos os desenhos (apenas a verificação)
Lua code

1
2
3
eventLoop = function()
executeJoint()
end

• setFunction(id, f)
Redefine ou remove a função de um desenho
* id (int) -> ID do desenho
* f (function) -> Nova função. Caso nil, a função do desenho será removida

Retorna:
#1 (Boolean) Se foi redefinida ou não

Lua code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
eventNewGame = function()
-- Obrigatório
tfm.exec.addPhysicObject(0, 0, 0, { type = 14, miceCollision = false, groundCollision = false })

-- Desenha um queijo que dá queijo e depois passa a funcionar como toca
translateJoint(0, "cheese", 300, 330, function(playerName)
tfm.exec.giveCheese(playerName)
setFunction(0, function(playerName)
tfm.exec.playerVictory(playerName)
end)
end)

-- Desenha uma toca que dá vitória e depois passa a funcionar como queijo
translateJoint(1, "hole", 200, 330, function(playerName)
tfm.exec.playerVictory(playerName)
setFunction(1, function(playerName)
tfm.exec.giveCheese(playerName)
end)
end)
end

Lua code

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
-- Um código de exemplo
eventNewGame = function()
-- Obrigatório
tfm.exec.addPhysicObject(0, 0, 0, { type = 14, miceCollision = false, groundCollision = false })

translateJoint(0, 'cheese', 500, 310, function(n)
tfm.exec.giveCheese(n)
end)

translateJoint(1, 'hole', 650, 310, true, function(n)
tfm.exec.playerVictory(n)
end)

local sha_id
sha_id = translateJoint('cannon', 200, 340, function(n)
tfm.exec.setShaman(n)
setFunction(sha_id)
end)

translateJoint('<C><P/><Z><S /><D /><O /><L><JPL P1="166,97"P3="166,98"P4="167,96"P2="168,94"c="7fdbeb,2"/><JPL P1="168,94"P3="169,92"P4="171,89"P2="172,87"c="7fdbeb,2"/><JPL P1="172,87"P3="175,84"P4="177,81"P2="180,78"c="7fdbeb,2"/><JPL P1="180,78"P3="183,76"P4="186,74"P2="190,72"c="7fdbeb,2"/><JPL P1="190,72"P3="193,71"P4="197,71"P2="201,71"c="7fdbeb,2"/><JPL P1="201,71"P3="205,73"P4="209,75"P2="214,79"c="7fdbeb,2"/><JPL P1="214,79"P3="218,84"P4="223,90"P2="218,84"c="7fdbeb,2"/><JD P1="223,91"P2="166,97"c="7fdbeb,2"/><JPL P1="167,99"P3="167,100"P4="167,100"P2="168,101"c="7fdbeb,2"/><JPL P1="168,101"P3="168,102"P4="169,104"P2="170,106"c="7fdbeb,2"/><JPL P1="170,106"P3="171,108"P4="172,110"P2="174,112"c="7fdbeb,2"/><JPL P1="174,112"P3="176,114"P4="179,115"P2="182,117"c="7fdbeb,2"/><JPL P1="182,117"P3="185,118"P4="189,119"P2="194,120"c="7fdbeb,2"/><JPL P1="194,120"P3="198,120"P4="204,119"P2="210,118"c="7fdbeb,2"/><JPL P1="210,118"P3="217,116"P4="224,114"P2="217,116"c="7fdbeb,2"/><JD P1="206,55"P2="217,42"c="7fdbeb,2"/><JD P1="274,111"P2="263,61"c="7fdbeb,2"/><JD P1="263,61"P2="301,96"c="7fdbeb,2"/><JD P1="301,96"P2="294,46"c="7fdbeb,2"/><JPL P1="326,69"P3="326,70"P4="326,68"P2="327,66"c="7fdbeb,2"/><JPL P1="327,66"P3="328,64"P4="329,62"P2="330,60"c="7fdbeb,2"/><JPL P1="330,60"P3="331,58"P4="333,55"P2="335,53"c="7fdbeb,2"/><JPL P1="335,53"P3="337,51"P4="339,49"P2="341,48"c="7fdbeb,2"/><JPL P1="341,48"P3="344,47"P4="347,47"P2="350,47"c="7fdbeb,2"/><JPL P1="350,47"P3="353,49"P4="357,51"P2="361,55"c="7fdbeb,2"/><JPL P1="361,55"P3="365,59"P4="369,65"P2="365,59"c="7fdbeb,2"/><JPL P1="369,65"P3="369,66"P4="369,67"P2="368,68"c="7fdbeb,2"/><JPL P1="368,68"P3="367,70"P4="367,73"P2="366,76"c="7fdbeb,2"/><JPL P1="366,76"P3="364,79"P4="363,82"P2="361,84"c="7fdbeb,2"/><JPL P1="361,84"P3="359,87"P4="357,89"P2="354,90"c="7fdbeb,2"/><JPL P1="354,90"P3="352,91"P4="349,91"P2="345,90"c="7fdbeb,2"/><JPL P1="345,90"P3="342,88"P4="338,85"P2="334,81"c="7fdbeb,2"/><JPL P1="334,81"P3="330,75"P4="325,68"P2="330,75"c="7fdbeb,2"/><JD P1="396,90"P2="385,46"c="7fdbeb,2"/><JPL P1="415,39"P3="411,42"P4="408,46"P2="406,49"c="7fdbeb,2"/><JPL P1="406,49"P3="405,51"P4="405,54"P2="405,56"c="7fdbeb,2"/><JPL P1="405,56"P3="405,58"P4="406,60"P2="407,61"c="7fdbeb,2"/><JPL P1="407,61"P3="409,63"P4="411,64"P2="413,65"c="7fdbeb,2"/><JPL P1="413,65"P3="415,66"P4="417,66"P2="419,67"c="7fdbeb,2"/><JPL P1="419,67"P3="420,67"P4="422,68"P2="423,68"c="7fdbeb,2"/><JPL P1="423,68"P3="424,68"P4="424,69"P2="424,68"c="7fdbeb,2"/><JPL P1="425,69"P3="425,70"P4="426,69"P2="427,70"c="7fdbeb,2"/><JPL P1="427,70"P3="428,70"P4="430,71"P2="431,71"c="7fdbeb,2"/><JPL P1="431,71"P3="433,72"P4="435,73"P2="436,74"c="7fdbeb,2"/><JPL P1="436,74"P3="437,75"P4="438,76"P2="438,77"c="7fdbeb,2"/><JPL P1="438,77"P3="438,79"P4="438,80"P2="436,82"c="7fdbeb,2"/><JPL P1="436,82"P3="434,83"P4="431,85"P2="428,86"c="7fdbeb,2"/><JPL P1="428,86"P3="423,88"P4="417,90"P2="423,88"c="7fdbeb,2"/><JD P1="357,40"P2="371,26"c="7fdbeb,2"/><L /></L></Z></C>', 200, 200, true)

local id, joints
id, joints = translateJoint('ghost', 50, 320, function()
ui.setMapName("Lá se vai um fantasmão de " .. joints .. " linhas...")
removeJoint(id)
end)
end

eventLoop = function()
executeJoint()
end

tfm.exec.disableAutoNewGame()
tfm.exec.disableAutoShaman()
tfm.exec.newGame(0)


https://image.prntscr.com/image/IOk1FAGMTzOVyJD1ql2Jfw.png
Sem o Mescouleur lindo eu não teria pensado nesse script, agora ele pode melhorar o editor de piso dele


Last edit on 1514847840000
Squalleze
« Citizen »
1514769060000
    • Squalleze#0000
    • Profile
    • Last posts
    • Tribe
#2
  2
Legal, sucesso
Didiego
« Citizen »
1514769120000
    • Didiego#9777
    • Profile
    • Last posts
#3
  2
Aaaah que fofinho os desenhos, vou usar sempre no meu cafofo *-*
Mescouleur
« Citizen »
1514775900000
    • Mescouleur#0000
    • Profile
    • Last posts
    • Tribe
#4
  2
:') orgulhoso..
seria essa uma tentativa para ajudar no editor, então? HAHAHSDIAS

Last edit on 1514776860000
Bolodefchoco
« Senator »
1514777100000
    • Bolodefchoco#0095
    • Profile
    • Last posts
    • Tribe
#5
  1
Cibelle_wu said:
Aaaah que fofinho os desenhos, vou usar sempre no meu cafofo *-*

Brigado <3

Squalleze said:
Legal, sucesso

falsa

Mescouleur said:
:') orgulhoso..
seria essa uma tentativa para ajudar no editor, então? HAHAHSDIAS

É claro

https://media.giphy.com/media/yBEzqUaJx36Fy/giphy.gif

Mescouleur
« Citizen »
1514777280000
    • Mescouleur#0000
    • Profile
    • Last posts
    • Tribe
#6
  2
Bolodefchoco said:
Cibelle_wu said:
Aaaah que fofinho os desenhos, vou usar sempre no meu cafofo *-*

Brigado <3

Squalleze said:
Legal, sucesso

falsa

Mescouleur said:
:') orgulhoso..
seria essa uma tentativa para ajudar no editor, então? HAHAHSDIAS

É claro

https://media.giphy.com/media/yBEzqUaJx36Fy/giphy.gif


que gif engraçadokkkkkkkkkkkkkkkkkkkkkkkkkkk
eu sempre soube q vc amou o q eu fiz (menos todas aquelas var, mas ok)
eu atualizo aquele treco graças aos fãs que nem vc!!!!!!!!!!!!!!!
Hydroper
« Citizen »
1514814660000
    • Hydroper#0528
    • Profile
    • Last posts
    • Tribe
#7
  2
GJ. Pena que ñ tem como o desenho ser dinâmico xd
Bolodefchoco
« Senator »
1514815440000
    • Bolodefchoco#0095
    • Profile
    • Last posts
    • Tribe
#8
  1
Profiver said:
GJ. Pena que ñ tem como o desenho ser dinâmico xd

Até dá pra fazer, mas acho que seria mais adequado num script diferente desse, não sei. É que eu teria que iterar todos os pisos e adicionar ligações pra cada linha :p
Lailaccc
« Citizen »
1517872080000
    • Lailaccc#0700
    • Profile
    • Last posts
    • Tribe
#9
  1
Titio Bolo, (amo bolo de chocolate :v) como coloca esse negocio de "Documento Lua"?
Bolodefchoco
« Senator »
1517874480000
    • Bolodefchoco#0095
    • Profile
    • Last posts
    • Tribe
#10
  1
Adarlen said:
Titio Bolo, (amo bolo de chocolate :v) como coloca esse negocio de "Documento Lua"?

Tem algo a ver com o script? Há a documentação lua e é para programação..
Kabu
« Consul »
1517984160000
    • Kabu#6682
    • Profile
    • Last posts
    • Tribe
#11
  1
Script foda, hehe. ♥
Bolodefchoco
« Senator »
1518012180000
    • Bolodefchoco#0095
    • Profile
    • Last posts
    • Tribe
#12
  1
Icrower said:
Script foda, hehe. ♥

Valeu he <3
Bloom
« Heliast »
1535319840000
    • Bloom#6766
    • Profile
    • Last posts
#13
  1
Parabéns
Bolodefchoco
« Senator »
1535320140000
    • Bolodefchoco#0095
    • Profile
    • Last posts
    • Tribe
#14
  4
Bloom said:
Parabéns

Obrigado <3
  • Forums
  • /
  • Transformice
  • /
  • Modules
  • /
  • [Script] Joint Translator
© Atelier801 2018

Staff Terms and Conditions of Use Privacy Policy Contact

Version 1.27