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.

Tables

keys List of keycodes.

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

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)
  • 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)
  • ESCAPE The ESC key. (27)
  • SPACE The SPACEBAR key. (32)
  • PAGEUP The PAGE UP key. (33)
  • NEXT 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)
  • MULTIPLY The multiply key. (106)
  • ADD The ADD key. (107)
  • SEPARATOR The separator key. (108)
  • SUBTRACT The subtract key. (109)
  • DECIMAL The decimal key. (110)
  • DIVIDE The divide key. (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)

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 2024-07-10 03:22:35