When used in a script, it needs to be surrounded by quotes to make it a string.
Some Lua functions use MUIDs, for example FindObjectById and SpawnAsset. The colon and everything after it are optional and are there to make it easier to read. The important part is the 16 digits at the start. You can copy a MUID to the clipboard automatically by right-clicking assets in Project Content or placed objects in the Hierarchy. They are guaranteed to be unique within the game and likely to be unique globally. MUIDs are internal identifiers for objects and assets within your game.
#LUA TABLE INSERT IN CLASS MANUAL#
See the reference manual for more information on what they do. Note that Lua's built-in trigonometric functions use radians, while other functions in Core uses degrees. The available functions are listed below. For example, someVehicle:IsA("Damageable") will return true, because the Vehicle type implements the Damageable interface.įor security reasons, various built-in Lua functions have been restricted or removed entirely. When a type implements an interface, the IsA() function will return true for the interface name. Interfaces list properties, functions, and events that types which implement that interface must have. They are only ever accessed by calling functions within these namespaces. Some sets of related functionality are grouped within namespaces, which are similar to the types above, but cannot be instantiated. An uppercase type is a Core Type, such as Player and CoreObject. You can learn more about Lua types from the official manual here. We can provide any number of arguments after the keys, which will be available in Lua as the. Note, that Lua indexed tables start with index 1, not 0. In our case, it contains a single value key:name at index 1. They are accessible as KEYS table within the script. Use the dot syntax or syntax to insert by associative key. Immediately after this number, we need to provide these keys, one after another. In other words, after doing table.insert, your button table will be at tmp1, tmp2 etc. For example, myObject:IsA("StaticMesh").Ī lowercase type denotes a basic Lua type, such as string and boolean. table.insert works with the index part of the table only. The IsA() function can be passed a type name, and will return true if the value is that type or one of its subtypes, or will return false if it is not. All Core types also share an IsA() function. The value of the type property will match the section headings below, for example: Ability, Vector2, CoreObject, etc. However, all data structures and Objects share a common type property, which is a string indicating its type. Objects all inherit from a single base type: Object. Data structures are owned by Lua, while Objects are owned by the engine and could be destroyed while still referenced by Lua. Core Lua TypesĪt a high level, Core Lua types can be divided into two groups: Data structures and Objects. Some types have class functions, which are accessed with. eventName, while functions are accessed with :FunctionName(). Both properties and events are accessed with. Properties, functions, and events inherited by CoreObject types are listed below. Scripts added to the hierarchy will execute as soon as the game loads, while scripts inside templates execute with each newly spawned instance of the template. Scripts are objects created and added to the hierarchy and/or templates, similar to other object types.