×

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
  • /
  • Module API FAQ
« ‹ 30 / 38 › »
Module API FAQ
Discretooo
1389939960000
    • Discretooo#0000
    • Profil
    • Derniers messages
    • Tribu
#581
[Modéré par Icewolfbob, raison : Please speak English here on the EN forums. Thank you!]
Laagaadoo
« Citoyen »
1390089720000
    • Laagaadoo#0000
    • Profil
    • Derniers messages
    • Tribu
#582
  0
Lua Team members can use tfm.exec.chatMessage in the tribehouse?
Shamousey
« Consul »
1390090320000
    • Shamousey#0095
    • Profil
    • Derniers messages
    • Tribu
#583
  0
Laagaadoo a dit :
Lua Team members can use tfm.exec.chatMessage in the tribehouse?

No, the Lua Team has the same powers as regular users in the tribe house.
Quesoyquesos
« Citoyen »
1390090440000
    • Quesoyquesos#0000
    • Profil
    • Derniers messages
    • Tribu
#584
  0
Lua team can use chat messaje in tribe and rooms or in rooms?
Hophipmice
« Citoyen »
1390123860000
    • Hophipmice#0000
    • Profil
    • Derniers messages
    • Tribu
#585
  0
Quesoyquesos a dit :
Lua team can use chat messaje in tribe and rooms or in rooms?

Rooms only.
Kittyepress
« Citoyen »
1390138440000
    • Kittyepress#0000
    • Profil
    • Derniers messages
#586
  0
Why in Infected one player name is pink?
Benbirkralm
« Citoyen »
1390228320000
    • Benbirkralm#0000
    • Profil
    • Derniers messages
    • Tribu
#587
  0
Thanks.
Bushmeister
1390231260000
    • Bushmeister#0000
    • Profil
    • Derniers messages
    • Tribu
#588
[Modéré par Bolinboy]
Mousechris
« Censeur »
1390629600000
    • Mousechris#0000
    • Profil
    • Derniers messages
    • Tribu
#589
  0
Is there any way to put an XML into the script '[XML code here]' when I try to put one in I always get an error
Safwanrockz
« Censeur »
1390667880000
    • Safwanrockz#0095
    • Profil
    • Derniers messages
    • Tribu
#590
  0
Mousechris a dit :
Is there any way to put an XML into the script '[XML code here]' when I try to put one in I always get an error

Just put the xml in a string that starts and ends with two square brackets.
a dit :

xml = [[<C><P ><S><The rest of the XML here>]]
tfm.exec.newGame(xml)

 
Laagaadoo
« Citoyen »
1390696320000
    • Laagaadoo#0000
    • Profil
    • Derniers messages
    • Tribu
#591
  0
Why the math.random() choose three values instead one? I want only one value, but sometimes it choose three...

a dit :
players = {}
math.random(players[math.random(#players)])

The table has values.
Mousechris
« Censeur »
1390697820000
    • Mousechris#0000
    • Profil
    • Derniers messages
    • Tribu
#592
  0
Safwanrockz a dit :
Just put the xml in a string that starts and ends with two square brackets.
 

No, I mean the script thing

that way it can show an XML in the script start
edit: apparently < can't be used in the chat, so oh well, nvm
Safwanrockz
« Censeur »
1390748640000
    • Safwanrockz#0095
    • Profil
    • Derniers messages
    • Tribu
#593
  0
Mousechris a dit :
No, I mean the script thing

that way it can show an XML in the script start
edit: apparently < can't be used in the chat, so oh well, nvm

Ooooh, you mean with printing the XML. You can simply do that with the gsub() function:
a dit :

xml = [[<C><P ><S><The rest of the XML here>]]
xml = xml:gsub("<", "&lt;")
print(xml)

Laagaadoo a dit :

players = {}
math.random(players[math.random(#players)])

That script is wrong; basically math.random(a,b) is used to return a random NUMBER between a and b, for example math.random(1,10) returns a random number between 1 and 10.
Likewise, math.random is used among tables to return a random number to be the index of this table, for example:
a dit :

players={"Safwanrockz","Laagaadoo"}
print(players[1])


This will print the FIRST value of the players table, which is "Safwanrockz".
a dit :

players={"Safwanrockz","Laagaadoo"}
print(players[math.random(0,#players)])


math.random() here will return a random number between 0 and the length of players table (which is 2), and then this number will be as a random index of the players table, hence a random value of the players table will be printed.
Note that if math.random() is used with only one argument, it returns a random number between 0 and the argument you specified; for example math.random(9) returns a random number between 0 and 9.
Laagaadoo
« Citoyen »
1390757580000
    • Laagaadoo#0000
    • Profil
    • Derniers messages
    • Tribu
#594
  0
Safwanrockz a dit :
Ooooh, you mean with printing the XML. You can simply do that with the gsub() function:
That script is wrong; basically math.random(a,b) is used to return a random NUMBER between a and b, for example math.random(1,10) returns a random number between 1 and 10.
Likewise, math.random is used among tables to return a random number to be the index of this table, for example:

This will print the FIRST value of the players table, which is "Safwanrockz".

math.random() here will return a random number between 0 and the length of players table (which is 2), and then this number will be as a random index of the players table, hence a random value of the players table will be printed.
Note that if math.random() is used with only one argument, it returns a random number between 0 and the argument you specified; for example math.random(9) returns a random number between 0 and 9.

Thanks! The eventLoop influences the math.random ? I placed it in the eventLoop inside a "timer".
Abdeltif
« Citoyen »
1390757760000
    • Abdeltif#0000
    • Profil
    • Derniers messages
    • Tribu
#595
  0
Laagaadoo a dit :
Thanks! The eventLoop influences the math.random ? I placed it in the eventLoop inside a "timer".

What do you exacly mean ?
Also , eventLoop will call it more then once and it will chose a random number more then once !
You could put it outside the loop to chose a random number only once for all the time

E : Saf you ninjad ! ;)
Safwanrockz
« Censeur »
1390757760000
    • Safwanrockz#0095
    • Profil
    • Derniers messages
    • Tribu
#596
  0
Laagaadoo a dit :
Thanks! The eventLoop influences the math.random ? I placed it in the eventLoop inside a "timer".

It works if it's within a body of an if statement, but preferably remove it from eventLoop().
Laagaadoo
« Citoyen »
1390760520000
    • Laagaadoo#0000
    • Profil
    • Derniers messages
    • Tribu
#597
  0
Safwanrockz a dit :
It works if it's within a body of an if statement, but preferably remove it from eventLoop().

I want choose a random player in 10 seconds, maybe the problem is the eventLoop()...
Abdeltif
« Citoyen »
1390763760000
    • Abdeltif#0000
    • Profil
    • Derniers messages
    • Tribu
#598
  0
Laagaadoo a dit :
I want choose a random player in 10 seconds, maybe the problem is the eventLoop()...

oh
hmm
What do you want to do with him? xD


a dit :
t = 0

PLRS = {"Laagaadoo", "someoneslese..."}
function eventLoop()
t = t + 0.5
if t<=10 then
local player = PLRS[math.random(#PLRS)]
t = 0
print(player)
end
end

---------You can also do this-------------
a dit :

PLRS = {}
function eventNewPlayer(name)
table.insert(PLRS, name)
end
for k,v in pairs(tfm.get.room.playerList) do
eventNewPlayer(k)
end
function eventLoop()
t = t + 0.5
if t<=10 then
local player = PLRS[math.random(#PLRS)]
t = 0
print(player)
end
end

.
Efefay
« Citoyen »
1390862820000
    • Efefay#0000
    • Profil
    • Derniers messages
#599
  0
Simosc no longer plays so i would like to learn how to code lua. I just don't know where to start...

There is so much information in the opening document
Shamousey
« Consul »
1390917960000
    • Shamousey#0095
    • Profil
    • Derniers messages
    • Tribu
#600
  0
Efefay a dit :
Simosc no longer plays so i would like to learn how to code lua. I just don't know where to start...

There is so much information in the opening document

There are several links under the "Where can I learn Lua?" that direct you to places you can start learning Lua from scratch.

Also, it'd be worth noting that the official documentation has been updated to fix a few things (Tigrounette's original documentation contained some wrong things, and lacking information in some places). Ontop of that, functions you can't use in the tribe house are also marked with a
* so you know which aren't available.
  • Forums
  • /
  • Transformice
  • /
  • Archives
  • /
  • Module API FAQ
« ‹ 30 / 38 › »
© Atelier801 2018

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

Version 1.27