Commands: objects
Legend
- X - X is a number
- 'X' - X is a string (a letter/word/text)
- [X=0] - X is an optional parameter with value 0 when omitted (NEVER add [] to your script!)
- - command is hard synced
createobject(TYPE, X, Y, [PARAMETER=0])
Parameters: | TYPE - object type X - x coordinate Y - y coordinate [PARAMETER=0] - setup parameter |
Creates a Carnage Contest game object at the (X|Y) coordinate.
Valid built-in object types are:
o_fire - a fire which hurts players
o_supply - a supply crate (for non random content: PARAMETER = return value of addweapon)
o_mine - a mine which explodes when a player is close
o_beartrap - a trap
o_medikit - a medikit which heals you
o_node - a node (typically created in the editor only for mission scripting, invisible)
o_item - creates an item (PARAMETER = return value of addweapon)
Moreover you can use IDs returned by the addobject-command. This allows you to create and use your own custom objects.
It is recommended to use the Lua table "objects" as an array to store your custom object data. The array index is the ID of the object. Carnage Contest will reset this table each time a game is started.
Example:
objects[id].myvariable
Attention: This command does NOT return the ID of the new object!
Instead it calls the Lua setup-function of the object (if it is a custom object). It also passes the new ID and the PARAMETER:
setup(ID,PARAMETER)
Valid built-in object types are:
o_fire - a fire which hurts players
o_supply - a supply crate (for non random content: PARAMETER = return value of addweapon)
o_mine - a mine which explodes when a player is close
o_beartrap - a trap
o_medikit - a medikit which heals you
o_node - a node (typically created in the editor only for mission scripting, invisible)
o_item - creates an item (PARAMETER = return value of addweapon)
Moreover you can use IDs returned by the addobject-command. This allows you to create and use your own custom objects.
It is recommended to use the Lua table "objects" as an array to store your custom object data. The array index is the ID of the object. Carnage Contest will reset this table each time a game is started.
Example:
objects[id].myvariable
Attention: This command does NOT return the ID of the new object!
Instead it calls the Lua setup-function of the object (if it is a custom object). It also passes the new ID and the PARAMETER:
setup(ID,PARAMETER)
getobjecttype(OBJECT)
Parameters: | OBJECT - ID of object |
Returns: | TYPE - type of object |
Returns the type of OBJECT.
getobjectx(OBJECT)
Parameters: | OBJECT - ID of object |
Returns: | X - x coordinate of object |
Returns the X coordinate/position of OBJECT.
getobjectxspeed(OBJECT)
Parameters: | OBJECT - ID of object |
Returns: | X SPEED - x speed of object |
Returns the x speed of OBJECT (flying speed).
getobjecty(OBJECT)
Parameters: | OBJECT - ID of object |
Returns: | Y - y coordinate of object |
Returns the Y coordinate/position of PLAYER.
getobjectyspeed(OBJECT)
Parameters: | OBJECT - ID of object |
Returns: | Y SPEED - y speed of object |
Returns the y speed of OBJECT (flying speed).
objectposition(OBJECT, X, Y)
Parameters: | OBJECT - ID of object X - x coordinate Y - y coordinate |
Sets the position of an object to the (X|Y) coordinate.
objectpush(OBJECT, PUSH X, PUSH Y, [ABSOLUTE=0])
Parameters: | OBJECT - ID of object PUSH X - x push value PUSH Y - y push value [ABSOLUTE=0] - set absolute (1) or add to current values (0) |
Pushs a certain object with the speeds PUSH X and PUSH Y.
Use ABSOLUTE 1 to set the values. Use ABSOLUTE 0 to add the values to the current speed values.
Use ABSOLUTE 1 to set the values. Use ABSOLUTE 0 to add the values to the current speed values.
objecttable([TYPE=0])
Parameters: | [TYPE=0] - list objects of this type only (0 for all types) |
Returns: | OBJECT TABLE - a table containing object IDs |
Returns a table/array which contains the IDs of objects in the game.
By default all object types are included. Use another value for TYPE to get a table which only contains objects of a certain type.
By default all object types are included. Use another value for TYPE to get a table which only contains objects of a certain type.