Lua Documentation

Status
Not open for further replies.

Soulzone

Developer | TR Community Manager
Staff Member
Admin
Lua Crew

GeneralLua CrewEnums and IDsLua Tree


  • Modules are minigames built into MiceForce with a variety of different gameplay options, and 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 are minigames or utilities that have been approved by an administrator. They show up on the minigame menu.
    • Semi-Official Modules are minigames or utilities that have been approved by an administrator. They don't show up on the minigame menu.
    • Unofficial Modules are usually just scripts ran in tribe houses and other rooms without being previously approved by an administrator.
    What are all of the official modules?
    Below you can find a list of all of the official modules, and who developed them. You can also find a list of official modules ingame by typing "/module" or going to the "Game Mode" window from the menu.


    How can I play a module?
    You can play any 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.

    I've developed a module, how can it be made official?
    Only members of the Lua Crew can manage an official module. You should consider applying for the team yourself (see the "Lua Crew" 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. Closing this tab will result in these messages going to your main chat channel, and you won't be able to reopen the #lua tab without reloading your client.

  • The Lua Crew 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.
    • Displaying custom images in modules.
    • Uploading images to the miceforce.com domain.

  • 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.

    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.

    These are color tags that can be used within strings displayed ingame, such as within tfm.exec.chatMessage() and ui.addTextArea(). They don't need to be ended like HTML tags, and will color all of the text in the string after the code, for example "<J>Help me".

    #2F7FCC <BV> Map Crew names.
    #CB546B <R> Errors.
    #6C77C1 <BL> Default system messages.
    #BABD2F <J> Help & other information.
    #C2C2DA <N> Regular chat.
    #606090 <G> Offline friends.
    #009D9D <V> Chat names.
    #2ECF73 <VP> Tutorial keywords.
    #C53DFF <VI> No usage found.
    #ED67EA <ROSE> Moderation and server messages.
    #98E2EB <CH> Blue shaman text.
    #A4CF9E <T> Tribe chat.

    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.

    0 - Dance
    1 - Laugh
    2 - Cry
    3 - Kiss
    4 - Rage
    5 - Clap
    6 - Sleep
    7 - Facepaw
    8 - Sit
    9 - Confetti
    10 - Flag Waving

    While tfm.enum.shamanObject is an easy-to-access list of most shaman objects, it doesn't list every object available in MiceForce. 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.

    0 - Arrow
    1 - Small Box
    2 - Large Box
    3 - Small Plank
    4 - Large Plank
    5 - Heavy Ball
    6 - Ball
    7 - Trampoline
    8 - Small Rough Plank
    9 - Large Rough Plank
    10 - Anvil
    11 - Red Anchor
    12 - Red Anchor Rotating Clockwise
    13 - Red Anchor Rotating Counter-Clockwise
    14 - Green Anchor
    15 - Green Anchor Rotating Clockwise
    16 - Green Anchor Rotating Counter-Clockwise
    17 - Cannon (Up)
    18 - Cannon (Down)
    19 - Cannon (Right)
    20 - Cannon (Left)
    21 - Sticky Ball
    22 - Yellow Anchor
    23 - Bomb
    24 - Spirit
    25 - Fake Cheese
    26 - Blue Portal
    27 - Orange Portal
    28 - Balloon
    29 - Static Red Balloon
    30 - Static Green Balloon
    31 - Static Yellow Balloon
    32 - Rune
    33 - Chicken
    34 - Snowball
    35 - Valentine's Arrow
    39 - Apple
    40 - Sheep
    41 - Demolition Worker Skill
    42 - Spring
    43 - Speed Boost
    44 - Totem
    45 - Ice Plank
    46 - Choco Plank
    48 - Transformed Mouse Small Box
    49 - Transformed Mouse Large Box
    50 - Transformed Mouse Anvil
    51 - Transformed Mouse Small Plank
    52 - Transformed Mouse Large Plank
    53 - Transformed Mouse
    54 - Frozen Mouse
    57 - Cloud
    58 - Architect Skill
    59 - Bubble
    60 - Tiny Plank
    61 - Companion Crate
    62 - Stable Rune
    65 - Pufferfish
    66 - Balloon Anchor
    67 - Very Long Plank
    68 - Triangle Box
    69 - S-Shaped Plank
    70 - Cobweb Skill
    71 - Roll Skill
    72 - Recycling Skill
    73 - Small Mouse Skill
    74 - Leaf Skill
    75 - Nature's Return Skill
    76 - Booster Skill
    77 - Handymouse Skill
    78 - Restorative Skill
    79 - Stop Skill
    80 - Mouse in Bubble
    81 - Gravitational Anomaly Skill
    82 - Antigravity Skill
    83 - Meep Skill
    84 - Grapnel Skill
    85 - Controlled Disintegration Skill
    86 - Campfire Skill
    87 - Shameow Skill (Broken)
    88 - Conjuration Anchor
    89 - Pumpkin
    90 - Tombstone
    91 - Snowman
    92 - Renewal Skill
    93 - Small Cloud
    94 - Shameow Skill
    100, 103-199, 20000-29999 - Invisible Small Box
    101 - Small Heart Box
    102 - Small Mechanical Box
    103 - Small Christmas Box
    104 - Small Cake Box
    200, 204-299, 30000-32767 - Invisible Large Box
    201 - Large Heart Box
    202 - Large Mechanical Box
    203 - Large Bubble Box
    204 - large Pumpkin Box
    205 - Large Christmas Box
    206 - Large Shaman Box
    207 - Large Cake Box
    300, 303-399 - Invisible Small Plank
    301 - Small Heart Plank
    302 - Small Mechanical Plank
    400, 404-499 - Invisible Large Plank
    401 - Large Heart Plank
    402 - Large Mechanical Plank
    403 - Large Alligator Plank
    600, 602-699 - Invisible Ball
    601 - Pokéball
    602 - Skull Ball
    700, 702-799 - Invisible Trampoline
    701 - Leafy Trampoline
    1000, 1001, 1004-1099 - Invisible Anvil
    1002 - Mechanical Anvil
    1003 - Rock Anvil
    1700, 1702-1799 - Invisible Cannon (Up)
    1701 - Bubble Cannon (Up)
    1800-1899 - Invisible Cannon (Down)
    1900-1999 - Invisible Cannon (Right)
    2000-2099 - Invisible Cannon (Left)
    2801 - Cat Balloon
    2802 - Mechanical Balloon
    2803 - Striped Balloon
    2804 - Spiky Balloon
    2805 - Frog Balloon
    2806 - Heart Balloon
    2807 - Bubble Balloon
    2800, 2808-3199 - Invisible Balloon
    3200-3299 - Invisible Rune
    3500-3599 - Invisible Valentine's Arrow
    3900-3999 - Invisible Apple
    4000-4099 - Invisible Sheep
    4500-4599 - Invisible Ice Plank
    4600-4699 - Invisible Choco Plank
    5700-5799 - Invisible Cloud
    5900-5999 - Invisible Bubble
    6000-6099 - Invisible Tiny Plank
    6100-6199 - Invisible Companion Crate
    6200-6299 - Invisible Stable Rune
    6500-6599 - Invisible Pufferfish
    65536 - Arrow (repeats back from 0)

    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.

    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

    Here is a list of grounds and their corresponding IDs that a map's XML uses.

    0 - Wood
    1 - Ice
    2 - Trampoline
    3 - Lava
    4 - Chocolate
    5 - Earth
    6 - Grass
    7 - Sand
    8 - Cloud
    9 - Water
    10 - Stone
    11 - Snow
    12 - Rectangle
    13 - Circle

    This section contains a list of emoticons that can be used, they are listed in tfm.get.enum.emotes and returned by eventEmotePlayed().

    0 - Dance
    1 - Laugh
    2 - Cry
    3 - Kiss
    4 - Mad
    5 - Clap
    6 - Sleep
    7 - Facepaw
    8 - Sit
    9 - Confetti Throw
    10 - Flag Wave

    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

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

    0 - White Glitter
    1 - Purple Glitter
    2 - Orange Glitter
    3 - Spawn Dust
    4 - Soft White Glitter
    5 - Hearts
    6 - Bubbles
    7 - Bubbles
    8 - Bubbles
    9 - Teal Glitter
    10 - Spirit
    11 - Yellow Glitter
    12 - Super Spirit
    13 - Red Glitter
    14 - Water Bubbles
    15 - Plus 1
    16 - Plus 10
    17 - Plus 12
    18 - Plus 14
    19 - Plus 16
    20 - Meep Sign
    21 - Red Confetti
    22 - Green Confetti
    23 - Blue Confetti
    24 - Yellow Confetti
    25 - Rain
    26 - Wind
    27 - Wind
    28 - Lightning
    29 - Yellow Stars
    30 - Small Red Hearts
    31 - Small Pink Hearts
    32 - Flowers
    33 - Bell
    34 - Water Drops

  • _G
    • ipairs
    • ui
      • setMapName
      • addTextArea
      • addPopup
      • updateTextArea
      • addLog
      • showColorPicker
      • setShamanName
      • removeTextArea
    • math
    • pcall
    • assert
    • tonumber
    • rawequal
    • table
    • tfm
      • exec
        • setPlayerScore
        • SetRoomMaxPlayers
        • disableAutoShaman
        • setRoomPassword
        • giveMeep
        • killPlayer
        • chatMessage
        • removeObject
        • respawnPlayer
        • movePlayer
        • addShamanObject
        • addConjuration
        • snow
        • setUIMapName
        • setGameTime
        • setVampirePlayer
        • disableAfkDeath
        • disablePhysicalConsumables
        • nextShaman
        • removeCollectable
        • disableAllShamanSkills
        • playerVictory
        • playEmote
        • giveCheese
        • setNameColor
        • displayParticle
        • disableAutoTimeLeft
        • disableChat
        • disableAutoScore
        • setShaman
        • setShamanMode
        • addImage
        • addPhysicObject
        • changeSize
        • changeName
        • newGame
        • removeImage
        • addJoint
        • setSoulmate
        • explosion
        • disableAutoNewGame
        • addCollectable
        • animZelda
        • bindKeyboard
      • get
        • misc
          • transformiceVersion : 2.69
          • apiVersion : 0.19
        • room
          • community : EN
          • currentMap : 0
          • maxPlayers : 50
          • objectList
            • [id]
              • id : 0
              • x : 0
              • y : 0
              • angle : 0
              • ghost : false
              • type : 10
          • name : -
            playerList
            • [playerName]
              • isJumping : true
              • title : 0
              • y : 0
              • x : 0
              • isDead : false
              • look : 1;0,0,0,0,0,0,0,0,0
              • isShaman : false
              • vx : 0
              • score : 0
              • inHardMode : 0
              • vy : 0
              • movingRight : true
              • hasCheese : true
              • registrationDate : 0
              • playerName : Tigrounette
              • movingLeft : false
              • isFacingRight : true
              • isVampire : false
              • tribeName : Les Populaires
          • xmlMapInfo
            • permCode
            • mapCode : 666
            • author : Sevenops
            • xml : <C><P /><Z><S /><D /><O /></Z></C>
    • pairs
    • os
    • xpcall
    • type
    • error
    • string
    • debug
      • disableEventLog
      • disableTimerLog
    • tostring
    • print
    • mf
      • changeLook
      • catchMouse
      • freeze
      • kontrol
    • next
    • system
      • loadPlayerData
      • giveConsumables
      • addBot
      • addCharacter
      • bindMouse
      • sendBots
      • disableStats
      • giveBadge
      • bilgi
      • kickPlayer
      • blockPlayer
      • savePlayerData
      • bindKeyboard
      • disableChatCommandDisplay
      • playMusic
      • eventMs
      • giveTitle
 
Last edited:

Soulzone

Developer | TR Community Manager
Staff Member
Admin
Lua Crew
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.

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:
function eventChatCommand(playerName,message)
print(playerName.." typed the command: "..message)​
end

eventEmotePlayed(playerName, emoteID)
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.


Example:
function eventEmotePlayed(playerName, emoteID)
if emoteID==0 then​
print(playerName.." is dancing!")​
end​
end

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

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


Example:
function eventFileLoaded(fileID, file)
print(fileID.." contains the following data: "..file)
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:
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 co-ordinate the player is at as they press the key.
  • yPlayerPosition (integer) - The Y co-ordinate the player is at as they press the key.

Example:
function eventKeyboard(playerName, keyCode, down, xPlayerPosition,yPlayerPosition)
if key==32 then
print(playerName.." pressed the space key!")
end
end
tfm.exec.bindKeyboard("Soulzone", 32, true, true)

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 co-ordinate the player clicked at.
  • yMousePosition (integer) - The Y co-ordinate the player clicked at.

Example:
function eventMouse(playerName,xMousePosition,yMousePosition)
print(playerName.." clicked the screen.")
end
system.bindMouse("Soulzone", 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:
function eventLoop(timeRemaining,timeRemaining)
print("This will spam you every half a second.")
end

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

Arguments:
  • None.

Example:
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:
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 (integer) - The data that was loaded.

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

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:
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:
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:
function eventPlayerLeft(playerName)
print(playerName.." left the room :(")
end

eventPlayerVampire(playerName)
Trigger: This event triggers when a player becomes a vampire.

Arguments:
  • arg1 (string) - The username of the player who becomes a vampire.

Example:
function eventPlayerVampire(playerName)
print(playerName.." is now a vampire!")
end

eventPlayerWon(playerName, timeElapsed, timeElapsedSinceRespawn)
Trigger: This event triggers when a player enters the hole with cheese and wins.

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:
function eventPlayerWon(playerName,timeElapsed)
print(playerName.." got to the hole in "..(timeElapsed/1000).." seconds.")
end

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:
function eventPlayerRespawn(playerName)
print(playerName.." is now alive again!")
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 (integer) - The answer the popup was given.

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

eventSummoningStart(playerName, objectType, xPosition, yPosition, angle)
Trigger: This event triggers when a shaman starts invocating 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 co-ordinate the object started spawning at.
  • yPosition (integer) - The Y co-ordinate the object started spawning at.
  • angle (integer) - The angle of the shaman object being spawned.

Example:
function eventSummoningStart(playerName, objectType, xPosition, yPosition, angle)
if objectType==10 then
print(playerName.." is spawning an anvil at X:"..xPosition.." Y:"..yPosition)
end
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:
function eventSummoningCancel(playerName)
print(playerName.." stopped summoning an object.")
end

eventSummoningEnd(playerName, objectType, xPosition, yPosition, angle, xSpeed, ySpeed, other)
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 co-ordinate of where the object was spawned.
  • yPosition (integer) - The Y co-ordinate of where the object was spawned.
  • angle (integer) - The angle the object was spawned at.
  • xSpeed (integer) - The X velocity the object has at time of spawning. This is only useful for cannons.
  • ySpeed (integer) - The Y velocity the object has at time of spawning. This is only useful for cannons.
  • other (table) - A table containing other information related to the object spawned.
    • 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.
    • x (integer) - The X coordinate the object was spawned at.
    • y (integer) - The Y coordinate the object was spawned at.
    • 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.

Example:
function eventSummoningEnd(playerName, objectType, xPosition, yPosition, angle, xSpeed, ySpeed, other)
if objectType==10 then
print(playerName.." has spawned an anvil! Let's remove it.")
tfm.exec.removeObject(other.id)
end
end

eventTextAreaCallback(textAreaID, playerName, callback)
Trigger: This event triggers when something happens.

Arguments:
  • textAreaID (integer) - The ID of the text area clicked on, for use in ui.removeTextArea() and ui.updateTextArea().
  • 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:
ui.addTextArea(1,"<a href='event:example'>Example Text</a>",nil,375,175,50,50)
function eventTextAreaCallback(textAreaID, playerName, callback)
print(playerName.." clicked on Text Area "..textAreaID.." on the event '"..callback.."'.")
end
 
Last edited:

Soulzone

Developer | TR Community Manager
Staff Member
Admin
Lua Crew
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 MiceForce, which allow modules to actually do anything.

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:

print("This is example text.")

system.exit()
Effect: Deactivates the currently running script.

Arguments:
  • None.


Example:

system.exit()

system.disableChatCommandDisplay(command, hidden)
Effect: Disables chat commands starting with the ! character from displaying in the public chat. Can only disable up to 100 commands.

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.
  • 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:
system.disableChatCommandDisplay("help",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:
system.bindMouse("Soulzone",true)

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.



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 co-ordinate that the left of the popup will start at.
  • yPosition (integer) - The Y co-ordinate 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:
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.



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 co-ordinate that the left of the popup will start at.
  • yPosition (integer) - The Y co-ordinate 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:
ui.addTextArea(1,"Example text to display.",nil,350,180,100,40,0x324650,0x212F36,0.8,true)

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:
ui.updateTextArea(1,"This is some different text.",nil)

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:
ui.removeTextArea(1,nil)

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:
tfm.exec.addConjuration(40,20,10000)

tfm.exec.addJoint(id, object1, object2, 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.



Arguments:
  • id (integer) - The ID of the joint created.
  • object1 (integer) - The first ground to link.
  • object2 (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 co-ordinates 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 co-ordinates 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:
--As a physic object is needed for the joint to connect to, this will ensure there's one by creating it.
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})

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

tfm.exec.removeJoint(id)
Effect: Removes a joint from the map.

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


Example:
tfm.exec.removeJoint(1)

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.



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:
tfm.exec.addPhysicObject(1,800,400,{
type=0,
restitution=0.2,
friction=0.3,
width=200,
height=50,
groundCollision=true
})

tfm.exec.removePhysicObject(id)
Effect: Removes a physic object from the map.

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


Example:
tfm.exec.removePhysicObject(1)

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.



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:
tfm.exec.addShamanObject(10,400,200,45,50,-20,false)

tfm.exec.displayParticle(id, xPosition, yPosition, xSpeed, ySpeed, xAcceleration, yAcceleration, targetPlayer)
Effect: Displays a temporary particle effect to a player or all players. 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.



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:
tfm.exec.displayParticle(1,400,200,0,0,0,0,"Soulzone")

tfm.exec.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:
tfm.exec.bindKeyboard("Soulzone",32,true,true)

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:
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:
tfm.exec.disableAllShamanSkills(true)

tfm.exec.disableAutoNewGame(disable)
Effect: Disables MiceForce's automatic new round system. When the timer hits 0 seconds remaining, the current round will continue playing. Note: When the time hits 0 seconds remaining, eventLoop may stop ticking.

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:
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 cheese for getting in the hole first, 14 cheese for coming second, 12 cheese for coming third, 10 cheese for getting in the hole any other way, or 1 cheese 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:
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:
tfm.exec.disableAutoShaman(true)

tfm.exec.disableAutoTimeLeft(disable)
Effect: Disables the automatic timer changes that occur when only 2 mice are left alive.

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.


Example:
tfm.exec.disableAutoTimeLeft(true)

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:
tfm.exec.explosion(400,200,100,50,false)

tfm.exec.giveCheese(playerName)
Effect: Gives cheese to a player, if they don't already have it.

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


Example:
tfm.exec.giveCheese("Soulzone")

tfm.exec.giveMeep(playerName)
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.


Example:
tfm.exec.giveMeep("Soulzone")

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:
tfm.exec.killPlayer("Soulzone")

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.
  • xOffset (boolean) - If true, the object will be horizontally moved relative to its current position by the number in xPosition. If false, the object will be moved directly to that coordinate.
  • xSpeed (integer) - The horizontal velocity the object will be given.
  • ySpeed (integer) - The vertical velocity the object will be given.
  • yOffset (boolean) - If true, the object will be vertically moved relative to its current position by the number in yPosition. If false, the object will be moved directly to that coordinate.


Example:
-- 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)

tfm.exec.movePlayer(playerName, xPosition, yPosition, xOffset, xSpeed, ySpeed, yOffset)
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.
  • xOffset (boolean) - If true, the player will be horizontally moved relative to its current position by the number in xPosition. If false, the player will be moved directly to that coordinate.
  • xSpeed (integer) - The horizontal velocity the player will be given.
  • ySpeed (integer) - The vertical velocity the player will be given.
  • yOffset (boolean) - If true, the player will be vertically moved relative to its current position by the number in yPosition. If false, the player will be moved directly to that coordinate.


Example:
tfm.exec.movePlayer("Soulzone",400,200,false,0,50,false)

tfm.exec.newGame(mapCode)
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. Note: This doesn't work in tribehouses.
    • <XML> - A complete map XML can be played directly without having to be exported to the server.


Example:
tfm.exec.newGame(3000000)

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:
tfm.exec.removeObject(tfm.exec.addShamanObject(10,400,200))

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:
tfm.exec.playerVictory("Soulzone")

tfm.exec.respawnPlayer(playerName)
Effect: Respawns a player if they're dead.

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


Example:
tfm.exec.respawnPlayer("Soulzone")

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).



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:
tfm.exec.setNameColor("Soulzone",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:
tfm.exec.setPlayerScore("Soulzone",25)

tfm.exec.setShaman(playerName)
Effect: Makes a player a shaman. Note that due to a bug, players made a shaman through this command will not be able to use their active skills, only passive ones.

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


Example:
tfm.exec.setShaman("Soulzone")

tfm.exec.setGameTime(seconds, add)
Effect: Sets the time left on the current round.

Arguments:
  • seconds (integer) - The amount of seconds to give the current round.
  • add (boolean) - If true, the amount of seconds in the first argument will be added to the current round. If false, the current round's timer will be set to the amount of seconds in the first argument.


Example:
tfm.exec.setGameTime(600,true)

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.



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


Example:
tfm.exec.setUIMapName("Tigrounette is smelly")

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.



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


Example:
tfm.exec.setUIShamanName("Loukno is a kangaroo")

tfm.exec.setVampirePlayer(playerName)
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.


Example:
tfm.exec.setVampirePlayer("Soulzone")

tfm.exec.snow(time, power)
Effect: Makes snow fall onto the screen, as used in Christmas events. While it's snowing, mice can throw snowballs by ducking, which will give off a small explosion as they hit something.

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 disappears. The default is 10.


Example:
tfm.exec.snow(60,10)

/* These functions are only available to members on the Lua Crew. *\
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 Lua Crew. 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:

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 Lua Crew.

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


Example:

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.loadFile(fileNumber)
Effect: Loads a file associated with the account that executed the script. Triggers the eventFileLoaded() function. Usage is limited to once every 10 minutes.

This function is only available to members on the Lua Crew.

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


Example:
system.loadFile(1)

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 10 minutes.

This function is only available to members on the Lua Crew. 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 64k characters maximum.
  • fileNumber (integer) - The number of the file to save to. Can be between 1 and 100.


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

system.loadPlayerData(playerName)
Effect: Loads a string with custom information about a player that was previously saved. Will only work if the player is in the room.

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:
system.loadPlayerData("Soulzone")

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.


Example:
system.savePlayerData("Soulzone","Example string to save.")

tfm.exec.chatMessage(message, playerName)
Effect: Displays a custom message in the chat to users.

This function is only available to members on the Lua Crew. 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 1,000 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:
tfm.exec.chatMessage("<ROSE>[~Moderation] I'm a duck.")

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 Lua Crew. 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:
tfm.exec.setRoomMaxPlayers(5)
 
Last edited:

Soulzone

Developer | TR Community Manager
Staff Member
Admin
Lua Crew
/* SPECIAL MICEFORCE FUNCTIONS *\

system.addBot(id, playerName, title, look, xPosition, yPosition, targetPlayer)
Effect: Makes NPC bot.

Example:
system.addBot(1, "Soulzone", 3062, "1;0,0,31,1,23,11,0,0,0", 458, 335, nil)

system.playMusic(musicLink, targetPlayer)
Effect: Does play music.

You can use MiceForce's Youtube mp3 converter system.
For example, to open music, get the code after the ?v= in the link https://www.youtube.com/watch?v=slff3_3-ioQ -> slff3_3-ioQ and put it after the http://mp3.miceforce.com/

Example:
system.playMusic("http://mp3.miceforce.com/slff3_3-ioQ", "Soulzone")

If you leave the paramater which linked targetPlayer blank or put nil instead; it will work for everybody on the room.

tfm.exec.setShamanMode(name, mode)
Effect: Changes the shaman mode of a player.


0: Normal mode
1: Hard mode
2: Divine mode

Example:
tfm.exec.setShamanMode("Soulzone", 2)

tfm.exec.setSoulmate(playerOne, PlayerTwo)
Effect: Temporarily links players.

Example:
tfm.exec.setSoulmate("Soulzone", "Sevenops", "Kmlcan", "Chomar", "Vol")

Example to unlink:
tfm.exec.setSoulmate("Soulzone")

mf.freeze(name, boolean)
Effect: The mice can't move

example:
mf.freeze("Soulzone", true)

mf.catchMouse(name)
Effect: Thief mouse

example:
mf.catchMouse("Soulzone")

system.disableTags(boolean)
Effect: allows you to disable tags (False: disables / True: enables)

example:
system.disableTags(false) --tags are now disabled
 
Last edited:
Status
Not open for further replies.
Top
"Dev-TR" theme by Soulzone