×

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
  • /
  • Lua Snippets
« ‹ 26 / 33 › »
Lua Snippets
Zyx
« Censeur »
1387504980000
    • Zyx#8690
    • Profil
    • Derniers messages
#501
  0
Animaljamvid a dit :
i was never banned for hacking before (at least i dont think so) and 1000 cheese in shop or the 1000 cheese in profile? cause in profile i have 4533 cheese .-.

You need profile cheese. Anyhow if it doesn't work you probably got banned and now you don't remember it.
Animaljamvid
« Citoyen »
1387556700000
    • Animaljamvid#0000
    • Profil
    • Derniers messages
    • Tribu
#502
  0
well thats sad for me D: ive only gotten two warnings i never knew i got banned DD:
Abdeltif
« Citoyen »
1388778840000
    • Abdeltif#0000
    • Profil
    • Derniers messages
    • Tribu
#503
  0
a dit :
score = {
compair = function(score1, score2)
if score1 and score2 then
if score1>score2 then
return score1
elseif score1<score2 then
return score2
elseif score1==score2 then
return score1, score2
end
elseif not score1 then
error("Element 1 is NIL", 2)
elseif not score2 then
error("Element 2 is NIL", 3)
end
end
}

You can compair two elements (score.compair(element1, element2)) and the function will return to the biggest one or if they are equal each other , it will return them both.
Safwanrockz
« Censeur »
1388780280000
    • Safwanrockz#0095
    • Profil
    • Derniers messages
    • Tribu
#504
  0
Abdeltif a dit :
You can compair two elements (score.compair(element1, element2)) and the function will return to the biggest one or if they are equal each other , it will return them both.

Not really necessary, plus why'd you put that in a table and store it in a variable, lol.
Abdeltif
« Citoyen »
1388780520000
    • Abdeltif#0000
    • Profil
    • Derniers messages
    • Tribu
#505
  0
Safwanrockz a dit :
Not really necessary, plus why'd you put that in a table and store it in a variable, lol.

Because I have more in my files and I don't want to share it ^^
That's why :p
(Also I love the thing.thing that's why omo)

This can be used in tfm, like it compairs the score of two players when the admin do !compare name1 name2
and do something to the one who have more , or if you have a private score system ect ...
Kittyepress
« Citoyen »
1391447640000
    • Kittyepress#0000
    • Profil
    • Derniers messages
#506
  0
Can get the codes now, ty ^^
Epicsouris
« Citoyen »
1393705980000
    • Epicsouris#0000
    • Profil
    • Derniers messages
#507
  0
Hey. Could someone make a code for only one mouse can teleport with a mouse click please, thanks!
Safwanrockz
« Censeur »
1393706460000
    • Safwanrockz#0095
    • Profil
    • Derniers messages
    • Tribu
#508
  0
Epicsouris a dit :
Hey. Could someone make a code for only one mouse can teleport with a mouse click please, thanks!

Edit "Epicsouris" if you want another.
a dit :

n="Epicsouris"
system.bindMouse(n,true)
function eventMouse(name,x,y)
tfm.exec.movePlayer(name,x,y)
end

 
Luffylxl
« Citoyen »
1394476620000
    • Luffylxl#0000
    • Profil
    • Derniers messages
    • Tribu
#509
  0
Hi, could you explain to me why this code does not work?

code a dit :
function eventLoop (currentTime, timeRemaining) -- Un compteur tourne toutes les 500 milisecondes sur la map
if (currentTime > 5000 and currentTime < 6000 ) then -- Si le temps passé est entre 5 seconds et 6
ui.removeTextArea (1, nil) -- Supprimer le texte "fait gaffe au commencement morray"
ui.addTextArea (4, "3...", nil, 390, 28, width, height, 0x000000, 0xFFFFFF, 0.8, true)-- Creer une zone de texte, avec "3.." dedans
elseif (currentTime > 6500 and currentTime < 7500 ) then -- Sinon si le temps passé est entre 6.5 secondes et 7.5 secondes
ui.updateTextArea (4, "2..", nil) -- Modifier le "3..." en "2.."
elseif (currentTime > 8000 and currentTime < 9500 ) then -- Sinon si le temps passé est entre 8 secondes et 9.5 secondes
ui.updateTextArea (4, "1..", nil) -- Modifier le "2.." en "1.."
elseif(currentTime > 10000 and currentTime < 11000 ) then -- Sinon si le temps passé est entre 10 secondes et 11 secondes (donc 1min50)
ui.updateTextArea (4, "<r><b>GO</r></b>", nil) -- Afficher un "Go" en rouge et gras
elseif(currentTime > 15000 ) then -- Sinon si 15 secondes se sont ecoulés
ui.removeTextArea (4, nil) -- Supprimer la zone de texte qui comporte le "Go"
end -- Fin de l'if
function eventSummoningEnd (playerName, objectType, xPosition, yPosition, angle, xSpeed, ySpeed, other) -- Si le cham invoque
while (currentTime < 10000) do -- Si il invoque avant 1min50
tfm.exec.killPlayer (playerName) -- Le random meurt
end -- Fin de l'if
end -- Fin de la fonction invoque chamane
end -- Fin de la fonction eventLoop (500 milisecondes)

Sorry for annotations in french.
When i say "don't work", it's only the latter function doesn't work, it kills the shaman before 10 seconds if the shamanes spawn a item.
Thank's and sorry for my english ! ;)
Safwanrockz
« Censeur »
1394478060000
    • Safwanrockz#0095
    • Profil
    • Derniers messages
    • Tribu
#510
  0
Luffylxl a dit :
Hi, could you explain to me why this code does not work?


Sorry for annotations in french.
When i say "don't work", it's only the latter function doesn't work, it kills the shaman before 10 seconds if the shamanes spawn a item.
Thank's and sorry for my english ! ;)

The currentTime variable is a local variable for eventLoop, which you also used in eventSummoningEnd, hence it doesn't work.
Luffylxl
« Citoyen »
1394549760000
    • Luffylxl#0000
    • Profil
    • Derniers messages
    • Tribu
#511
  0
Thank's for your help.
A new question, I want to make some sort of moderation, which has a command for only her, but don't understand why it doen't work.

code a dit :

mods = {"Luffylxl","otherpseudonym"}

for playerName in pairs(mods) do
tfm.exec.bindKeyboard(playerName, 17, true, true)
end
for playerName in pairs(mods) do
tfm.exec.bindKeyboard(playerName, 32, true, true)
end

Can you help me ?
EDIT : I'm sorry, I found the solution. =)
Abdeltif
« Citoyen »
1394651520000
    • Abdeltif#0000
    • Profil
    • Derniers messages
    • Tribu
#512
  0
Luffylxl a dit :
Thank's for your help.
A new question, I want to make some sort of moderation, which has a command for only her, but don't understand why it doen't work.
Can you help me ?
EDIT : I'm sorry, I found the solution. =)

The player you are binding the keys for is the key of the value
in for loops, the metatables work like this :
a dit :

Table = {"The value of key:1", "The second value"}
Table[4] = "The fourth"
for key,value in pairs(Table) do
print(key, value)
end
Output = [[
1 The value of key:1
2 The second value
4 The fourth
]]

And removing the value argument, it will become :
a dit :

Table = {"The value of key:1", "The second value"}
Table[4] = "The fourth"
for key in pairs(Table) do
print(key)
end
Output = [[
1
2
4]]

There are two ways to fix your script , the first is to make the names of players as keys if you want the for loops stay as they are , we can simply make thier values as anything(string, number, boolean, table, nil...):
a dit :

mods = {Luffylxl=nil,otherpseudonym=nil}

for playerName in pairs(mods) do
tfm.exec.bindKeyboard(playerName, 17, true, true)
end
for playerName in pairs(mods) do
tfm.exec.bindKeyboard(playerName, 32, true, true)
end

Or we can add the value argument to the two for loops, and change the first argument of tfm.exec.bindKeyboard function into the name of the second argument in the for loop :
a dit :

mods = {"Luffylxl","otherpseudonym"}

for playerName,name in pairs(mods) do
tfm.exec.bindKeyboard(name, 17, true, true)
end
for playerName in pairs(mods) do
tfm.exec.bindKeyboard(name, 32, true, true)
end

I hope this was usefull enough ;)
-- Hex my posts are mega long and boring to read.
Safwanrockz
« Censeur »
1394656860000
    • Safwanrockz#0095
    • Profil
    • Derniers messages
    • Tribu
#513
  0
Abdeltif a dit :
[wall of text]

Luffylxl a dit :
EDIT : I'm sorry, I found the solution. =)

Regardless, your explanation was pretty useful.
Luffylxl
« Citoyen »
1394746320000
    • Luffylxl#0000
    • Profil
    • Derniers messages
    • Tribu
#514
  0
Anyway I thank you for your explanations that can help others. But I noticed my fault before and i corrected that with the same way :
a dit :
for id,playerName in pairs(mods) do
tfm.exec.bindKeyboard(playerName, 17, true, true)
tfm.exec.bindKeyboard(playerName, 32, true, true)
end

But thank you for trying to help me, it's always nice to hear. =)

PS : Sorry again for my english, i'm french.
Abdeltif
« Citoyen »
1395055980000
    • Abdeltif#0000
    • Profil
    • Derniers messages
    • Tribu
#515
  0
Luffylxl a dit :
Anyway I thank you for your explanations that can help others. But I noticed my fault before and i corrected that with the same way :

But thank you for trying to help me, it's always nice to hear. =)

PS : Sorry again for my english, i'm french.

Your welcome

Safwanrockz a dit :



Regardless, your explanation was pretty useful.

I know, a wall of text for nothing ;-;
Luffylxl
« Citoyen »
1395598440000
    • Luffylxl#0000
    • Profil
    • Derniers messages
    • Tribu
#516
  0
You can explain to me why this code applies only to the last survivor ?
a dit :

function eventPlayerDied(name)
local i=0
local n
for pname,player in pairs(tfm.get.room.playerList) do
if not player.isDead then
i=i+1
n=pname
end
end
if i==1 then
tfm.exec.giveCheese(n)
tfm.exec.playerVictory(n)
tfm.exec.setGameTime(5)
end
end

Thank's. ;)
Bad
1395612360000
    • Bad#9645
    • Profil
    • Derniers messages
    • Tribu
#517
[Modéré par Bolinboy, raison : double post]
Bad
« Citoyen »
1395614280000
    • Bad#9645
    • Profil
    • Derniers messages
    • Tribu
#518
  0
How could you respawn only 1 specific mouse on a map?

And how could you only make 1 mouse fly?
[quote=
function eventNewPlayer(name)
tfm.exec.bindKeyboard(name,32,true,true)
end

for name,player in pairs(tfm.get.room.playerList) do
eventNewPlayer(name)
end

function eventKeyboard(name,key,down,x,y)
if key==32 then
tfm.exec.movePlayer(name,0,0,true,0,-50,false)
end
end [/quote]

I tried this but it dosen't work :/
Abdeltif
« Citoyen »
1395615180000
    • Abdeltif#0000
    • Profil
    • Derniers messages
    • Tribu
#519
  0
Luffylxl a dit :
You can explain to me why this code applies only to the last survivor ?


Thank's. ;)

Indeed I can
First it counts the number of the survived players
and sets the variable n to the LAST player in the loop that is alive.
If there is only 1 survival
The variable n will refer to his name , ofcorse , because he is the FIRST and THE LAST survival.
so he get cheese and win, and a new game starts.
Why do you need explanation in this ?
Also, the argument "name" is useless
and it doens't refer to the last survival, it simply does nothing if there is more than 1 person alive.
Safwanrockz
« Censeur »
1395655380000
    • Safwanrockz#0095
    • Profil
    • Derniers messages
    • Tribu
#520
  0
Badmanb a dit :
How could you respawn only 1 specific mouse on a map?

Use this (!respawn Name)
a dit :

function eventChatCommand(name,cmd)
local arg={}
for word in cmd:gmatch("[^%s]+") do
table.insert(arg, word)
end
if arg[1]=="respawn" then
tfm.exec.respawnPlayer(arg[2])
end
end

Badmanb a dit :
And how could you only make 1 mouse fly?
I tried this but it dosen't work :/

There are several solutions for this, the easiest way to do it is to only bind the keyboard to the specific user you want.
a dit :

name="Badmanb"
tfm.exec.bindKeyboard(name,32,true,true)
function eventKeyboard(name,key,down,x,y)
if key==32 then
tfm.exec.movePlayer(name,0,0,true,0,-50,false)
end
end

 
  • Forums
  • /
  • Transformice
  • /
  • Modules
  • /
  • Lua Snippets
« ‹ 26 / 33 › »
© Atelier801 2018

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

Version 1.27