Types
A type describes the properties of data. In SuperCode, data can be of the following types:
- Built-in types that come with Lua (numbers, strings, tables, nil, functions)
- SuperCode custom types (e.g. Entity, Player, Vector2, etc.)
For example, the properties associated with the Player type are:
Property | Description |
---|---|
isPlayer | Indicates whether the object is a player. This property is read-only. |
name | The nickname of the player. This property is read-only. |
id | The ID of the player — every player in the world has a unique ID. This property is read-only. |
clientId | The network ID of the player — use this when calling functions that apply to a specific player. This property is read-only. |
rotation | The current rotation of the player (in degrees). |
isInvulnerable | Determines whether the player can take damage. Setting to true will allow the player to lose health when hit by weapons or hazards. Setting to false will prevent the player from losing health. |
position | Gets or sets the current position. |
onDestroy | Assigns a function that will be called when the object is destroyed. This property is write-only. |
onSensorEnter | Assigns a function that will be called when an object enters the sensor. This property is write-only. |
onSensorExit | Assigns a function that will be called when an object leaves the sensor. This property is write-only. |
The properties of data can be accessed using the .
— the following example prints the name of a player to the log console. It uses the built-in print()
function, and passes the name
property from the variable named “player” (which is a Player
type).
print(player.name) <-- Prints the name of the player to the log console