×

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
  • /
  • Module FAQ & Documentation
« ‹ 18 / 19 › »
Module FAQ & Documentation
Oooooooooojz
« Citoyen »
1624563960000
    • Oooooooooojz#0000
    • Profil
    • Derniers messages
    • Tribu
#341
  0
Plz help!how to use shaman skills in #utility or #shamousey room?!skills doesnt work :(

Dernière modification le 1624564080000
Hufdasr
« Citoyen »
1633606920000
    • Hufdasr#0000
    • Profil
    • Derniers messages
    • Tribu
#342
  0
If I save some string for a player using system.savePlayerData(playerName, data) and then I want to load it using system.loadPlayerData(playerName), where is the data loaded?

Dernière modification le 1633606980000
Bolodefchoco
« Sénateur »
1633616220000
    • Bolodefchoco#0095
    • Profil
    • Derniers messages
    • Tribu
#343
  0
Hufdasr a dit :
If I save some string for a player using system.savePlayerData(playerName, data) and then I want to load it using system.loadPlayerData(playerName), where is the data loaded?

It'd trigger eventPlayerDataLoaded
Hufdasr
« Citoyen »
1633622760000
    • Hufdasr#0000
    • Profil
    • Derniers messages
    • Tribu
#344
  0
on this topic is
eventPlayerDataLoaded(playerName, data)
Arguments:
  • playerName (string) - The name of the player who's data was loaded.
  • data (integer) - The data that was loaded.

but, on official Lua documentation is
eventPlayerDataLoaded ( playerName, playerData )
Arguments:
  • playerName (String) : the player whose data got loaded
  • playerData (String) : the data about the player

I couldn't understand why it gives an integer when I insert a string. It is a mistake, or it is possible for the function to give an integer as well?

Dernière modification le 1637479920000
Bolodefchoco
« Sénateur »
1633655400000
    • Bolodefchoco#0095
    • Profil
    • Derniers messages
    • Tribu
#345
  0
I've fixed it. It should be str.

Code Lua

1
2
3
4
5
6
7
system.savePlayerData("Bolodefchoco#0015", "666a")
system.loadPlayerData("Bolodefchoco#0015")

function eventPlayerDataLoaded(p, d)
assert(p == "Bolodefchoco#0015")
assert(d == "666a")
end
Hufdasr
« Citoyen »
1633676160000
    • Hufdasr#0000
    • Profil
    • Derniers messages
    • Tribu
#346
  0
Thank you, you helped me a lot. :D
Hufdasr
« Citoyen »
1633712400000
    • Hufdasr#0000
    • Profil
    • Derniers messages
    • Tribu
#347
  0
On the Lua documentation, there is a note for system.savePlayerData : "Please note that this data is per player and per Lua dev, so take care not to overwrite data from another one of your modules."
Do I understand correctly that it is possible to overwrite data from other modules with an input string? If so, is there any instructions on how to store and insert data correctly? I don't want to break something.
Bolodefchoco
« Sénateur »
1633729140000
    • Bolodefchoco#0095
    • Profil
    • Derniers messages
    • Tribu
#348
  0
It means that you only have 2,000 characters to share within all the projects hosted by the module team member.

So if I'm hosting #parkour, #powers and #mycity in the same account, I have to share this storage space for all of them... Thus needing a specific format that works for all three. And yes, a mistake can end up overwriting the string.

You can build your own parser or find alternatives in the forums. I like Laag's serializer: https://atelier801.com/topic?f=6&t=874652#m1
Wizardamani0
« Censeur »
1634198340000
    • Wizardamani0#6277
    • Profil
    • Derniers messages
#349
  0
this is good thx ☺
Err_405
« Citoyen »
1643403420000
    • Err_405#8827
    • Profil
    • Derniers messages
#350
  0
I can't find the definition of the function tfm.exec.bindKeyboard in this list of functions. Can u add it Shamousey?
Bolodefchoco
« Sénateur »
1643407860000
    • Bolodefchoco#0095
    • Profil
    • Derniers messages
    • Tribu
#351
  1
Err_405 a dit :
I can't find the definition of the function tfm.exec.bindKeyboard in this list of functions. Can u add it Shamousey?

It's system.bindKeyboard, I think that's why you can't find it.

system.bindKeyboard(playerName, keyCode, down, bind)

Effect: Binds a key to be listened for. Whenever a player presses a bound key, it will trigger eventKeyboard(). Note: Some keys (such as "A and Q") can act differently between both QWERTY and AZERTY keyboards.

Arguments:
  • playerName (string) - The username of the player whose key will be bound.
  • keyCode (integer) - The keycode to know which key to bind. Check the "Enums and IDs" section of this thread for a complete list of supported keycodes.
  • down (boolean) - If true, this will trigger the event when the key is pressed. If false, the event will be triggered when the key is released.
  • bind (boolean) - If true, this key will be bound. If false, the key will be unbound and won't trigger any more events.


Example:
Code Lua

1
system.bindKeyboard("Melibellule#0001", 32, true, true)
Err_405
« Citoyen »
1643565360000
    • Err_405#8827
    • Profil
    • Derniers messages
#352
  0
Bolodefchoco a dit :
Err_405 a dit :
I can't find the definition of the function tfm.exec.bindKeyboard in this list of functions. Can u add it Shamousey?

It's system.bindKeyboard, I think that's why you can't find it.

system.bindKeyboard(playerName, keyCode, down, bind)

Effect: Binds a key to be listened for. Whenever a player presses a bound key, it will trigger eventKeyboard(). Note: Some keys (such as "A and Q") can act differently between both QWERTY and AZERTY keyboards.

Arguments:
  • playerName (string) - The username of the player whose key will be bound.
  • keyCode (integer) - The keycode to know which key to bind. Check the "Enums and IDs" section of this thread for a complete list of supported keycodes.
  • down (boolean) - If true, this will trigger the event when the key is pressed. If false, the event will be triggered when the key is released.
  • bind (boolean) - If true, this key will be bound. If false, the key will be unbound and won't trigger any more events.


Example:
Code Lua

1
system.bindKeyboard("Melibellule#0001", 32, true, true)

Thx
Bye
« Citoyen »
1643614980000
    • Bye#9812
    • Profil
    • Derniers messages
    • Tribu
#353
  0
Is it possible to change the color of the mouse or force it to use a skin from inventory?
King_seniru
« Censeur »
1643619240000
    • King_seniru#5890
    • Profil
    • Derniers messages
    • Tribu
#354
  2
Bye a dit :
Is it possible to change the color of the mouse or force it to use a skin from inventory?

Nope, sadly :( You can add an image overlay with addImage but that wouldn't look really well
King_seniru
« Censeur »
1643785680000
    • King_seniru#5890
    • Profil
    • Derniers messages
    • Tribu
#355
  1
New lua update! (01/28/2022) - Not really new but just in case noobs don't know

  • 1.684: print() can now pretty print lua table.
  • 1.684: Added third parameter to tfm.exec.freezePlayer() to display or not ice on mice.


New events
a dit :

• eventContactListener ( playerName, groundId, contactInfo )
 Event is called when a player collides with the ground. Use it with contactListener (setting it to true should work) property in tfm.exec.addPhysicObject() or with contact="id" in xml map
 Parameters:
  - playerName (String) : the name of the player who touched the ground
  - groundId (Number) : the ground's ID
  - contactInfo (Table) : collision information
   -contactX (Int), contactY (Int), playerX (Int), playerY (Int), speedX (Int), speedY (Int)


Dernière modification le 1643785740000
Wizardamani0
« Censeur »
1643801400000
    • Wizardamani0#6277
    • Profil
    • Derniers messages
#356
  0
ok -_-
Err_405
« Citoyen »
1644062520000
    • Err_405#8827
    • Profil
    • Derniers messages
#357
  0
Guys, I tried to run this script in the tribe house:

t = {10, print, x = 12, k = "hi"}
for k, v in pairs(t) do
print(k, v)
end

This is what showed in the #lua channel:
• # 1
• # 2
• # x
• # k

How do I fix this? Thanks!
Err_405
« Citoyen »
1644065100000
    • Err_405#8827
    • Profil
    • Derniers messages
#358
  0
Also, I ran this code in zerobrane studio:
t = {}
for line in io.lines() do
table.insert(t, line)
end
print(#t)

And when I input the lines I don't know how to reach the end of the program because it keeps asking me to input lines. What do I do? Thanks so much!
King_seniru
« Censeur »
1644068820000
    • King_seniru#5890
    • Profil
    • Derniers messages
    • Tribu
#359
  1
Err_405 a dit :
Guys, I tried to run this script in the tribe house:

t = {10, print, x = 12, k = "hi"}
for k, v in pairs(t) do
print(k, v)
end

This is what showed in the #lua channel:
• # 1
• # 2
• # x
• # k

How do I fix this? Thanks!

How to fix what exactly, what's the expected behavior? If the problem is the value (v) related with table's keys (k) not getting printed, it's because the lua implementation in tfm doesn't accept "vararg" type arguments for print. To print both k and v do print({k, v})


Err_405 a dit :
Also, I ran this code in zerobrane studio:
t = {}
for line in io.lines() do
table.insert(t, line)
end
print(#t)

And when I input the lines I don't know how to reach the end of the program because it keeps asking me to input lines. What do I do? Thanks so much!

When you press enter in the newline without typing any other value, it'd send an empty string (""). So do it like this
code
Code Lua

1
2
3
4
5
6
t = {}
for line in io.lines() do
if line == "" then break end
table.insert(t, line)
end
print(#t)

You can also do Ctrl+C to terminate the program, and it would give the same output as above

Dernière modification le 1644069060000
Err_405
« Citoyen »
1644069180000
    • Err_405#8827
    • Profil
    • Derniers messages
#360
  0
King_seniru a dit :
Err_405 a dit :
Guys, I tried to run this script in the tribe house:

t = {10, print, x = 12, k = "hi"}
for k, v in pairs(t) do
print(k, v)
end

This is what showed in the #lua channel:
• # 1
• # 2
• # x
• # k

How do I fix this? Thanks!

How to fix what exactly, what's the expected behavior? If the problem is the value (v) related with table's keys (k) not getting printed, it's because the lua implementation in tfm doesn't accept "vararg" type arguments for print. To print both k and v do print({k, v})


Err_405 a dit :
Also, I ran this code in zerobrane studio:
t = {}
for line in io.lines() do
table.insert(t, line)
end
print(#t)

And when I input the lines I don't know how to reach the end of the program because it keeps asking me to input lines. What do I do? Thanks so much!

When you press enter in the newline without typing any other value, it'd send an empty string (""). So do it like this
code
Code Lua

1
2
3
4
5
6
t = {}
for line in io.lines() do
if line == "" then break end
table.insert(t, line)
end
print(#t)

You can also do Ctrl+C to terminate the program, and it would give the same output as above

OMFG that's exactly what I wanted to try at the last program. Thanks a lot! Do you use discord? I may need more help with this stuff. I just started learning lua...
  • Forums
  • /
  • Transformice
  • /
  • Modules
  • /
  • Module FAQ & Documentation
« ‹ 18 / 19 › »
© Atelier801 2018

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

Version 1.27