Module utils

Helper functions and variables

Functions

tolua (value) Converts game value to Lua.
totable (value) Converts game object / game array to Lua.
toobject (value) Converts Lua value to game object.
toarray (value) Converts Lua value to game array.
tovararg (value) Converts an array of positions (tables with an x value and a y value) into a vararg.
instanceof (object, class) Checks if an object is an instance of a class.
GraphicsPathCommand.new () Creates a GradientPathCommand helper, for use with drawPath.

Tables

keys List of keycodes.
GraphicsPathWinding GraphicsPathWinding enum.
GradientType GradientType enum.
GradientSpreadMethod GradientSpreadMethod enum.
TextFormatAlign TextFormatAlign enum.
TextFieldAutoSize TextFieldAutoSize enum.
CapsStyle CapsStyle enum.
JointStyle JointStyle enum.
ColorInterpolationMethod ColorInterpolationMethod enum.
BlendMode BlendMode enum.

Fields

Projectile The Projectile class.
Player The Player class.
LocalPlayer The LocalPlayer class.


Functions

tolua (value)
Converts game value to Lua. This allows the modification of given value.

Parameters:

  • value The value to convert.

Returns:

    Lua type of the value.

Usage:

    player.speed = tolua(player.speed) + 10
totable (value)
Converts game object / game array to Lua. This allows iteration over its fields.

The Lua table is a copy of the original game data. Therefore, modifications made to the Lua table will not affect the original object / array.

Parameters:

  • value The value to convert.

Returns:

    table Lua table representing the value.

Usage:

    local players = totable(game.getAllPlayers())
    for i, v in pairs(players) do
        v.setmetadata("index", i)
    end
toobject (value)
Converts Lua value to game object. This allows the usage of options in more complex functions.

Parameters:

  • value The value to convert.

Returns:

    The game object.

Usage:

    givelaser(toobject{ammo=5,reload=4})
toarray (value)
Converts Lua value to game array.

Parameters:

  • value The value to convert.

Returns:

    The game array.
tovararg (value)
Converts an array of positions (tables with an x value and a y value) into a vararg.

Parameters:

  • value The value to convert.

Returns:

    The vararg.

See also:

Usage:

    block.bulkteleportto(false, true, tovararg({{x = 0, y = -7}, {x = 0, y = -8}, {x = 1, y = -8}, {x = 1, y = -7}}))
instanceof (object, class)
Checks if an object is an instance of a class.

Parameters:

  • object The object. tolua must be used for this parameter
  • class The class.

Returns:

    boolean Returns whether the object is an instance of the class.

See also:

Usage:

    isProjectile = tolua(instanceof(tolua(event.reason), Projectile))
GraphicsPathCommand.new ()
Creates a GradientPathCommand helper, for use with drawPath.

See also:

Tables

keys
List of keycodes.

Fields:

  • NONE No key pressed.
  • CANCEL The CANCEL key. (3)
  • BACK The BACKSPACE key. (8)
  • TAB The TAB key. (9)
  • LINEFEED The LINEFEED key. (10)
  • CLEAR The CLEAR key. (12)
  • RETURN The RETURN key. (13)
  • FUNCTION The FUNCTION key. (14)
  • COMMAND The COMMAND key. (15)
  • SHIFT The SHIFTKEY key. (16)
  • CONTROL The CONTROLKEY key. (17)
  • MENU The ALT key. (18)
  • PAUSE The PAUSE key. (19)
  • CAPSLOCK The CAPS LOCK key. (20)
  • NUMPAD The NUMPAD key. (21)
  • ESCAPE The ESC key. (27)
  • SPACE The SPACEBAR key. (32)
  • PAGEUP The PAGE UP key. (33)
  • PAGEDOWN The PAGE DOWN key. (34)
  • END The END key. (35)
  • HOME The HOME key. (36)
  • LEFT The LEFT ARROW key. (37)
  • UP The UP ARROW key. (38)
  • RIGHT The RIGHT ARROW key. (39)
  • DOWN The DOWN ARROW key. (40)
  • SELECT The SELECT key. (41)
  • PRINT The PRINT key. (42)
  • EXECUTE The EXECUTE key. (43)
  • PRINTSCREEN The PRINT SCREEN key. (44)
  • INSERT The INS key. (45)
  • DELETE The DEL key. (46)
  • HELP The HELP key. (47)
  • D0 The 0 key. (48)
  • D1 The 1 key. (49)
  • D2 The 2 key. (50)
  • D3 The 3 key. (51)
  • D4 The 4 key. (52)
  • D5 The 5 key. (53)
  • D6 The 6 key. (54)
  • D7 The 7 key. (55)
  • D8 The 8 key. (56)
  • D9 The 9 key. (57)
  • A The A key. (65)
  • B The B key. (66)
  • C The C key. (67)
  • D The D key. (68)
  • E The E key. (69)
  • F The F key. (70)
  • G The G key. (71)
  • H The H key. (72)
  • I The I key. (73)
  • J The J key. (74)
  • K The K key. (75)
  • L The L key. (76)
  • M The M key. (77)
  • N The N key. (78)
  • O The O key. (79)
  • P The P key. (80)
  • Q The Q key. (81)
  • R The R key. (82)
  • S The S key. (83)
  • T The T key. (84)
  • U The U key. (85)
  • V The V key. (86)
  • W The W key. (87)
  • X The X key. (88)
  • Y The Y key. (89)
  • Z The Z key. (90)
  • NUMPAD0 The 0 key on the numeric keypad. (96)
  • NUMPAD1 The 1 key on the numeric keypad. (97)
  • NUMPAD2 The 2 key on the numeric keypad. (98)
  • NUMPAD3 The 3 key on the numeric keypad. (99)
  • NUMPAD4 The 4 key on the numeric keypad. (100)
  • NUMPAD5 The 5 key on the numeric keypad. (101)
  • NUMPAD6 The 6 key on the numeric keypad. (102)
  • NUMPAD7 The 7 key on the numeric keypad. (103)
  • NUMPAD8 The 8 key on the numeric keypad. (104)
  • NUMPAD9 The 9 key on the numeric keypad. (105)
  • NUMPADMULTIPLY The multiply key on the numeric keypad. (106)
  • NUMPADADD The add key on the numeric keypad. (107)
  • NUMPADENTER The enter key on the numeric keypad. (108)
  • NUMPADSUBTRACT The subtract key on the numeric keypad. (109)
  • NUMPADPERIOD The period key on the numeric keypad. (110)
  • NUMPADSLASH The slash key on the numeric keypad. (111)
  • F1 The F1 key. (112)
  • F2 The F2 key. (113)
  • F3 The F3 key. (114)
  • F4 The F4 key. (115)
  • F5 The F5 key. (116)
  • F6 The F6 key. (117)
  • F7 The F7 key. (118)
  • F8 The F8 key. (119)
  • F9 The F9 key. (120)
  • F10 The F10 key. (121)
  • F11 The F11 key. (122)
  • F12 The F12 key. (123)
  • F13 The F13 key. (124)
  • F14 The F14 key. (125)
  • F15 The F15 key. (126)
  • F16 The F16 key. (127)
  • F17 The F17 key. (128)
  • F18 The F18 key. (129)
  • F19 The F19 key. (130)
  • F20 The F20 key. (131)
  • F21 The F21 key. (132)
  • F22 The F22 key. (133)
  • F23 The F23 key. (134)
  • F24 The F24 key. (135)
  • NUMLOCK The NUM LOCK key. (144)
  • SCROLL The SCROLL LOCK key. (145)
  • LSHIFTKEY The left SHIFT key. (160)
  • RSHIFTKEY The right SHIFT key. (161)
  • LCONTROLKEY The left CTRL key. (162)
  • RCONTROLKEY The right CTRL key. (163)
  • LMENU The left ALT key. (164)
  • RMENU The right ALT key. (165)
  • SEMICOLON The semicolon key. (186)
  • EQUAL The equals key. (187)
  • COMMA The comma key. (188)
  • MINUS The minus key. (189)
  • PERIOD The period key. (190)
  • SLASH The slash key. (191)
  • BACKQUOTE The backquote key. (192)
  • LEFTBRACKET The left bracket key. (219)
  • BACKSLASH The backslash key. (220)
  • RIGHTBRACKET The right bracket key. (221)
  • QUOTE The quote key (222)
  • NEXT [DEPRECATED] Legacy equivalent of the PAGE DOWN key. (34)
  • SEPARATOR [DEPRECATED] Legacy equivalent of the NUMPAD ENTER key. (108)
  • DECIMAL [DEPRECATED] Legacy equivalent of NUMPAD PERIOD key. (110)
  • DIVIDE [DEPRECATED] Legacy equivalent of NUMPAD SLASH key. (111)
GraphicsPathWinding
GraphicsPathWinding enum. Defines the winding rule for path drawing.

Fields:

  • EVEN_ODD Even-odd winding rule. ("evenOdd")
  • NON_ZERO Non-zero winding rule. ("nonZero")

See also:

GradientType
GradientType enum. Defines the type of gradient fill.

Fields:

  • LINEAR Linear gradient fill. ("linear")
  • RADIAL Radial gradient fill. ("radial")

See also:

GradientSpreadMethod
GradientSpreadMethod enum. Defines the spread method for gradient fills.

Fields:

  • PAD Pad spread method. ("pad")
  • REFLECT Reflect spread method. ("reflect")
  • REPEAT Repeat spread method. ("repeat")

See also:

TextFormatAlign
TextFormatAlign enum. Defines the alignment of text within a text field.

Fields:

  • CENTER Centers the text within the text field. ("center")
  • END Aligns the text to the ending edge of the text field, as determined by the text language. Usually the same as RIGHT. ("end")
  • JUSTIFY Justifies the text within the text field. The spacing between words is adjusted line-by-line to ensure each line is the same length. ("justify")
  • LEFT Aligns the text to the left edge of the text field. ("left")
  • RIGHT Aligns the text to the right edge of the text field. ("right")
  • START Aligns the text to the starting edge of the text field, as determined by the text language. Usually the same as LEFT. ("start")

See also:

TextFieldAutoSize
TextFieldAutoSize enum. Defines the auto-sizing mode for text fields.

Fields:

  • CENTER Specifies that the text is to be treated as center-justified text. Any resizing of a single line of a text field is equally distributed to both the right and left sides. ("center")
  • LEFT Specifies that the text is to be treated as left-justified text, meaning that the left side of the text field remains fixed and any resizing of a single line is on the right side. ("left")
  • NONE Specifies that no resizing is to occur. ("none")
  • RIGHT Specifies that the text is to be treated as right-justified text, meaning that the right side of the text field remains fixed and any resizing of a single line is on the left side. ("right")

See also:

CapsStyle
CapsStyle enum. Defines the type of caps at the end of lines.

Fields:

  • NONE No caps at the end of lines. ("none")
  • ROUND Round caps at the end of lines. ("round")
  • SQUARE Square caps at the end of lines. ("square")

See also:

JointStyle
JointStyle enum. Defines the type of joint appearance used at angles.

Fields:

  • BEVEL Beveled joints at the angles formed by lines. ("bevel")
  • MITER Mitered joints at the angles formed by lines. ("miter")
  • ROUND Round joints at the angles formed by lines. ("round")

See also:

ColorInterpolationMethod
ColorInterpolationMethod enum. Defines the color space interpolation method for gradients.

Fields:

  • LINEAR_RGB Linear RGB color space interpolation. ("linearRGB")
  • RGB RGB color space interpolation. ("rgb")

See also:

BlendMode
BlendMode enum. Defines the blend mode for display objects.

Fields:

  • ADD Adds the values of the constituent colors. ("add")
  • ALPHA Applies the alpha value of each pixel to the background. ("alpha")
  • DARKEN Selects the darker of the constituent colors. ("darken")
  • DIFFERENCE Compares colors and subtracts the darker from the lighter. ("difference")
  • ERASE Erases the background based on the alpha value. ("erase")
  • HARDLIGHT Adjusts color based on the darkness of the display object. ("hardlight")
  • INVERT Inverts the background. ("invert")
  • LAYER Forces creation of a transparency group. ("layer")
  • LIGHTEN Selects the lighter of the constituent colors. ("lighten")
  • MULTIPLY Multiplies the values of the display object colors by the background colors. ("multiply")
  • NORMAL The display object appears in front of the background. ("normal")
  • OVERLAY Adjusts color based on the darkness of the background. ("overlay")
  • SCREEN Multiplies the complement of the colors, resulting in a bleaching effect. ("screen")
  • SHADER Uses a shader to define the blend. ("shader")
  • SUBTRACT Subtracts the display object colors from the background colors. ("subtract")

See also:

Fields

Projectile
The Projectile class.

See also:

Player
The Player class.

See also:

LocalPlayer
The LocalPlayer class. All instances of this class also belong to Player class.

See also:

generated by LDoc 1.5.0 Last updated 2025-12-17 05:13:02