×

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
1 / 19 › »
Module FAQ & Documentation
Shamousey
« Consul »
1411071240000
    • Shamousey#0095
    • Profil
    • Derniers messages
    • Tribu
#1
  12
  • General
  • Module Team
  • Module Rooms
  • Enums and IDs
  • Lua Tree
  • Lua resources
  • Lua API Changelog

http://www.transformice.com/share/api.png



Modules are mini-games build in Transformice with a variety of different gameplay options, the developers of them have complete control.
They are coded in the lightweight Lua scripting Language.

What are the different types of modules?

Official Modules

• Official modules are mini-games or utilities that have been approved by an Administrator.
• They show up on the in-game mini-game rooms list.
• You can earn 1 shop cheese every 2 minutes when you enter the hole.
• You can load these modules in the tribe house.
• These modules must be hosted by someone of the Module Team.

Semi-official Modules

• Semi-official modules are mini-games or utilities that have been approved by an Administrator.
• You can load these modules in the tribe house.
• These modules must be hosted by someone of the Module Team.

Unofficial Modules

• Unofficial modules are usually just scripts ran in tribe houses and other rooms without being previously approved by an Administrator.


What is the different about modules compared to normal rooms?

Other than modules each having their own unique game-play and features, there's a few other things to note.
• In official modules you can earn 1 shop cheese every 2 minutes when you enter the hole.
• In unofficial modules there is no "Your last message is the same" warning.
• Stats are disabled.
• /mort is disabled.

How can I play a module?

You can play any (semi-)official module by going to its room, for example "/room #ModuleName", or running it in your tribe house with the command "/module #ModuleName" if you have the power to load maps there.

You can play unofficial modules by loading the script yourself, or having someone else load it for you.

How do I Run a script?

In order to execute your own script, you need to fit a couple of requirements; be in your tribe house, have the appropriate permissions to use the "/np" command, have over 100 cheese, and never be banned for hacking.

You can then type the command "/lua" and a window will pop up with an area to type in or paste code. Pressing the "Submit" button will launch the script in your room

https://i.imgur.com/fRFAxZo.png

Where can I suggest something or report a bug?

If you've come up with an idea you'd like to see implemented in either the Module API itself or an individual module, you can post it in the Module Suggestions Thread.

If you've noticed a bug with the Module API or a specific module, you can report it in the Module Bugs Thread

I've developed a module, how can it be made official?

Only members of the Module Team can manage an official module. You should consider applying for the team yourself (see the "Module Team" section of this thread for instructions on how to do that), or alternatively ask an existing member of the team to look at it on your behalf.

All official modules need to be approved by an administrator, and these modules should have several things such as; fun gameplay, replay value, clear help/rules, translations to the most popular languages in the communities, and efficient coding that won't use too many server resources or crash.

I ran a script and a #lua chat tab opened, what is this?

The #lua chat tab is used to house all information about your currently running scripts. Any printed strings will display here, as well as any errors, warnings for high runtime, or anything else of the sort.

Where can I get help coding a module?

If you need help in developing something, there are several places you can go. If you're experiencing an error, you can visit the errors thread for information on how to fix it, or post your code for someone else to fix for you. If you need a function or some code written for you, the Script Requests thread is the place to ask.

If you need to talk to someone one-on-one, you can talk to any of the members listed in the "Module Team" section of this thread, join "/chat Lua" ingame, or use the #modules Discord channel A validated account is required to get access to the #lua channel, see #rules-and-roles.

http://images.atelier801.com/1772d16ab58.png

Is there anything else I should take note of when developing a module?

There are a few quirks and useful bits of information that will help you out when developing with the Module API.

• Flash supports some HTML tags that can be used in chat messages, popups, textareas, and other places that display strings. You can read more about which HTML tags can be used here.
• tfm.exec.newGame() can't be executed less than 3 seconds since the last time it was ran.
• "<" and ">" characters can't be displayed in strings, however by using the HTML entities for them, they can be.
• "http", "://" words can't be displayed in textareas.
• Some variables in tfm.get.room.playerList and tfm.get.room.objectList rely on the room's sync to stay updated. This means that several things such as player's and object's coordinates, player's direction, and several other things can be incorrect at times as they only update roughly once every 500 milliseconds.
• Function names all use camelCase, meaning that the first word starts with a lowercase character and all subsequent ones start with an uppercase character. A good example of this is tfm.exec.disableAllShamanSkills()
• Scripts can only be successfully executed if their size is less than 1mb.
The Module Team is a group of developers who create minigames for the community to enjoy playing, by using the Module API.

Members of the team have access to a few additional functions to create modules, some of which are more resource intensive on the server than other functions so are limited - these functions are marked in the documentation in this thread.

Some of the features available to the module team exclusively are:
  • Access to a dedicated chat channel to talk with the rest of the members of the team directly.
  • The ability to load scripts outside of the tribe house.
  • Saving information to a database, for things like persistent leaderboards.
  • Saving statistics for each user, allowing persistent stats for your minigame.
  • Uploading images to the atelier801.com domain.


The full list of team members is kept private as some members wish to remain anonymous or not handle whispers, however the following people listed are public members of the team, you may contact them for help developing your module, getting your module made official, or ask them any other questions you may have.

• https://atelier801.com/img/pays/sa.png Bodykudo#0000
• https://atelier801.com/img/pays/sa.png Heniyengui#0000
• https://atelier801.com/img/pays/sa.png Massi#0095
• https://atelier801.com/img/pays/sa.png Noooooooorr#0000
• https://atelier801.com/img/pays/sa.png Turkitutu#0000
• https://atelier801.com/img/pays/br.png Bolodefchoco#0015
• https://atelier801.com/img/pays/br.png Brenower#0000
• https://atelier801.com/img/pays/br.png Esh#0095
• https://atelier801.com/img/pays/br.png Fofinhoppp#0000
• https://atelier801.com/img/pays/br.png Laagaadoo#0000
• https://atelier801.com/img/pays/br.png Nettoork#0000
• https://atelier801.com/img/pays/br.png Ninguem#0095
• https://atelier801.com/img/pays/br.png Rufflesdqjo#0095
• https://atelier801.com/img/pays/br.png Thanos#1306
• https://atelier801.com/img/pays/gb.png Drgenius#0000
• https://atelier801.com/img/pays/gb.png Frozenjord#0656
• https://atelier801.com/img/pays/gb.png Gekkeiju#0000
• https://atelier801.com/img/pays/gb.png King_seniru#5890
• https://atelier801.com/img/pays/gb.png Moepl#0095
• https://atelier801.com/img/pays/gb.png Onkei#0000
• https://atelier801.com/img/pays/gb.png Papero#9240
• https://atelier801.com/img/pays/gb.png Sebaisseba#0095
• https://atelier801.com/img/pays/gb.png Shamousey#0015
• https://atelier801.com/img/pays/gb.png Sharpiepoops#0020
• https://atelier801.com/img/pays/gb.png Tat#0095
• https://atelier801.com/img/pays/es.png Saintgio#0000
• https://atelier801.com/img/pays/es.png Tocutoeltuco#0000
• https://atelier801.com/img/pays/es.png Warfenix#0095
• https://atelier801.com/img/pays/fr.png Athesdrake#0000
• https://atelier801.com/img/pays/fr.png Thewav#0095
• https://atelier801.com/img/pays/fr.png Tortuegreen#0000
• https://atelier801.com/img/pays/nl.png Jordy#0095
• https://atelier801.com/img/pays/nl.png Makinit#0095
• https://atelier801.com/img/pays/pl.png Rkubi#0000
• https://atelier801.com/img/pays/pl.png Sebafrancuz#0000
• https://atelier801.com/img/pays/ro.png Extremq#0000
• https://atelier801.com/img/pays/ru.png Zigwin#0000

The Module Team is looking for dedicated members of the community with bright ideas for games that know Lua well and are willing to create fantastic modules for the whole community to enjoy.

Before considering applying for this position, there are several things that you should take note of:
• All applicants must speak some level of English in order to communicate with the rest of the team.
• This is not a staff position, there is no age limit or additional benefits.
• After your application, you will get a notification when you are accepted.
• Maturity is required from all members of the team, even if they're not public members.
• All members of the team must know Lua and how to use the Module API. Practising in the tribe house is a good way to ensure you know how it works.

If you are ready to apply, feel free to fill out the following form in English.

Apply Here
What are all of the semi-official and official modules?

You can find a list of official modules ingame by typing "/module" or going to the "Game Mode" window from the menu.

On forums, you can check the Available Module Rooms thread.

This section contains a variety of different pieces of information that can be useful when developing a module, such as enums, color codes, IDs, and more.

Color Codes

The color codes listed here are commonly used in Transformice, both the game and interface. For a more complete list of color codes used in the game, please visit this thread.

#6A7495 Game background.
#324650 Game UI.
#465a6e Lighter game UI.

Color code Description Attribute
#2F7FCC Mapcrew color. <BV>
#CB546B Errors' color. <R>
#6C77C1 Default system messages' color. <BL>
#BABD2F Help & other informations' color. <J>
#C2C2DA Messages' color. <N>
#9292AA Disabled buttons' color. <N2>
#2EBA7E Tribe color. <PT>
#E88F4F Whisper color. <CE>
#F0A78E Whisper color. <CEP>
#EFCE8F Whisper color. <CS>
#FFD991 Whisper color. <D>
#CAA4CF Chat messages' (/chat ...) color. <S>
#F1C4F6 Chat messages' (/chat ...) color. <PS>
#E9E654 Clicked links' color. <A:ACTIVE>
#2ECF73 Links on hover color. <A:HOVER>
#606090 Offline friends' color. <G>
#009D9D Default nickname color. <V>
#2ECF73 Tutorial keywords' color. <VP>
#C53DFF Purple color. <VI>
#ED67EA Server and moderator messages' color. <ROSE>
#98E2EB Blue shaman color. <CH>
#FEB1FC Pink shaman color. <CH2>
#A4CF9E Tribe messages' color. <T>
#FF8547 Funcorp color. <FC>
#F79337 Funcorp color. <O>



Emote IDs

This is a list of emotes and their corresponding enums. Bare in mind that the tfm.enum.emote table has a list of all emote names and enums.

    dance : 0
    laugh : 1
    cry : 2
    kiss : 3
    angry : 4
    clap : 5
    sleep : 6
    facepaw : 7
    sit : 8
    confetti : 9
    flag : 10
    marshmallow : 11
    selfie : 12
    highfive : 13
    highfive_1 : 14
    highfive_2 : 15
    partyhorn : 16
    hug : 17
    hug_1 : 18
    hug_2 : 19
    jigglypuff : 20
    kissing : 21
    kissing_1 : 22
    kissing_2 : 23
    carnaval : 24
    rockpaperscissors : 25
    rockpaperscissors_1 : 26
    rockpaperscissor_2 : 27



Shaman Object IDs

While tfm.enum.shamanObject is an easy-to-access list of most shaman objects, it doesn't list every object available in Transformice. Here is a list of all shaman objects that can be spawned in with tfm.exec.addShamanObject.

Note that some of them can't be spawned properly in modules, so are crossed out.

    arrow : 0
    littleBox : 1
    box : 2
    littleBoard : 3
    board : 4
    Heavy Ball : 5
    ball : 6
    trampoline : 7
    Small Rough Plank : 8
    Large Rough Plank : 9
    anvil : 10
    Red Anchor : 11
    Red Anchor Rotating Clockwise : 12
    Red Anchor Rotating Counter-Clockwise : 13
    Green Anchor : 14
    Green Anchor Rotating Clockwise : 15
    Green Anchor Rotating Counter-Clockwise : 16
    cannon (Up) : 17
    Cannon (Down) : 18
    Cannon (Right) : 19
    Cannon (Left) : 20
    Sticky Ball : 21
    Yellow Anchor : 22
    bomb : 23
    Fake Cheese : 25
    orangePortal : 26
    blueBalloon : 28
    redBalloon : 29
    greenBalloon : 30
    yellowBalloon : 31
    rune : 32
    chicken : 33
    snowBall : 34
    cupidonArrow : 35
    apple : 39
    sheep : 40
    Demolition Worker Skill : 41
    Spring : 42
    Speed Boost : 43
    Totem : 44
    littleBoardIce : 45
    littleBoardChocolate : 46
    Transformed Mouse Small Box : 48
    Transformed Mouse Large Box : 49
    Transformed Mouse Anvil : 50
    Transformed Mouse Small Plank : 51
    Transformed Mouse Large Plank : 52
    Transformed Mouse : 53
    iceCube : 54
    cloud : 57
    Architect Skill : 58
    bubble : 59
    tinyBoard : 60
    companionCube : 61
    stableRune : 62
    balloonFish : 65
    Balloon Anchor : 66
    longBoard : 67
    triangle : 68
    sBoard : 69
    Cobweb Skill : 70
    Roll Skill : 71
    Recycling Skill : 72
    Small Mouse Skill : 73
    Leaf Skill : 74
    Nature's Return Skill : 75
    Booster Skill : 76
    Handymouse Skill : 77
    Restorative Skill : 78
    Stop Skill : 79
    paperPlane : 80
    Gravitational Anomaly Skill : 81
    Antigravity Skill : 82
    Meep Skill : 83
    Grapnel Skill : 84
    rock : 85
    Campfire Skill : 86
    Shameow Skill (Broken) : 87
    Conjuration Anchor : 88
    pumpkinBall : 89
    tombstone : 90
    Snowman : 91
    Renewal Skill : 92
    Small Cloud : 93
    Shameow Skill : 94
    paperBall : 95
    Invisible Small Box : 100-199, 20000-29999
    Custom Small Box : 101-199
    Invisible Large Box : 200-299, 30000-32767
    Custom Large Box : 201-299
    Invisible Small Plank : 300-399
    Custom Small Plank : 301-399
    Invisible Large Plank : 400-499
    Custom Large Plank : 401-499
    Invisible Ball : 600, 602-699
    Custom Ball : 601-699
    Invisible Trampoline : 700-799
    Custom Trampoline : 701-799
    Invisible Anvil : 1000-1099
    Custom Anvil : 1001-1099
    Invisible Cannon (Up) : 1700-1799
    Custom Cannon (Up) : 1701
    Invisible Cannon (Down) : 1800-1899
    Invisible Cannon (Right) : 1900-1999
    Invisible Cannon (Left) : 2000-2099
    Invisible Balloon : 2800-3199
    Custom Balloon : 2801-2899
    Invisible Rune : 3200-3299
    Invisible Valentine's Arrow : 3500-3599
    Invisible Apple : 3900-3999
    Invisible Sheep : 4000-4099
    Invisible Ice Plank : 4500-4599
    Invisible Choco Plank : 4600-4699
    Invisible Cloud : 5700-5799
    Invisible Bubble : 5900-5999
    Invisible Tiny Plank : 6000-6099
    Invisible Companion Crate : 6100-6199
    Invisible Stable Rune : 6200-6299
    Invisible Pufferfish : 6500-6599
    Arrow (repeats back from 0) : 65536



Key Codes

This is a list of characters that Lua supports, and their corresponding key codes. These are the numbers that the second argument of eventKeyboard returns and bindKeyboard requires.

0 - Left Arrow + A
1 - Up Arrow + W
2 - Right Arrow + D
3 - Down Arrow + S
8 - Backspace
9 - Tab
13 - Enter
16 - Shift
17 - Control
18 - Alt
19 - Pause
20 - Caps Lock
27 - Escape
32 - Spacebar
33 - Page Up
34 - Page Down
35 - End
36 - Home
37 - Left Arrow
38 - Up Arrow
39 - Right Arrow
40 - Down Arrow
45 - Insert
46 - Delete
48 - 0
49 - 1
50 - 2
51 - 3
52 - 4
53 - 5
54 - 6
55 - 7
56 - 8
57 - 9
65 - A
66 - B
67 - C
68 - D
69 - E
70 - F
71 - G
72 - H
73 - I
74 - K
75 - J
76 - L
77 - M
78 - N
79 - O
80 - P
81 - Q
82 - R
83 - S
84 - T
85 - U
86 - V
87 - W
88 - X
89 - Y
90 - Z
91 - Windows (Left)
92 - Windows (Right)
93 - Application Key
97 - 1 (Numbpad)
98 - 2 (Numbpad)
99 - 3 (Numbpad)
100 - 4 (Numbpad)
101 - 5 (Numbpad)
102 - 6 (Numbpad)
103 - 7 (Numbpad)
104 - 8 (Numbpad)
105 - 9 (Numbpad)
106 - * Asterix (Numbpad)
107 - + Plus (Numbpad)
109 - - Minus (Numbpad)
110 - \ Forward Slash (Numbpad)
112 - F1
113 - F2
114 - F3
115 - F4
116 - F5
117 - F6
118 - F7
119 - F8
120 - F9
121 - F10
122 - F11
123 - F12
144 - Numlock
145 - Scroll Lock
186 - ; Semicolon
187 - = Equals
188 - , Comma
189 - - Hyphen
190 - . Period
191 - / Forward Slash
192 - ` Apostrophe
219 - [ Left Square Bracket
220 - \ Backslash
221 - ] Right Square Bracket


Ground IDs

Here is a list of grounds and their corresponding IDs that a map's XML uses. Bare in mind that the tfm.enum.ground table has a list of all ground names and enums.

    wood : 0
    ice : 1
    trampoline : 2
    lava : 3
    chocolate : 4
    earth : 5
    grass : 6
    sand : 7
    cloud : 8
    water : 9
    stone : 10
    snow : 11
    rectangle : 12
    circle : 13
    invisible : 14
    web : 15
    yellowGrass : 17
    pinkGrass : 18
    acid : 19



Perm Categories

This section contains a list of all perm categories, for use in tfm.exec.newGame() and returned by tfm.get.room.xmlMapInfo.permCode. You can read the Map Rotation Guidelines thread for a more thorough explanation of each category.

P0 - Regular Rotation
P1 - Protected
P2 - Prime Perm (now redundant)
P3 - Prime Bootcamp
P4 - Shaman
P5 - Art
P6 - Mechanism & Cooperation
P7 - No-Shaman
P8 - Dual Shaman
P9 - Miscelleneous
P10 - Survivor
P11 - Vampire Survivor
P13 - Bootcamp
P17 - Racing
P18 - Defilante
P19 - Music (now redundant)
P21 - Vampire Survivor Testing
P22 - Tribe House
P23 - Bootcamp Testing
P24 - Dual Shaman Survivor
P32 - Dual Shaman Testing
P38 - Racing Testing
P41 - Module/Minigame
P42 - No-shaman Testing
P43 - Deleted (Inappropriate)
P44 - Deleted
P87 - Vanilla


Decoration IDs (outdated)

This is a list of decoration IDs for player-made maps from the map editor.

0 - Bush
1 - Tree
2 - Fern
3 - Blue Flower
4 - Sign
5 - Grass
6 - Coconut Tree
7 - Umbrella
8 - Sand Castle
9 - Shovel
10 - Sand Bucket
11 - Red Flower
12 - Thorns
13 - Fence
14 - Window
15 - Sofa
16 - Chair
17 - Table 1
18 - Vase of Flowers 1
19 - Sofa with 1 Place
20 - Vase of Flowers 2
21 - Roast Chicken
22 - Bookcase
23 - Poster
24 - Bed
25 - Radio
26 - Teddy
27 - Abajour
28 - Refrigerator
29 - Wardrobes
30 - TV with Stand
31 - Soda
32 - Vase of Flowers 3
33 - Nightstand
34 - Fund 1
35 - range of Halloween 1
36 - range of Halloween 2
37 - Broom
38 - Skeleton
39 - Halloween Poster
40 - Balloons Halloween
41 - Web with Spider
42 - Autumn Tree
43 - Bats
44 - Torch
45 - Fund Cemetery
46 - Torch 2
47 - About Grades
48 - Pumpkin 1
49 - Pumpkin 2
50 - Snowmouse
51 - Snowy Tree
52 - Cookies with Milk
53 - Garland
54 - Half Hanging
55 - Candle 1
56 - Band Christmas
57 - Christmas Tree
58 - Ice Stalactites
59 - Mistletoe
60 - Ball Christmas Tree
61 - Lights Natalinas
62 - Present
63 - Gifts
64 - Santa
65 - Loop
66 - Valentine's Umbrella
67 - Valentine's Chair
68 - Valentine's Table
69 - Valentine's Plate
70 - Valentine's Day Gift
71 - Candle 2
72 - Vase of Flowers 4
73 - Flower in Vase
74 - Ribbons with Hearts
75 - Balloon Heart
76 - Valentine's Window
77 - Heart Pendant
78 - Stones with Algae
79 - Algae 1
80 - Chest
81 - Starfish
82 - Shell
83 - Stones
84 - Stones with Algae 2
85 - Coral 1
86 - Coral 2
87 - Algae 2
88 - Broken Vase
89 - Big Screen
90 - Small Screen
91 - Alchemy Pot
92 - Objects of Alchemy 1
93 - Objects of Alchemy 2
94 - Bookshelf 2
95 - Piano
96 - Fireplace
97 - Candelebra
98 - Coffin
99 - Paper Holder
100 - Bottle with Substance 1
101 - Bottle with Substance 2
102 - Buff
103 - Barrel
104 - Table 2
105 - Chair 2
106 - Skull Mouse
107 - Cobweb 1
108 - Cobweb 2
109 - Cobweb 3
110 - Cobweb 4
111 - Cobweb 5
112 - Vampire Portrait
113 - Support with Fruits
114 - Mirror
115 - Tombstone of Elise
116 - Crucifix
117 - Background 2
118 - RIP Tombstone
119 - Toilet
120 - Bath & Curtains
121 - Sink/Faucet
122 - Mirror
123 - Pots & Pans
124 - Oven
125 - Rocking Chair
126 - Pot
127 - Bar Stool
128 - Kitchen Cabinet
129 - Kitchen Drawers
130 - Lava Lamp
131 - Bootcamp Checkpoint


Clothing IDs (outdated)

This is a list of all clothing and outfit IDs that tfm.get.room.playerList[playerName].look returns. Note that .look doesn't return the ID of a fur colour if the player is wearing one. You can also access these IDs by typing /infoshop ingame, then opening the shop window.

Furs
1 - Default Fur
2 - Cow Fur
3 - Siamese Cat Fur
4 - Rabbit Fur
5 - Cow Fur v2
6 - White-Brown Fur
7 - Black-White Cat Fur
8 - Tiger Fur
9 - Fox Fur
10 - Skeleton Costume
11 - Black-Grey Fur
12 - Black-Brown Fur
13 - Racoon Fur
14 - Snow Fur
15 - Red Panda
16 - Bunny Fur
17 - Zebra Fur
18 - Panda Fur
19 - Moon Fur
20 - Sun Fur
21 - Leopard Fur
22 - Deer Fur
23 - Skeleton Suit Fur
24 - White Leopard Fur
25 - Valentines Day Fur
27 - Toucan Fur
26 - St. Patrick's Day Fur
28 - Valentines Day Fur v2
29 - Ankh Fur
30 - 2014 FIFA World Cup Brazil Fur
31 - Giraffe Fur
32 - Cloud Fur

Head
0 - Nothing
1 - Helicopter Hat
2 - Straw Hat
3 - Helmet
4 - Top Hat
5 - Sun Hat
6 - Fedora
7 - Soldier Helmet
8 - Miner Hat
9 - General's Cap
10 - Beret
11 - Ninja Headband
12 - Horns
13 - Halo
14 - Viking Hat
15 - Bandit Mask
16 - Pirate Hat
17 - Witch Hat
18 - Riding Helmet
19 - Nurse Cap
20 - Police Cap
21 - Santa Hat
22 - Chef's Hat
23 - Bunny Ears
24 - Shower Cap
25 - Cow Boy Hat
26 - Lemon Hat
27 - Mandarin Hat
28 - Palm Hairstyle
29 - Uncle Sam Hat
30 - Marge Simpson Hair
31 - Mario Hat
32 - Super Sayen Hat
33 - Party Hat
34 - Asterix Hat
35 - Crown
36 - Dreadlocks
37 - Afro
38 - Pharaoh Hat
39 - Pumpkin Head
40 - Skull Mask
41 - Antlers
42 - Snowman Head
43 - Blonde Hair
44 - Campaign Hat
45 - Quiff Hair
46 - Coolie Hat
47 - Indian Headress
48 - Panama Hat
49 - Jester Hat
50 - Deadmau5 Hat
51 - Pilot Hat
52 - Megaman Hat
53 - Viewtiful Joe Hat
54 - Eggshell
55 - Cocked Hat
56 - Fish Hat
57 - Cat Hat
58 - Fish Bowl
59 - Bow
60 - Egg Basket
61 - Orange Hair Hat
62 - Luffy Hat
63 - Sonic Hair
64 - Turkish Hat
65 - Brunette Hair
66 - Link Hat
67 - Shark Hat
68 - Rainbow Dash's Mane
69 - Twillight Sparkle's Mane
70 - AppleJack's Mane
71 - Pinkie Pie's Mane
72 - Rarity's Mane
73 - Fluttershy's Mane
74 - Ushanka
75 - Coonskin Hat
76 - Paper Bag
77 - Sombrero
78 - Ash's Hat
79 - Sleep Cap
80 - Knife In Head
81 - Ghost Sheet
82 - Bat Wings
83 - Turban
84 - Christmas Tree
85 - Stocking
86 - Krissim's Cockatrice Head
87 - Banana Leaf Headdress
88 - Straw Panache
89 - Fisherman Hat
90 - Fishing Rod
91 - Shell
92 - Captain Cap
93 - Sailor Cap
94 - Chicken
95 - Cake Hat
96 - Shadow Hat
97 - Ice Hat
98 - Lion Hat
99 - Tiara
100 - Break
101 - Hokage Hat
102 - Spartan Helmet
103 - Candle Hat
104 - Ice Cube
105 - Frog Beanie
106 - Chick Hat
107 - Panda Beanie
108 - Graduate Hat
109 - Coconut Shell
110 - Underpants
111 - Ram Horns
112 - Wreath
113 - Beanie
114 - Angel Bear Hat
115 - Senhor do Bofim ribbons
116 - Comb
117 - Bell Hat
118 - Pschent
119 - Octopus

Eyes
0 - Nothing
1 - Sunglasses
2 - Heart Glasses
3 - Evil Sunglasses
4 - Monocle
5 - Eyepatch
6 - Tuba
7 - 3D Glasses
8 - Glasses
9 - Make Up
10 - Shutter Glasses
11 - Cyclops Glasses
12 - Kitsune Mask
13 - Disguise
14 - Carnival Mask
15 - Creeper Mask
16 - Japanese Headband
17 - Bandages
18 - Eyes Crazy
19 - Skull

Mouth
0 - Nothing
1 - Moustache
2 - Straw
3 - Bowtie
4 - Pipe
5 - Rose
6 - Green Lightsaber
7 - Red Lightsaber
8 - Knife
9 - Gas Mask
10 - Clover
11 - Fish Bones
12 - Pacifier
13 - Lollipop
14 - Surgeon Mask
15 - Pumpkin Basket
16 - Red Nose
17 - Buck Teeth
18 - Minecraft Pickaxe
19 - Strawberry
20 - Paint Brush
21 - Ice Lolly
22 - Bone
23 - Donut
24 - Vampire Teeth
25 - Chocolate
26 - Gingerbread Cookie
27 - Chocolate Box
28 - Bouquet
29 - Carrot
30 - Turkish Cake
31 - Bamboo
32 - Japanese Fan
33 - Diploma
34 - Sardine
35 - Candy
36 - Candy Cane

38 - Heart Shaped Lolipop
39 - Tambourine
40 - Beak
41 - Whistle

Ear
0 - Nothing
1 - Bow
2 - Spider Earring
3 - Bauble Earring
4 - Flower in Hair
5 - Headphones
6 - Heart Earring
7 - Poisson Earring
8 - Star Earring
9 - Cheese Earring
10 - Lenneth Helm
11 - Earmuffs
12 - Candy Cane Earring
13 - Rose Headband
14 - Anglish Bunny Headband
15 - Holldine Mask
16 - Fish Earring
17 - Spy Glass
18 - Hoop Earrings
19 - Rin Kagamine Hairband
20 - Frankstein Screws
21 - Arrow in the Head
22 - Skull Earring
23 - Frozen Ear
24 - Bunny Earring
25 - Frangipani

Neck
0 - Nothing
1 - Tri Coloured Scarf
2 - Bandana
3 - Beard
4 - Flowers
5 - Tie
6 - Green and Grey Scarf
7 - Bell Necklace
8 - Barrel Necklace
9 - Halloween Scarf
10 - Red Wreath
11 - Bowtie
12 - Umbrella
13 - Camera
14 - Striped Tie
15 - Medal
16 - Nazar

Hair
0 - Nothing
1 - Punk Hairstyle
2 - Windswept Hairstyle
3 - Normal Male Hair
4 - Fringe
5 - Chanel
6 - Applebloom's Mane
7 - Scootaloox's Mane
8 - Sweetiebell's Mane
9 - Hatsune Miku's Hairstyle
10 - Rin Kagamine's Hairstyle
13 - Golden Curls
14 - Forelock
16 - Levi's hair

Tail
0 - Nothing
1 - Diamond
2 - Star
3 - Bow
4 - Heart
5 - Easter Egg
6 - Sun
7 - Moon
8 - Some Chinese Coin Amulet
9 - Halloween Lantern
10 - Bell
11 - Rings
12 - Clover
13 - Berimbau
14 - Winged Scarab
15 - Football
16 - Seashell


Particle IDs

This section contains a list of particles and their associated IDs, for use in tfm.exec.displayParticle.

    whiteGlitter : 0
    blueGlitter : 1
    orangeGlitter : 2
    cloud : 3
    dullWhiteGlitter : 4
    heart : 5
    bubble : 6
    tealGlitter : 9
    spirit : 10
    yellowGlitter : 11
    ghostSpirit : 12
    redGlitter : 13
    waterBubble : 14
    plus1 : 15
    plus10 : 16
    plus12 : 17
    plus14 : 18
    plus16 : 19
    meep : 20
    redConfetti : 21
    greenConfetti : 22
    blueConfetti : 23
    yellowConfetti : 24
    diagonalRain : 25
    curlyWind : 26
    wind : 27
    rain : 28
    star : 29
    littleRedHeart : 30
    littlePinkHeart : 31
    daisy : 32
    bell : 33
    egg : 34
    projection : 35
    mouseTeleportation : 36
    shamanTeleportation : 37
    lollipopConfetti : 38
    yellowCandyConfetti : 39
    pinkCandyConfetti : 40



Titles

For a complete and updated list of titles, you can visit this page.


The updated Lua Tree can be found in this Lua Documentation topic.
Where can I learn Lua?

There are several places throughout the internet where Lua is well documented, and there are a lot of tutorials on learning to use it from being a total beginner.
  • Official Lua Website
  • Lua Reference Manual
  • Lua Users Wiki
  • Lua Unofficial FAQ
  • Learn Lua in 15 Minutes


What programs can I use to write Lua code?

The built in text box in the /lua window isn't particularly good for coding anything longer than a few lines. Tabs don't look right, it's not wide enough to see a lot of code and it doesn't have syntax highlighting, just to mention a few things. While any text editor will do, some external third party text editors or integrated development environments can do a good job of this.
  • Eclipse with Lua Development Tools or Lua Eclipse (IDE)
  • Lua Edit (IDE)
  • NotePad++
  • Sublime Text
  • ZeroBrane Studio (IDE)


Collaborative Text Editors

If you wish to collaborate and code alongside someone else in realtime, there are several tools available to do just that.
  • CodeShare - Has Lua syntax highlighting.
  • Google Docs
  • EtherPad - Collaborative text-editing site running on the open source EtherPad software.
  • CollabEdit
  • Sync.in


Lua Minifiers

As there is a 64k character limit imposed when running code with the Module API, any long script may have to be minified. Minification makes the code smaller through practises such as removing linebreaks, whitespace, renaming functions and local variables to shorter alternatives, and the such to help reduce the overall size.
  • Squish
  • Mothereffin Lua Minifier (web based)


Miscellaneous Resources

  • Lua for Windows (Windows) - Lua interpreter.
  • CodePad (Web) - Lua interpreter.
  • ComputerCraft - A modification for MineCraft that adds computers to the game where you can program things in Lua.

Click here to see the most updated change logs of the Lua API.


  • 25/03/2013 - Version 0.2
    • New: tfm.exec.setAutoNewGame()
    • New: tfm.get.misc.apiVersion
    • New: tfm.enum.shamanObject
    • Change: eventPlayerDisconnected() event renamed to eventPlayerLeft()
    • Change: moveShamanObject() function renamed to moveObject()
    • Change: removeShamanObject() function renamed to removeObject()
    • Change: tfm.exec.movePlayer() and tfm.exec.moveObject() can now set offsets.
  • 26/03/2013 - Version 0.3
    • New: tfm.exec.disableAutoScore()
    • New: eventEmotePlayed()
    • New: tfm.enum.emote
    • New: eventSummoningStart()
    • New: eventSummoningEnd()
    • New: EventSummoningEnd()
    • New: system.exit()
    • Change: tfm.exec.newGame() can now play a random map from a perm category.
    • Change: tfm.exec.bindKeyboard() can now unbind keys.
    • Change: tfm.get.room.playerList now displays a player's X and Y co-ordinates.
    • Change: eventPlayerVampire() fixed.
    • Change: eventPlayerWon() is no longer sent before eventNewGame()
    • Change: tfm.exec.addShamanObject creating ghost objects fixed.
    • Change: tfm.exec.chatMessage() can now send messages to individual players.
    • Change: eventLoop() returns the current time of the round, and time passed since the round started.
    • Change: Objects spawned by a shaman are now added to tfm.get.room.objectList
  • 27/03/2013 - Version 0.4
    • New: debug.disableEventLog()
    • New: tfm.exec.setRoomMaxPlayers()
    • New: eventChat()
    • Change: Scripts can now be 30,000 characters maximum.
    • Change: eventLoop() occurs every 500 milliseconds.
    • Change: eventKeyboard() gives player's X and Y co-ordinates.
    • Change: Vampire functions and events fixed.
  • 27/03/2013 - Modules announced publicly.
  • 03/04/2013 - Version 0.5
    • New: tfm.exec.disableAutoTimer()
    • New: system.newTimer()
    • New: system.removeTimer()
    • New: system.loadFile()
    • New: system.saveFile()
    • New: eventFileLoaded()
    • New: eventFileSaved()
    • New: pcall()
    • New: xpcall()
    • Change: Scripts can now only be ran in rooms starting with # or *#, whereas previously they had to have "debuglua" in the room name.
    • Change: tfm.exec.setRoomMaxPlayers() fixed.
  • 04/04/2013 - Version 0.6
    • New: system.disableChatCommandDisplay()
    • New: tfm.get.room.name
    • New: tfm.get.room.community
    • New: tfm.exec.explosion()
    • Change: tfm.get.room.objectList returns the X and Y co-ordinates and angle of each shaman object, which is updated by the sync.
    • Change: eventChat() renamed to eventChatCommand()
    • Change: tfm.exec.bindKeyboard() allows you to bind keys being pressed or keys being released separately.
    • Change: eventKeyboard() returns whether the key is being pressed or released.
    • Change: Players don't get the "Your message is the same." warning when typing !commands in a Lua room.
  • 05/04/2013 - Version 0.7
    • New: Modules approved by administrators will be turned official and not have to be run manually by someone on the module team.
    • New: tfm.exec.setNameColor()
    • Change: Module room names need at least 5 characters.
  • 07/04/2013 - Version 0.8
    • New: /module command.
    • New: Function names are displayed in error messages.
    • Change: Fixed a bug where tfm.exec.disableAutoNewGame() is executed and a second mouse joins the room.
    • Change: Fixed timers.
    • Change: When an object is moved, sleeping is disabled.
    • Change: Player's nickname colors are now removed when they change room.
    • Change: tfm.exec.disableChatCommandDisplay() only needs the first word.
  • 08/04/2013 - Version 0.9
    • New: Players can earn 1 shop cheese every 2 minutes in official modules.
    • Change: Fixed character encoding.
    • 03/09/2013 Version 0.11
    • Change: tfm.get.room.playerList returns player's tribe names.
    • Change: tfm.exec.newGame() works with no parameters again.
    • Change: Context is reset when a module is reloaded (all players keybindings and mouse bindings, UI, etc. disappears).
    • Change: Order of arguments in the ui functions.
  • 26/09/2013 - Modules released to be used in tribe houses with the /lua command.
  • 04/10/2013 - Version 0.12
    • New: tfm.exec.addImage()
    • New: tfm.exec.removeImage()
  • 27/11/2013 - Version 0.14
    • New: system.loadPlayerData()
    • New: system.savePlayerData()
    • New: eventPlayerDataLoaded()
    • Change: Shamans created with tfm.exec.setShaman now have their passive skills.
    • Change: tfm.exec.snow() can now have custom time and power.
    • Change: ui.addPopup arguments altered.
    • Change: ui.addTextArea arguments altered.
    • 02/12/2013 Version 0.15
    • New: tfm.exec.displayParticle()
    • Change: tfm.exec.addImage() now has fixed layers.
  • 14/12/2013 - Version 0.16
    • Change: system.savePlayerData() can now save up to 1,000 characters per player.
    • 21/12/2013 Version 0.17
    • Change: All scripts aren't handled by a single thread now so when one crashes the entire bulle's modules aren't crashed.
    • Change: Official module errors now give the script author the last line number executed.
  • 26/01/2014 - Player Data granted to everyone on the team.
  • 09/02/2014 - Applications opened!
  • 23/04/2014 - XMLs loaded with Lua now have no maximum character size, height, width, or ground/decoration limits when loaded as a vanilla map.


Dernière modification le 1617727860000
Shamousey
« Consul »
1411071240000
    • Shamousey#0095
    • Profil
    • Derniers messages
    • Tribu
#2
  4

Events are functions that are triggered when a certain thing happens ingame. This is usually when a player performs a certain action, a certain event is called by the code itself, or one of many other things.

http://i.imgur.com/yQght.png


eventChatCommand(playerName, message)

Trigger: This event triggers when a player types a message into the room's chat that begins with a ! character.

Arguments:
  • playerName (string) - The username of the player that typed a command.
  • message (string) - The command that the user typed. Doesn't include the "!" character.


Example:
Code Lua

1
2
3
function eventChatCommand(playerName, message)
print(playerName .. " typed the command: " .. message)
end


eventChatMessage(playerName, message)

Trigger: This event triggers when a player types a message into the room's chat.

Arguments:
  • playerName (string) - The username of the player that typed a message.
  • message (string) - The message that the user typed.


Example:
Code Lua

1
2
3
function eventChatMessage(playerName, message)
print(playerName .. " said: " .. message)
end


eventColorPicked(colorPickerId, playerName, color)

Trigger: This event triggers when a player selects a color in a color picker interface.

Arguments:
  • colorPickerId (integer) - The ID of the color picked in which the color has been selected.
  • playerName (string) - The username of the player who selected the color.
  • color (integer) - The color code selected by the player. It will be -1 if no color has been selected.


Example:
Code Lua

1
2
3
4
function eventColorPicked(colorPickerId, playerName, color)
print(playerName .. " selected the color " .. string.format("#%x", color) .. " in the color picker of ID " .. colorPickerId .. ".")
end
ui.showColorPicker(1, nil, nil, "Pick a color")


eventEmotePlayed(playerName, emoteID, emoteParameter)

Trigger: This event triggers when a player uses an emote.

Arguments:
  • playerName (string) - The username of the player that used an emote.
  • emoteID (integer) - The ID of the emote that the player has used. See the "Enums and IDs" section of this thread for a full list of IDs that can be returned and what emotes they're associated with.
  • emoteParameter (string?) - The country code of the flag when the emote that the player used is flag.


Example:
Code Lua

1
2
3
4
5
6
7
function eventEmotePlayed(playerName, emoteID, emoteParameter)
if emoteID == tfm.enum.emote.dance then
print(playerName .. " is dancing!")
elseif emoteID == tfm.enum.emote.flag then
print(playerName .. " likes the " .. tostring(emoteParameter) .. " flag!")
end
end


eventFileLoaded(fileID, fileData)

Trigger: This event triggers when a file is successfully loaded from the system.loadFile() function.

Arguments:
  • fileID (integer) - The ID of the file loaded.
  • fileData (string) - The contents of the file loaded.


Example:
Code Lua

1
2
3
4
function eventFileLoaded(fileID, fileData)
print(fileID .. " contains the following data: " .. fileData)
end
system.loadFile(1)


eventFileSaved(fileID)

Trigger: This event triggers when a file has finished saving from the system.saveFile() function.

Arguments:
  • fileID (integer) - The ID of the file that has been saved.


Example:
Code Lua

1
2
3
4
function eventFileSaved(fileID)
print("File " .. fileID .. " has been successfully saved.")
end
system.saveFile("Text", 1)


eventKeyboard(playerName, keyCode, down, xPlayerPosition, yPlayerPosition)

Trigger: This event triggers when a player presses a key on their keyboard that has been bound with tfm.exec.bindKeyboard().

Arguments:
  • playerName (string) - The username of the player that pressed a key.
  • keyCode (integer) - The key code that has been pressed.
  • down (boolean) - If true, the key has been pressed down. If false, the key has been released.
  • xPlayerPosition (integer) - The X coordinate the player is at as they press the key.
  • yPlayerPosition (integer) - The Y coordinate the player is at as they press the key.


Example:
Code Lua

1
2
3
4
5
6
function eventKeyboard(playerName, keyCode, down, xPlayerPosition, yPlayerPosition)
if key == 32 then
print(playerName .. " pressed the space key!")
end
end
tfm.exec.bindKeyboard("Tigrounette#0001", 32, true, true)


eventLoop(currentTime, timeRemaining)

Trigger: This event triggers every 500ms.

Arguments:
  • currentTime (integer) - The number of milliseconds since the current round has started.
  • timeRemaining (integer) - The number of milliseconds left until the current round will be over.


Example:
Code Lua

1
2
3
function eventLoop(timeRemaining, timeRemaining)
print("This will spam you every half a second.")
end


eventMouse(playerName, xMousePosition, yMousePosition)

Trigger: This event triggers when a player clicks on the screen.

Arguments:
  • playerName (string) - The username of the player that clicked.
  • xMousePosition (integer) - The X coordinate the player clicked at.
  • yMousePosition (integer) - The Y coordinate the player clicked at.


Example:
Code Lua

1
2
3
4
function eventMouse(playerName, xMousePosition, yMousePosition)
print(playerName .. " clicked the screen at X:" .. xMousePosition .. " Y:" .. yMousePosition .. ".")
end
system.bindMouse("Tigrounette#0001", true)


eventNewGame()

Trigger: This event triggers when a new map is loaded.

Arguments:
  • None.


Example:
Code Lua

1
2
3
function eventNewGame()
print("A new round has just started.")
end


eventNewPlayer(playerName)

Trigger: This event triggers when a player joins the room.

Arguments:
  • playerName (string) - The name of the player that joined the room.


Example:
Code Lua

1
2
3
function eventNewPlayer(playerName)
print(playerName .. " joined the room!")
end


eventPlayerDataLoaded(playerName, data)

Trigger: This event triggers when a player's data is completed loading from system.loadPlayerData(). Returns "#" if the player's data is not yet loaded on the server.

Arguments:
  • playerName (string) - The name of the player who's data was loaded.
  • data (string) - The data that was loaded.


Example:
Code Lua

1
2
3
function eventPlayerDataLoaded(playerName, data)
print(playerName .. " has the following data associated with them: " .. data)
end


eventPlayerBonusGrabbed(playerName, bonusId)

Trigger: This event triggers when a player touches a defilante token of type 0 (+1 point).

Arguments:
  • playerName (string) - The username of the player who gathered cheese.
  • bonusId (integer) - The ID of the token that the player has touched.


Example:
Code Lua

1
2
3
4
function eventPlayerBonusGrabbed(playerName, bonusId)
print(playerName .. " touched the token of ID" .. bonusId .. "!")
end
tfm.exec.addBonus(0, 100, 350, 15)


eventPlayerDied(playerName)

Trigger: This event triggers when a player dies. It also gets ran when a player leaves the room.

Arguments:
  • playerName (string) - The name of the player who died.


Example:
Code Lua

1
2
3
function eventPlayerDied(playerName)
print(playerName .. " had an unfortunate death.")
end


eventPlayerGetCheese(playerName)

Trigger: This event triggers when a player collects cheese.

Arguments:
  • playerName (string) - The username of the player who gathered cheese.


Example:
Code Lua

1
2
3
function eventPlayerGetCheese(playerName)
print(playerName .. " gathered cheese!")
end


eventPlayerLeft(playerName)

Trigger: This event triggers when a player leaves the room.

Arguments:
  • playerName (string) - The username of the player who left the room.


Example:
Code Lua

1
2
3
function eventPlayerLeft(playerName)
print(playerName .. " left the room :(")
end


eventPlayerMeep(playerName, xPosition, yPosition)

Trigger: This event triggers when a player meeps.

Arguments:
  • playerName (string) - The name of the player who meeped.
  • xPosition (integer) - The X coordinate the player is at as they meep.
  • yPosition (integer) - The Y coordinate the player is at as they meep.


Example:
Code Lua

1
2
3
4
function eventPlayerMeep(playerName, xPosition, yPosition)
print(playerName .. " meeped at X:" .. xPosition .. " Y:" .. yPosition)!")
end
tfm.exec.giveMeep("Tigrounette#0001")


eventPlayerRespawn(playerName)

Trigger: This event triggers when a player respawns, either through bootcamp respawning, the shaman ambulance skill, or tfm.exec.respawnPlayer().

Arguments:
  • playerName (string) - The name of the player who respawned.


Example:
Code Lua

1
2
3
function eventPlayerRespawn(playerName)
print(playerName .. " is now alive again!")
end


eventPlayerVampire(playerName, vampire)

Trigger: This event triggers when a player becomes a vampire.

Arguments:
  • playerName (string) - The username of the player who becomes a vampire.
  • vampire (string?) - The username of the player who infects @playerName. Will be nil if @playerName became a vampire automatically.


Example:
Code Lua

1
2
3
function eventPlayerVampire(playerName, vampire)
print(playerName .. " got infected by " .. tostring(vampire) .. " and is now a vampire!")
end


eventPlayerWon(playerName, timeElapsed, timeElapsedSinceRespawn)

Trigger: This event triggers when a player enters the hole with cheese.

Arguments:
  • playerName (string) - The username of the player who entered the hole.
  • timeElapsed (integer) - The amount of milliseconds that have passed since the start of the current round.
  • timeElapsedSinceRespawn (integer) - The amount of milliseconds that have passed since the player last respawned.


Example:
Code Lua

1
2
3
function eventPlayerWon(playerName, timeElapsed)
print(playerName .. " got to the hole in " .. (timeElapsed/1000) .. " seconds.")
end


eventPopupAnswer(popupID, playerName, answer)

Trigger: This event triggers when a player submits an answer in a popup.

Arguments:
  • popupID (string) - The ID of the popup that the answer came from.
  • playerName (integer) - The username of the player who answered the popup.
  • answer (string) - The answer the popup was given. For popups of ID 1, the answer will be "yes" or "no".


Example:
Code Lua

1
2
3
function eventPopupAnswer(popupID, playerName, answer)
print(playerName .. " answered a popup with the ID " .. popupID .. " with the response: " .. answer)
end


eventSummoningCancel(playerName)

Trigger: This event triggers when a shaman stops summoning an object.

Arguments:
  • playerName (string) - The username of the shaman who cancelled the summoning of an object.


Example:
Code Lua

1
2
3
function eventSummoningCancel(playerName)
print(playerName .. " stopped summoning an object.")
end


eventSummoningEnd(playerName, objectType, xPosition, yPosition, angle, xSpeed, ySpeed, objectData)

Trigger: This event triggers when a shaman has successfully finished summoning a shaman object.

Arguments:
  • playerName (string) - The username of the shaman who spawned the object.
  • objectType (integer) - The object type ID of the object spawned.
  • xPosition (integer) - The X coordinate of where the object was spawned.
  • yPosition (integer) - The Y coordinate of where the object was spawned.
  • angle (integer) - The angle the object was spawned at.
  • objectData (table) - A table containing information related to the object spawned. Contains all data from tfm.get.room.objectList of this object.
    • id (integer) - The ID of the object spawned, for use in tfm.exec.addImage() and tfm.exec.removeObject().
    • type (integer) - The ID of the type of object spawned. You can see a full list of types in the "Enums and IDs" section of this thread.
    • baseType (integer) - The ID of the base type of the object spawned. If it is a custom shaman object that was spawned, this value will contain the ID of the type of the default object.
    • x (integer) - The X coordinate the object was spawned at.
    • y (integer) - The Y coordinate the object was spawned at.
    • vx (integer) - The X velocity the object has at time of spawning. This is only useful for cannons.
    • vy (integer) - The Y velocity the object has at time of spawning. This is only useful for cannons.
    • angle (integer) - The rotation of the object spawned, in degrees.
    • ghost (boolean) - If true, the object spawned is ghosted. If false, it's a regular object.
    • colors (table) - List of custom color of the object spawned.


Example:
Code Lua

1
2
3
4
5
function eventSummoningEnd(playerName, objectType, xPosition, yPosition, angle, objectData)
if objectType == 10 then
print(playerName .. " has spawned an anvil with angle:" .. angle .. " at X:" .. xPosition .. " Y:" .. yPosition .. ".)
end
end


eventSummoningStart(playerName, objectType, xPosition, yPosition, angle)

Trigger: This event triggers when a shaman starts summoning a shaman object.

Arguments:
  • playerName (string) - The username of the shaman who started summoning an object.
  • objectType (integer) - The ID of the object type that was started spawning.
  • xPosition (integer) - The X coordinate the object started spawning at.
  • yPosition (integer) - The Y coordinate the object started spawning at.
  • angle (integer) - The angle of the shaman object being spawned.


Example:
Code Lua

1
2
3
4
5
function eventSummoningStart(playerName, objectType, xPosition, yPosition, angle)
if objectType == 10 then
print(playerName .. " is spawning an anvil at X:" .. xPosition .. " Y:" .. yPosition)
end
end


eventTextAreaCallback(textAreaID, playerName, callback)

Trigger: This event triggers when a player clicks a text within a <a> </a> tag in a text area.

Arguments:
  • textAreaID (integer) - The ID of the text area clicked on.
  • playerName (string) - The username of the player who clicked on the text area.
  • callback (string) - The name of the event that was clicked on. This is the "callback" part of the following example anchor tag clicked on <a href="event:callback">Text</a>


Example:
Code Lua

1
2
3
4
function eventTextAreaCallback(textAreaID, playerName, callback)
print(playerName .. " clicked on Text Area " .. textAreaID .. " on the event '" .. callback .. "'.")
end
ui.addTextArea(1, "<a href='event:example'>Example Text</a>", nil, 375, 175, 50, 50)



Dernière modification le 1633655340000
Shamousey
« Consul »
1411071300000
    • Shamousey#0095
    • Profil
    • Derniers messages
    • Tribu
#3
  9
Functions (also known as procedures, subroutines or methods in other programming languages) are sections of code that perform a specific task. The Module API has a slew of different functions that work in Transformice, which allow modules to actually do anything.

http://i.imgur.com/yQght.png



print(text)

Effect: The text here will be displayed to the person that runs the script. If the "#lua" chat tab is open then it'll be displayed there.

Arguments:
  • text (string) - The text that is displayed.


Example:
Code Lua

1
print("This is example text.")


debug.disableEventLog(disabled)

Effect: Disables the event log from displaying in the chat log.

Note: This function is now redundant as its primary purpose was to stop functionality that is now disabled by default. In the past, every time an event was called it'd display a line in the chat showing which event.

Arguments:
  • disabled (boolean) - If true, events won't be displayed in the Lua log. If false, events will be displayed in the Lua log.


Example:
Code Lua

1
debug.disableEventLog(true)


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)


system.bindMouse(playerName, bind)

Effect: Binds a player's cursor to allow it to call eventMouse(). If a player's cursor is bound, the event will get executed when they click on the game screen.

Arguments:
  • playerName (string) - The player whose cursor clicks will be bound.
  • bind (boolean) - If true, cursor clicks will be bound to the player. If false, they won't be bound, or will be unbound if previously bound to the player.


Example:
Code Lua

1
system.bindMouse("Tigrounette#0001", true)


system.disableChatCommandDisplay(command, hidden)

Effect: Disables chat commands starting with the ! character from displaying in the public chat.

Arguments:
  • command (string?) - The command to be hidden. Any text after the first spacebar character will also be hidden. For example, if the command "help" is disabled from displaying in the chat, "!help us please" won't be displayed. If this value is nil, all commands will be hidden.
  • hidden (boolean) - If true, the command will be hidden in public chat. If false, the command will be displayed in public chat as usual.


Example:
Code Lua

1
system.disableChatCommandDisplay("help", true)


system.exit()

Effect: Deactivates the currently running script.

Arguments:
  • None.


Example:
Code Lua

1
system.exit()


system.giveEventGift(playerName, gift)

Effect: If this function is executed is an event approved by the administrators, this will give the player the appropriate reward for completing it. This was previously seen in the Lua events such as the Toy Factory, Grim's Mansion and Children's Day, where you could unlock a special title for completing a certain task on each of the maps. For more information about Lua events, see this post.

This function is only available to members on the Module Team.

Arguments:
  • playerName (string) - The username of the player to be given the gift.
  • gift (string) - The ID of the gift to give to the player.


Example:
Code Lua

1
system.giveEventGift("Tigrounette#0001", "titre_enfant_2014")


system.loadFile(fileNumber)

Effect: Loads a file associated with the account that executed the script. Triggers the eventFileLoaded() function. Usage is limited to once every 1 minute.

This function is only available to members on the Module Team.

Arguments:
  • fileNumber (integer) - The number of the file to load. Can be between 0 and 99.


Example:
Code Lua

1
system.loadFile(1)


system.loadPlayerData(playerName)

Effect: Loads a string with custom information about a player that was previously saved. Troggers the eventPlayerDataLoaded() function.

This function is only available to members on the Module Team.

Arguments:
  • playerName (string) - The username of the player whose data will be loaded.


Example:
Code Lua

1
system.loadPlayerData("Tigrounette#0001")


system.newTimer(callback, time, loop, arg1, arg2, arg3, arg4)

Effect: Creates a timer that will run for a specific amount of time before executing a function or rerunning itself. Returns the timer's ID.

This function is only available to members on the Module Team. This is due to the fact timers are very intensive on server resources and need to be used in moderation.

Arguments:
  • callback (function) - The function that will be executed. The first argument of this function is the timer's ID, for use in system.removeTimer.
  • time (integer) - The amount of time (in milliseconds, minimum 1000) before the timer will execute the function from the first argument.
  • loop (boolean) - If true the timer will loop after it's ended until stopped by other means. If false the timer will run once and then close itself.
  • arg1, arg2, arg3, arg4 (object) - These arguments will be passed to the function referred to as "callback" above, as the second to fifth arguments.


Example:
Code Lua

1
2
3
system.newTimer(function()
print("This message will print once 10 seconds after the function is executed.")
end, 10000, false)


system.removeTimer(timerID)

Effect: Removes a timer.

This function is only available to members on the Module Team.

Arguments:
  • timerID (integer) - The ID of the timer to be removed.


Example:
Code Lua

1
2
3
4
5
6
7
8
9
counter = 0
id = system.newTimer(function()
print("This message will print once every second for ten times.")

counter = counter + 1
if counter == 10 then
system.removeTimer(id)
end
end, 1000, true)


system.saveFile(data, fileNumber)

Effect: Save a file associated with the account of the player who executed the script. Usage is limited to once every 1 minute.

This function is only available to members on the Module Team. This is due to the fact that files can take up a lot of storage space on the server very quickly.

Arguments:
  • data (string) - The string to be saved. Can be 65k characters maximum.
  • fileNumber (integer) - The number of the file to save to. Can be between 0 and 99.


Example:
Code Lua

1
system.saveFile("Example string to save.", 1)


system.savePlayerData(playerName, data)

Effect: Saves custom information about a player. Will only work if the player is in the room.

This function is only available to members on the Module Team. This is due to the fact that saving a lot of strings for different people can take up a lot of storage space on the server very quickly.

Arguments:
  • playerName (string) - The username of the player whose data will be replaced with the string in the second argument.
  • data (string) - The custom information that will be saved for this player. Can be 5k characters maximum.


Example:
Code Lua

1
system.savePlayerData("Tigrounette#0001", "Example string to save.")


tfm.exec.addBonus(type, xPosition, yPosition, id, angle, visible, targetPlayer)

Effect: Adds a defilante token to the map. Triggers the eventPlayerBonusGrabbed() function when someone grabs it and it's type is 0 (+1 point).

Arguments:
  • type (integer) - Bonus type. (see tfm.enum.bonus)
  • xPosition (integer) - The X position that the token will be placed at.
  • yPosition (integer) - The Y position that the token will be placed at.
  • id (integer) - The ID of the token to be used in eventPlayerBonusGrabbed.
  • angle (integer) - The angle in which the token will be when placed in the map.
  • visible (boolean) - Whether the token should be visible..
  • targetPlayer (string) - The player who the token will be displayed to. If this argument is nil, it will be displayed to all players in the room.


Example:
Code Lua

1
tfm.exec.addBonus(0, 100, 350, 10, 45, true, "Tigrounette#0001")


tfm.exec.addConjuration(xPosition, yPosition, time)

Effect: Spawns a block of conjuration, which is a 10 by 10 pixel grey object fixed in place, seen in some vanilla maps as the shaman can spawn it. Note that the coordinates used in this function are 1/10th the size of a regular map due to their size. They do not spawn offscreen or past X:800 on scrolling maps.

Arguments:
  • xPosition (integer) - The X position that the conjuration will be spawned at. Can be between 1 and 80.
  • yPosition (integer) - The Y position that the conjuration will be spawned at. Can be between 1 and 40.
  • time (integer) - The amount of time, in milliseconds, that the conjuration will stay on the screen before disappearing.


Example:
Code Lua

1
tfm.exec.addConjuration(40, 20, 10000)


tfm.exec.addImage(imageName, target, xPosition, yPosition, targetPlayer, scaleX, scaleY, angle, alpha, anchorX, anchorY)

Effect: Displays an image. Returns the ID of the image.

http://i.imgur.com/AeLSILk.png

Arguments:
  • imageName (string) - The file name of the image, including the extension. If your image is given as http://images.atelier801.com/174042eda4f.png, the code you need to use should be 174042eda4f.png
  • target (string) - The part of the map, or dynamic object that the image will be attached to. Each target has a special character that's used as a prefix for the ID or name attached to.

    • #mobileID - A shaman object. The ID can be obtained through eventSummoningEnd(), tfm.get.room.objectList, or returned from tfm.exec.addShamanObject().
    • $playerName - A player in the room, their mouse graphic will stay and this image will be appended relative to it.
    • %playerName - A player in the room, their mouse graphic will be removed and this image will replace it completely.
    • ?backgroundLayerDepth - This image will appear in background and is not fixed to the mouse's camera
    • :fixedLayerDepthBehindInterface - This image will appear behind all interfaces and is fixed to the mouse's camera
    • !foregroundLayerDepth - This image will appear in foreground and is not fixed to the mouse's camera
    • &fixedLayerDepthFrontInterface - This image will appear in front of all interfaces and is fixed to the mouse's camera
    • _groundLayerDepth - This image will appear on the specified Z layer depth of a ground and is not fixed to the mouse's camera
  • xPosition (integer) - The X coordinate that the top-left of the image will be displayed at relative to the target.
  • yPosition (integer) - The Y coordinate that the top-left of the image will be displayed at relative to the target.
  • targetPlayer (string) - The player to display the image to. If this argument is nil, the image will be displayed to all players in the room.
  • scaleX (number) - The X (width) scale of the image
  • scaleY (number) - The Y (height) scale of the image
  • angle (number) - The angle of the image (in radians)
  • alpha (number) - The image opacity
  • anchorX (number) - The horizontal anchor in which the image's angle will use. (from -1 to 1, 0.5 being the center)
  • anchorY (number) - The vertical anchor in which the image's angle will use. (from -1 to 1, 0.5 being the center)


Example:
Code Lua

1
tfm.exec.addImage("1771d446c03.png", "%Tigrounette#0001", -21, -30, 0.9, 0.9, 45, 0.8, 0.5, 0.5)


tfm.exec.addJoint(id, ground1, ground2, jointDefinition)

Effect: Creates a map editor joint, linking two grounds/physic objects together with special properties or creating a colored line. For more information about joints, see this post.

http://i.imgur.com/FD8UW1Z.png

Arguments:
  • id (integer) - The ID of the joint created.
  • ground1 (integer) - The first ground to link.
  • ground2 (integer) - The second ground to link.
  • jointDefinition (table) - An associative array with all of the information needed for a joint, the available keys in the table are below but they're not all required.

    • type (integer) - 0 is a distance joint, 1 is a prismatic joint, 2 is a pulley joint, 3 is a revolute joint.
    • point1, point2, point3, point4 (string) - The coordinates of each used ground's center point in a string separated with a comma, such as "x, y" or "400, 200".
    • frequency (float) - The joint's frequency ratio.
    • damping (float) - The joint's damping ratio.
    • axis (string) - The coordinates of the axis the joint will move along in a string separated with a comma, such as "x, y" or "400, 200".
    • angle (integer) - The rotation of the joint, in degrees.
    • limit1, limit2 (float) - Prismatic and revolute joints' translation and rotation limits.
    • forceMotor (float) - Prismatic and revolute joints' moving motor ratio.
    • speedMotor (float) - Prismatic and revolute joints' moving speed ratio.
    • ratio (float) - Revolute joints' ratio.
    • line (integer) - The width of the line drawn between the two points.
    • color (integer) - The color of the line drawn between the two points.
    • alpha (float) - The opacity of the line drawn between the two points, 1 is opaque and 0 is transparent.
    • foreground (boolean) - If true, the line drawn between the two points will be in the foreground of the map.


Note: On the map editor, players can also add a 'lua="id"' property in a joint definition in the XML code to be able to interact with it with Lua code.

Example:
Code Lua

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
--As a physic object is needed for the joint to connect to, this will ensure there's one by creating it.
tfm.exec.addPhysicObject(5, 400, -600, {type=0, width=10, height=10, foreground=true, friction=0.3, restitution=0, dynamic=false, miceCollision=true, groundCollision=true})

local x1, y1 = 200, 200
local x2, y2 = 600, 200
tfm.exec.addJoint(1, 5, 5, {
type = 0,
point1 = x1 .. ", " .. y1,
point2 = x2 .. ", " .. y2,
frequency = 10,
damping = 0.2,
line = 10,
color = 0xFF6600,
alpha = 1,
foreground = true
})


tfm.exec.addPhysicObject(id, xPosition, yPosition, groundDefinition)

Effect: Creates a physic object with custom properties. In the map editor, this is known as a ground.

http://i.imgur.com/BzmIZVW.png

Arguments:
  • id (integer) - The ID of the physic object created.
  • xPosition (integer) - The X coordinate the center of the physic object will be spawned at.
  • yPosition (integer) - The Y coordinate the center of the physic object will be spawned at.
  • groundDefinition (table) - An associative array with all of the information needed for a physic object, the available keys in the table are below but they're not all required.

    • type (integer) - The ID of ground type. For a full list of valid types, check the "Ground IDs" part in the "Enums and IDs" section of this thread.
    • width (integer) - The width the physic object will be.
    • height (integer) - The height the physic object will be.
    • foreground (boolean) - If true, the physic object will be displayed in the foreground of the map. If false, it will be in the background.
    • friction (float) - The friction of the physic object, which is also needed for walljumping, 0 will act like ice and 20 will act like chocolate.
    • restitution (float) - How bouncy the physic object is, 0 won't be bouncy at all and 1 will bounce objects up to the same height they fell from.
    • angle (integer) - The rotation of the physic object in degrees.
    • color (integer) - The color of the physic object, only used if the type is a rectangle or circle.
    • miceCollision (boolean) - If true, the physic object will collide with mice. If false, it will pass through mice.
    • groundCollision (boolean) - If true, the physic object will collide with other physic objects. If false, it will pass through other physic objects.
    • dynamic (boolean) - If true, the physic object will be dynamic and fall with gravity. If false, it will be in a fixed position on the map.
    • fixedRotation (boolean) - If true, the physic object won't rotate at all. If false, it will fall in all directions like any regular object. Only used if the ground is dynamic.
    • mass (integer) - How heavy the object is. Only used if the ground is dynamic.
    • linearDamping (float) - The higher this number, the slower the object will fall to gravity. Only used if the ground is dynamic.
    • angularDamping (float) - The higher this number, the slower the object will rotate sideways. Only used if the ground is dynamic.


Example:
Code Lua

1
2
3
4
5
6
7
8
tfm.exec.addPhysicObject(1, 800, 400, {
type = 0,
restitution = 0.2,
friction = 0.3,
width = 200,
height = 50,
groundCollision = true
})


tfm.exec.addShamanObject(id, xPosition, yPosition, angle, xSpeed, ySpeed, ghost)

Effect: Spawns a shaman object on the map. Returns the ID of the shaman object spawned, for use in tfm.exec.addImage(), tfm.exec.moveObject() and tfm.exec.removeObject() Note: While anchors are usually considered shaman objects, they can't be spawned with this function. Similarly, some other shaman objects may not spawn correctly and will just display a graphic at coordinates 0, 0. Cannons cannot have their default spawning velocity changed by this function.

http://i.imgur.com/r5mlvmW.png

Arguments:
  • id (integer) - The ID of the type of shaman object to spawn. Check the "Enums and IDs" section of this thread for a complete list of IDs to use here.
  • xPosition (integer) - The X coordinate that the center of the object will be spawned at.
  • yPosition (integer) - The Y coordinate that the center of the object will be spawned at.
  • angle (integer) - The rotation of the object as it's spawned, in degrees.
  • xSpeed (integer) - The horizontal velocity that the object will have at the moment it's spawned.
  • ySpeed (integer) - The vertical velocity that the object will have at the moment it's spawned.
  • ghost (boolean) - If true, the object will be ghosted and not collide with mice. If false, the object will be a regular one.


Example:
Code Lua

1
tfm.exec.addShamanObject(10, 400, 200, 45, 50, -20, false)


tfm.exec.attachBalloon(playerName, isAttached, colorType, ghost)

Effect:  Attaches a balloon to player.

Arguments:
  • playerName (string) - The username of the player to have a balloon attached to them.
  • isAttached (boolean) - Whether the balloon should be attached or detached from the player.
  • colorType (integer) - The color type of the balloon [1-4]
  • ghost (boolean) - Whether the spawned balloon should be transparent.


Example:
Code Lua

1
tfm.exec.attachBalloon("Tigrounette#0001", true, 3, true)


tfm.exec.changePlayerSize(playerName, size)

Effect: Changes the size of a player.

Arguments:
  • playerName (string) - The username of the player to have their size changed.
  • size (float) - The new size of the player (between 0.1 and 5).


Example:
Code Lua

1
tfm.exec.changePlayerSize("Tigrounette#0001", 0.5)


tfm.exec.chatMessage(message, playerName)

Effect: Displays a custom message in the chat to users.

This function is only available to members on the Module Team. This is to prevent possible impersonation, spamming, breaking people's chat, and other similar things from happening.

Arguments:
  • message (string) - The message to be displayed. Can support up to 1k characters per message.
  • playerName (string) - The username of the player to display the message to. If this argument is nil, the message will be displayed to all players.


Example:
Code Lua

1
tfm.exec.chatMessage("<ROSE>[~Moderation] I'm a duck.")


tfm.exec.disableAfkDeath(disable)

Effect: Disables AFK death, where normally players automatically die if they haven't moved 30 seconds after a round's start.

Arguments:
  • disable (boolean) - If true, players won't die from AFK death. If false, players will die from AFK death.


Example:
Code Lua

1
tfm.exec.disableAfkDeath(true)


tfm.exec.disableAllShamanSkills(disable)

Effect: Disables shaman skills, shamans will just have the regular skill set available.

Arguments:
  • disable (boolean) - If true, shamans won't have access to any of their skills. If false, shamans will have access to all of their skills.


Example:
Code Lua

1
tfm.exec.disableAllShamanSkills(true)


tfm.exec.disableAutoNewGame(disable)

Effect: Disables Transformice's automatic new round system. When the timer hits 0 seconds remaining, the current round will continue playing.

Arguments:
  • disable (boolean) - If true, the game will continue the current round when time runs out. If false, the game will automatically start a new round.


Example:
Code Lua

1
tfm.exec.disableAutoNewGame(true)


tfm.exec.disableAutoScore(disable)

Effect: Disables Transformice's automatic scoring system so that people don't earn points. Players usually get 16 points for getting in the hole first, 14 points for coming second, 12 points for coming third, 10 points for getting in the hole any other way, or 1 points for dying.

Arguments:
  • disable (boolean) - If true, players won't earn points on the scoreboard. If false, players will earn points when they go in the hole or die.


Example:
Code Lua

1
tfm.exec.disableAutoScore(true)


tfm.exec.disableAutoShaman(disable)

Effect: Disables the automatic selection of a shaman when a new round starts.

Arguments:
  • disable (boolean) - If true, no players will be made shaman when a new round starts. If false, a player will be made a shaman on a new round (unless the map's perm type requires no shaman).


Example:
Code Lua

1
tfm.exec.disableAutoShaman(true)


tfm.exec.disableAutoTimeLeft(disable)

Effect: Disables the automatic timer changes that occur when only 2 mice are left alive, or when all mice are dead.

Arguments:
  • disable (boolean) - If true, the timer won't automatically change. If false, the timer will set itself to 20 seconds remaining when only 2 mice are left alive, or when all mice are dead.


Example:
Code Lua

1
tfm.exec.disableAutoTimeLeft(true)


tfm.exec.disableDebugCommand(disable)

Effect: Disables the /debug command and all players that were using it will get it disabled while they are in the room.

Arguments:
  • disable (boolean) - If true, the command /debug will stop working. If false, the command /debug can be used again.


Example:
Code Lua

1
tfm.exec.disableDebugCommand(true)


tfm.exec.disableMinimalistMode(disable)

Effect: Disables the minimalist mode and all players that were using it will get it disabled while they are in the room.

Arguments:
  • disable (boolean) - If true, the minimalist mode will stop working. If false, the minimalist mode can be used again.


Example:
Code Lua

1
tfm.exec.disableMinimalistMode(true)


tfm.exec.disableMortCommand(disable)

Effect: Disables the /mort command.

Arguments:
  • disable (boolean) - If true, the /mort command will stop working. If false, the /mort command can be used again.


Example:
Code Lua

1
tfm.exec.disableMortCommand(true)


tfm.exec.disablePhysicalConsumables(disable)

Effect: Disables all physical consumables, meaning that players will no longer be allowed to use them in the map.

Arguments:
  • disable (boolean) - If true, players will not be allowed to use physical items from the inventory in the map. If false, players will be able to use physical items from the inventory in the map.


Example:
Code Lua

1
tfm.exec.disableMortCommand(true)


tfm.exec.disablePrespawnPreview(disable)

Effect: Disables the prespawn preview from shamans in the map, meaning that players will no longer know where the shaman will be summoning an object until it begins the invocation.

Arguments:
  • disable (boolean) - If true, players will not able to see where the shaman will be summoning an object. If false, players will be able to see where the shaman will be summoning an object.


Example:
Code Lua

1
tfm.exec.disablePrespawnPreview(true)


tfm.exec.disableWatchCommand(disable)

Effect: Disables the /watch command and all players that were using it will get it disabled while they are in the room.

Arguments:
  • disable (boolean) - If true, the command /watch will stop working. If false, the command /watch can be used again.


Example:
Code Lua

1
tfm.exec.disableWatchCommand(true)


tfm.exec.displayParticle(id, xPosition, yPosition, xSpeed, ySpeed, xAcceleration, yAcceleration, targetPlayer)

Effect: Displays a temporary particle effect to a player or all players.

http://i.imgur.com/eLfPhRn.png

Arguments:
  • id (integer) - The ID of the type of particle to display. Check the "Enums and IDs" section of this thread for a complete list of IDs to use here.
  • xPosition (integer) - The X coordinate that the particle will be spawned at.
  • yPosition (integer) - The Y coordinate that the particle will be spawned at.
  • xSpeed (integer) - The horizontal velocity that the particle will have at the moment it's spawned.
  • ySpeed (integer) - The vertical velocity that the particle will have at the moment it's spawned.
  • xAcceleration (integer) - The horizontal acceleration that the particle will have at the moment it's spawned.
  • yAcceleration (integer) - The vertical acceleration that the particle will have at the moment it's spawned.
  • name (string) - If a string, the particle will only display to the selected player. If nil, the particle will display to everyone in the room.


Example:
Code Lua

1
tfm.exec.displayParticle(1, 400, 200, 0, 0, 0, 0, "Tigrounette#0001")


tfm.exec.explosion(xPosition, yPosition, power, distance, miceOnly)

Effect: Creates an explosion that forces nearby objects and mice away, similarly to how a spirit works.

Arguments:
  • xPosition (integer) - The X coordinate that the explosion will occur at.
  • yPosition (integer) - The Y coordinate that the explosion will occur at.
  • power (integer) - The power that the explosion will have - the higher the number, the more velocity objects nearby will be pushed away with.
  • distance (integer) - The radius that the explosion will be affect.
  • miceOnly (boolean) - If true, the explosion will affect mice but not dynamic objects in the map. If false, the explosion will affect both mice and physic objects.


Example:
Code Lua

1
tfm.exec.explosion(400, 200, 100, 50, false)


tfm.exec.freezePlayer(playerName, freeze)

Effect: Freezes a player, as in the Stop! shaman skill.

Arguments:
  • playerName (string) - The username of the player to be frozen.
  • freeze (boolean) - Whether the player should be frozen.


Example:
Code Lua

1
tfm.exec.freezePlayer("Melibellule#0001", true)


tfm.exec.getPlayerSync( )


Effect: Gets the room's sync player.

This function is only available to members on the Module Team.

Example:
Code Lua

1
tfm.exec.getPlayerSync()


tfm.exec.giveCheese(playerName)

Effect: Gives cheese to a player, if they don't already have it. Triggers the eventPlayerGetCheese() function.

Arguments:
  • playerName (string) - The username of the player to be given cheese.


Example:
Code Lua

1
tfm.exec.giveCheese("Melibellule#0001")


tfm.exec.giveConsumables(playerName, consumableId, amount)

Effect: If this function is executed is an event approved by the administrators, this will give the player the specified inventory consumable. This was previously seen in the Lua events such as The Unkonwn and Day of the Dead. For more information about Lua events, see this post.

This function is only available to members on the Module Team.

Arguments:
  • playerName (string) - The username of the player to be given the consumables.
  • consumableId (string) - The ID of the consumable to give to the player.
  • amount (string) - The number of consumables to give to the player. You can only give a player 10 consumables per game reboot.


Example:
Code Lua

1
tfm.exec.giveConsumables("Tigrounette#0001", 24, 10)


tfm.exec.giveMeep(playerName, canMeep)

Effect: Gives a player the ability to "meep", as found in the Vampire Survivor minigame. Players with this ability can press the spacebar every few seconds to make a small explosion, pushing nearby mice away.

Arguments:
  • playerName (string) - The username of the player to be given the meep ability.
  • canMeep (boolean) - Whether the player should get the meep ability.


Example:
Code Lua

1
tfm.exec.giveMeep("Tigrounette#0001", true)


tfm.exec.giveTransformations(playerName, canTransform)

Effect: Gives a player the ability to transform into objects, as found in a few vanilla maps. Players with this ability can choose an object in the board where shaman objects are displayed. Once clicked, they will become a mouse-object. Then, they can press again in the mouse object to become a mouse.

Arguments:
  • playerName (string) - The username of the player to be given the transformation ability.
  • canTransform (boolean) - Whether the player should get the transformation ability.


Example:
Code Lua

1
tfm.exec.giveTransformations("Tigrounette#0001", true)


tfm.exec.killPlayer(playerName)

Effect: Kills a player instantly, removing them from the current round and making the bubble particle effect in their place.

Arguments:
  • playerName (string) - The username of the player to kill.


Example:
Code Lua

1
tfm.exec.killPlayer("Tigrounette#0001")


tfm.exec.linkMice(playerName1, playerName2, linked)

Effect: Links two players, as in soulmate maps.

Arguments:
  • playerName1 (string) - The username of the first player.
  • playerName2 (string) - The username of the second player.
  • linked (boolean) - Whether player1 and player2 should be linked.


Example:
Code Lua

1
tfm.exec.linkMice("Tigrounette#0001", "Melibellule#0001", true)


tfm.exec.lowerSyncDelay(playerName)

Effect: Lowers the synchronization delay between the game and the Lua api for a specificied player, making the update every 400ms (max) instead of the default 500ms.

This function is only available to members on the Module Team. This is due to the fact it is very intensive on server and client resources and need to be used in moderation.

Arguments:
  • playerName (string) - The player who is getting their synchronization delay reduced.


Example:
Code Lua

1
tfm.exec.lowerSyncDelay("Tigrounette#0001")


tfm.exec.moveObject(id, xPosition, yPosition, xOffset, xSpeed, ySpeed, yOffset)

Effect: Sets the position and velocity of a shaman object on the map.

Arguments:
  • id (integer) - The ID of the shaman object to move. This can be found in tfm.get.room.objectList, and is returned by tfm.exec.addShamanObject() and eventSummoningEnd()
  • xPosition (integer) - The X coordinate to move the object to.
  • yPosition (integer) - The Y coordinate to move the object to.
  • positionOffset (boolean) - If true, the object will be moved to the sum of the current position coordinates with the values given in xPosition and yPosition. If false, the object will be moved to the absolute position coordinates given in xPosition and yPosition.
  • xSpeed (integer) - The horizontal velocity the object will be given.
  • ySpeed (integer) - The vertical velocity the object will be given.
  • speedOffset (boolean) - If true, the object will be have its speed set to the sum of the current speed (horizontally and vertically) with the values given in xSpeed and ySpeed. If false, the object will have its speed set to the absolute values given in xSpeed and ySpeed.


Example:
Code Lua

1
2
3
-- As a shaman object is required to move in the first place, one will be spawned here for example.
id = tfm.exec.addShamanObject(10, 100, 200)
tfm.exec.moveObject(id, 700, 200, false, 0, 0, false)


tfm.exec.movePlayer(playerName, xPosition, yPosition, positionOffset, xSpeed, ySpeed, speedOffset)

Effect: Sets the position and velocity of a player on the map.

Arguments:
  • playerName (string) - The username of the player to move.
  • xPosition (integer) - The X coordinate to move the player to.
  • yPosition (integer) - The Y coordinate to move the player to.
  • positionOffset (boolean) - If true, the player will be moved to the sum of the current position coordinates with the values given in xPosition and yPosition. If false, the player will be moved to the absolute position coordinates given in xPosition and yPosition.
  • xSpeed (integer) - The horizontal velocity the player will be given.
  • ySpeed (integer) - The vertical velocity the player will be given.
  • speedOffset (boolean) - If true, the player will be have its speed set to the sum of the current speed (horizontally and vertically) with the values given in xSpeed and ySpeed. If false, the player will have its speed set to the absolute values given in xSpeed and ySpeed.


Example:
Code Lua

1
tfm.exec.movePlayer("Tigrounette#0001", 400, 200, false, 0, 50, false)


tfm.exec.newGame(mapCode, flipped)

Effect: Starts a new round with a selected map.

Arguments:
  • mapCode (string) - The code of the map to play, this can be defined in several different ways. If this argument is nil and tfm.exec.disableAutoNewGame() isn't activated, this will start a new round with the regular map rotation in the room.

    • @1 - The @code of a map exported to the server. If the "@" symbol isn't included, this can be used as an integer.
    • #4 - The ID of a perm category, a random map from the category will be selected. See the "Enums and IDs" section of this thread for a full list of perm categories.
    • <XML> - A complete map XML can be played directly without having to be exported to the server.
  • flipped (boolean) - Whether the map should be mirrored when loaded.


Example:
Code Lua

1
tfm.exec.newGame(3000000)


tfm.exec.playEmote(playerName, emoteId, emoteArg)

Effect: Forces a player to perform a specific emote.

Arguments:
  • playerName (string) - The username of the player to do an emote. If nil, all players will do the emote.
  • emoteId (boolean) - The ID of an emote. See the "Enums and IDs" section of this thread for a full list of emotes.
  • emoteArg (string?) - If the emote is flag, you can also send the country code.


Example:
Code Lua

1
tfm.exec.playEmote("Tigrounette#0001", tfm.enum.emote.flag, "fr")


tfm.exec.playerVictory(playerName)

Effect: Makes a player simulate going to the hole, if they have cheese they will go in and if they don't they will continue as if nothing happened.

Arguments:
  • playerName (string) - The username of the player to give victory to.


Example:
Code Lua

1
tfm.exec.playerVictory("Tigrounette#0001")


tfm.exec.removeBonus(id, targetPlayer)

Effect: Removes a defilante token that's been placed in the map.

Arguments:
  • id (integer) - The ID of the token to remove.
  • targetPlayer (string) - The username of the player who will not see the token anymore. If nil, it will get removed to all players.


Example:
Code Lua

1
2
tfm.exec.addBonus(0, 100, 100, 1)
tfm.exec.removeBonus(1)


tfm.exec.removeCheese(playerName)

Effect: Takes away the cheese from a player.

Arguments:
  • targetPlayer (string) - The username of the player to take away the cheese from.


Example:
Code Lua

1
2
tfm.exec.giveCheese("Melibellule#0001")
tfm.exec.removeCheese("Melibellule#0001")


tfm.exec.removeImage(imageID)

Effect: Removes an image.

Arguments:
  • imageID (integer) - The ID of the image to removed. The ID to use here is returned from tfm.exec.addImage().


Example:
Code Lua

1
2
imageID = tfm.exec.addImage("1771d446c03.png", "%Tigrounette#0001", -21, -30)
tfm.exec.removeImage(imageID)


tfm.exec.removeJoint(id)

Effect: Removes a joint from the map.

Arguments:
  • id (integer) - The ID of the joint to remove.


Example:
Code Lua

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
local x1, y1 = 200, 200
local x2, y2 = 600, 200
tfm.exec.addJoint(1, 5, 5, {
type = 0,
point1 = x1 .. ", " .. y1,
point2 = x2 .. ", " .. y2,
frequency = 10,
damping = 0.2,
line = 10,
color = 0xFF6600,
alpha = 1,
foreground = true
})

tfm.exec.removeJoint(1)


tfm.exec.removeObject(id)

Effect: Deletes a shaman object from the map.

Arguments:
  • id (integer) - The ID of the shaman object to remove. This can be found in tfm.get.room.objectList, and is returned by tfm.exec.addShamanObject() and eventSummoningEnd().


Example:
Code Lua

1
2
id = tfm.exec.addShamanObject(10, 400, 200)
tfm.exec.removeObject(id)


tfm.exec.removePhysicObject(id)

Effect: Removes a physic object from the map.

Arguments:
  • id (integer) - The ID of the physic object to remove.


Example:
Code Lua

1
2
tfm.exec.addPhysicObject(1, 400, -600, {type=0, width=10, height=10, foreground=true, friction=0.3, restitution=0, dynamic=false, miceCollision=true, groundCollision=true})
tfm.exec.removePhysicObject(1)


tfm.exec.respawnPlayer(playerName)

Effect: Respawns a player if they're dead. Triggers the eventPlayerRespawn() function.

Arguments:
  • playerName (string) - The username of the player to revive.


Example:
Code Lua

1
tfm.exec.respawnPlayer("Tigrounette#0001")


tfm.exec.setAutoMapFlipMode(flipped)

Effect: Sets whether the following maps should be flipped (always, never, or TFM's default behaviour).

Arguments:
  • flipped (boolean) - If true, maps will always be mirrored. If false, maps will never be mirrored. If nil, maps will follow the game's default settings.


Example:
Code Lua

1
tfm.exec.setAutoMapFlipMode(true)


tfm.exec.setGameTime(seconds, init)

Effect: Sets the time left on the current round.

Arguments:
  • seconds (integer) - The amount of seconds to give the current round.
  • init (boolean) - If true, the amount of seconds in the first argument will be set to the current round. If false, the amount of seconds in the first argument will be set to the current round only if the current timer is greater than the amount of seconds in the first argument.


Example:
Code Lua

1
tfm.exec.setGameTime(600, true)


tfm.exec.setNameColor(playerName, color)

Effect: Sets the color of the name that appears above a player's mouse, overwriting any previous color they may have (for example, friends' names are green).

http://i.imgur.com/TDuLhH1.png

Arguments:
  • playerName (string) - The username of the player whose name color will be changed.
  • color (integer) - The color of the text area, as a hexadecimal number. If this argument is 0, their name color will be reset.


Example:
Code Lua

1
tfm.exec.setNameColor("Tigrounette#0001", 0xFFFFFF)


tfm.exec.setPlayerScore(playerName, score, add)

Effect: Changes the score a player has. This score is found in the tfm.get.room.playerList table, and can be seen on the scoreboard next to the chat.

Arguments:
  • playerName (string) - The username of the player whose score will be changed.
  • score (integer) - The number to set the player's score to.
  • add (boolean) - If true, the player's current score and number in the score argument will be added together. If false, the playe'rs score will be set to the number in the score argument.


Example:
Code Lua

1
tfm.exec.setPlayerScore("Tigrounette#0001", 25)


tfm.exec.setPlayerSync(playerName)

Effect: Defines the new room's sync player.

This function is only available to members on the Module Team.

Arguments:
  • playerName (string) - The username of the player who is going to be the sync. Use nil for the server to choose.


Example:
Code Lua

1
tfm.exec.setPlayerSync("Tigrounette#0001")


tfm.exec.setRoomMaxPlayers(maxPlayers)

Effect: Sets the maximum amount of players allowed in the room. If the room is full of players up until this amount, anyone trying to join will be redirected to another room, for example room "#module" would redirect them to room "#module1".

This function is only available to members on the Module Team. This is so that people can still access their own tribe house regardless of what script is ran inside.

Arguments:
  • maxPlayers (integer) - The number of maximum players to be allowed in the room. Can be between 5 and 50.


Example:
Code Lua

1
tfm.exec.setRoomMaxPlayers(5)


tfm.exec.setRoomPassword(password)

Effect: Sets the room password. If the room is protected by a password, whoever tries to join it will need to know the pass to enter the room.

This function is only available to members on the Module Team. This is so that people can still access their own tribe house regardless of what script is ran inside.

Arguments:
  • password (string) - The password to protect the room. If it's an empty string, the room gets removes the current password.


Example:
Code Lua

1
tfm.exec.setRoomPassword("lua")


tfm.exec.setShaman(playerName, makeAShaman)

Effect: Makes a player a shaman.

Arguments:
  • playerName (string) - The username of the player to be made a shaman.
  • makeAShaman (string) - Whether the player should become a shaman.


Example:
Code Lua

1
tfm.exec.setShaman("Tigrounette#0001", true)


tfm.exec.setShamanMode(playerName, mode)

Effect: Changes the shaman mode of a player while they are in the room.

Arguments:
  • playerName (string) - The username of the player to be change the shaman mode.
  • mode (integer) - The shaman mode to be set for the player. (0 = Normal Mode, 1 = Hard Mode, 2 = Divine Mode, nil = default)


Example:
Code Lua

1
tfm.exec.setShamanMode("Tigrounette#0001", 2)


tfm.exec.setVampirePlayer(playerName, makeAVampire)

Effect: Turns a player into a vampire, as seen in the Vampire Survivor minigame. Vampires have red names and will randomly infect nearby mice, turning them into vampires too.

Arguments:
  • playerName (string) - The username of the player to turn into a vampire.
  • makeAVampire (string) - Whether the player should become a vampire.


Example:
Code Lua

1
tfm.exec.setVampirePlayer("Tigrounette#0001", true)


tfm.exec.setWorldGravity(wind, gravity)

Effect: Sets the wind and the gravity of the current map.

Arguments:
  • wind (integer) - Sets the force of the wind (X axis).
  • gravity (integer) - Sets the force of the gravity (Y axis).


Example:
Code Lua

1
tfm.exec.setWorldGravity(-5, 5)


tfm.exec.snow(time, power)

Effect: Makes snow fall onto the screen, as used in Christmas events.

Arguments:
  • time (integer) - The amount of time in seconds the snow will stay on the screen. The default is 60.
  • power (integer) - The power the explosion will make when a snowball object disappears. The default is 10.


Example:
Code Lua

1
tfm.exec.snow(60, 10)


ui.addPopup(id, type, text, targetPlayer, xPosition, yPosition, width, fixedPosition)

Effect: Creates a popup on a player's screen with custom text. The popup's height will automatically adjust to fit the text displayed on it.

http://i.imgur.com/Ja8EXGv.png

Arguments:
  • id (integer) - The ID of the popup. Only one popup with the same ID can be displayed at a time per player, if another is created with the same ID the first will be removed.
  • type (integer) - 0 is a simple popup with nothing but a close button. 1 is a popup with two buttons with different callbacks; "yes" and "no". 2 is a popup with a text box that allows the player to type in anything they like and submit it.
  • text (string) - The text to be displayed on the popup window.
  • targetPlayer (string) - The username of the player who the popup will display for. If this argument is nil, the popup will display to all players.
  • xPosition (integer) - The X coordinate that the left of the popup will start at.
  • yPosition (integer) - The Y coordinate that the top of the popup will start at.
  • width (integer) - The width of the popup.
  • fixedPosition (boolean) - If true, the popup will stay relative to the UI on scrolling maps. If false, the popup will stay in the same position on the map.


Example:
Code Lua

1
ui.addPopup(1, 0, "Example text to display.", nil, 180, 300, 200, true)


ui.addTextArea(id, text, targetPlayer, xPosition, yPosition, width, height, backgroundColor, borderColor, backgroundAlpha, fixedPosition)

Effect: Creates an area on the screen with custom color, size, and text displayed on it that can be clicked on.

http://i.imgur.com/w0XHjeO.png

Arguments:
  • id (integer) - The ID of the text area, to be used when removing or updating it.
  • text (string) - The text to be displayed in the text area.
  • targetPlayer (string) - The player who the text area will be displayed to. If this argument is nil, it will be displayed to all players in the room.
  • xPosition (integer) - The X coordinate that the left of the popup will start at.
  • yPosition (integer) - The Y coordinate that the top of the popup will start at.
  • width (integer) - The width of the text area.
  • height (integer) - The height of the text area.
  • backgroundColor (integer) - The color of the text area, as a hexadecimal number. If this argument is nil, the background color will be 0x324650.
  • borderColor (integer) - The color of the border around the text area, as a hexadecimal number. If this argument is nil, the border color will be 0x000000.
  • backgroundAlpha (float) - The alpha level the text area will be. 1 is opaque, 0 is fully transparent. If this argument is nil, the alpha level will be 1.
  • fixedPosition (integer) - If true, the text area will stay relative to the UI on scrolling maps. If false, the text area will stay in the same position on the map.


Example:
Code Lua

1
ui.addTextArea(1, "Example text to display.", nil, 350, 180, 100, 40, 0x324650, 0x212F36, 0.8, true)


ui.removeTextArea(id, targetPlayer)

Effect: Removes a text area completely, stopping it from displaying and not allowing it to be clicked on.

Arguments:
  • id (integer) - The ID of the text area to remove.
  • targetPlayer (string) - The username of the player whose text area with the relevant ID. If this argument is nil, all player's text areas with this ID will be removed.


Example:
Code Lua

1
ui.removeTextArea(1, nil)


ui.setMapName(text)

Effect: Sets the text at the top-left of the UI that displays the current map's code and author by default. The map's perm icon is kept the same.

http://i.imgur.com/gx8oPT6.png

Arguments:
  • text (string) - The text to display in the top-left of the UI.


Example:
Code Lua

1
ui.setMapName("Tigrounette is smelly")

Dernière modification le 1641482760000
Shamousey
« Consul »
1411071300000
    • Shamousey#0095
    • Profil
    • Derniers messages
    • Tribu
#4
  2
ui.setShamanName(text)

Effect: Changes the text in the top bar where the shaman's name is usually displayed. The text "Shaman:" is kept there.

http://i.imgur.com/aNNVY3e.png

Arguments:
  • text (string) - The text to display in place of the shaman's name in the UI.


Example:
Code Lua

1
ui.setShamanName("Melibellule is a kangaroo")


ui.showColorPicker(id, targetPlayer, defaultColor, title)

Effect: Displays a color picker where a player can select a color.

http://images.atelier801.com/17730fbefa8.png

Arguments:
  • id (integer) - The ID of the color picker, to be used when removing it or when a player selects a color in eventColorPicked.
  • targetPlayer (string) - The player who the color picker will be displayed to. If this argument is nil, it will be displayed to all players in the room.
  • defaultColor (integer) - The initial color that the interface will display when opened.
  • title (string) - The title of the color picker, a short text that goes on top of the interface.


Example:
Code Lua

1
ui.showColorPicker(1, nil, 0x3A81A0, "Color for moderators")


ui.updateTextArea(id, text, targetPlayer)

Effect: Replaces the text on a text area with something else.

Arguments:
  • id (integer) - The ID of the text area to change.
  • text (string) - The text to be displayed on the updated text area.
  • targetPlayer (string) - The username of the player whose text area with the relevant ID. If this argument is nil, every player with a text area displayed with the ID used will be displayed the new text.


Example:
Code Lua

1
ui.updateTextArea(1, "This is some different text.", nil)

Dernière modification le 1621104600000
Shamousey
« Consul »
1411071300000
    • Shamousey#0095
    • Profil
    • Derniers messages
    • Tribu
#5
  1
You can find the previous Module API FAQ here. http://atelier801.com/topic?f=6&t=365251

Dernière modification le 1617410400000
Safwanrockz
« Censeur »
1411071540000
    • Safwanrockz#0095
    • Profil
    • Derniers messages
    • Tribu
#6
  0
Beautiful remake, gj Liam. o/
Haruhitastic
« Censeur »
1411071600000
    • Haruhitastic#0000
    • Profil
    • Derniers messages
    • Tribu
#7
  0
very fancy even though i've still no clue whats going on
that list of who runs what game is very helpful thaaaank
Makinit
« Citoyen »
1411072200000
    • Makinit#0095
    • Profil
    • Derniers messages
    • Tribu
#8
  1
how lua pls
Shamousey
« Consul »
1411073220000
    • Shamousey#0095
    • Profil
    • Derniers messages
    • Tribu
#9
  0
I hope this thread is useful for people! *-* Now there's the full list of shaman object IDs now (it's probably the biggest list of object IDs you've seen, thanks Ykr for telling me a large number of those newer ones), examples of what each function does and descriptions of each argument, much clearer styling and formatting, and generally something I know I'll be referring to myself.
Cheetahkitty
« Citoyen »
1411081920000
    • Cheetahkitty#0000
    • Profil
    • Derniers messages
    • Tribu
#10
  0
Wow Gj shamousey ^^
Shenato
« Citoyen »
1411083600000
    • Shenato#0000
    • Profil
    • Derniers messages
    • Tribu
#11
  0
I'm impressed...
Haku
« Sénateur »
1411098480000
    • Haku#0807
    • Profil
    • Derniers messages
#12
  0
I'd have loved to have this thread like this back when I started with the API and Lua. I'm sure the changes will be of much help to some people. Great work!
Orb
« Censeur »
1411141560000
    • Orb#0095
    • Profil
    • Derniers messages
    • Tribu
#13
  0
Pretty useful, thanks! \o
Oguzhandkr
« Citoyen »
1411143180000
    • Oguzhandkr#0000
    • Profil
    • Derniers messages
    • Tribu
#14
  0
Thanks Shamo! *-*
Hotspotower
« Citoyen »
1411143180000
    • Hotspotower#0000
    • Profil
    • Derniers messages
    • Tribu
#15
  0
Thanks.
Neonstrayzer
« Citoyen »
1411143240000
    • Neonstrayzer#0000
    • Profil
    • Derniers messages
    • Tribu
#16
  0
Thanks.
Drgenius
« Citoyen »
1411147560000
    • Drgenius#0000
    • Profil
    • Derniers messages
    • Tribu
#17
  0
Sweet! Finally the full documentation with IDs and all is actually on the forums! Thanks Shamo! This is going to be very useful I'm sure. ^_^
Leafileaf
« Citoyen »
1411182060000
    • Leafileaf#0000
    • Profil
    • Derniers messages
    • Tribu
#18
  0
Liam just a few things
2600-2699 spawns blue portal too, but it still has art.
2700-2799 spawns orange portal
Invisible apples don't work (I think it should be noted)
Drgenius
« Citoyen »
1411185600000
    • Drgenius#0000
    • Profil
    • Derniers messages
    • Tribu
#19
  0
May I suggest formatting the method names to indicate whether or not they are for use by everyone or just the Module Team? On the wiki it's underlined. I think it will save newbies a lot of time. Also something that would be neat is coloring for each type of argument required (or sent in events), for example, green for string, white for int, blue for float, orange for bool, etc. Just a thought.
Benbirkralm
« Citoyen »
1411198800000
    • Benbirkralm#0000
    • Profil
    • Derniers messages
    • Tribu
#20
  0
Perfect thread. Thanks!
  • Forums
  • /
  • Transformice
  • /
  • Modules
  • /
  • Module FAQ & Documentation
1 / 19 › »
© Atelier801 2018

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

Version 1.27