—» Home
—» Screens
—» Help
—» F.A.Q.
—» Armory
—» Download
Help Home

Tutorials

Weapon Scr. I
Weapon Scr. II

Cmd Reference

All Commands
General
Load
Graphics
HUD
Sounds
Player
Terrain
Projectiles
Particles
Collision
Objects
AI

Commands: load

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


addobject('TABLE', [IMAGE=0])

Parameters:
'TABLE' - Lua table which holds the object functions
[IMAGE=0] - ID of an image which will be used for collisions (0 for 0 collision)
Returns:
ID - object ID, required for createobject
Adds an object type to the game.
This command can be used several times in a single Lua script file.
A weapon does not have to have an object. It also can have multiple different objects.

Objects are pretty much like projectiles. The difference is that they can exist longer than just one turn. They normally do not prevent that the turn ends (but they can prevent it).

TABLE has to have at least 4 functions:
setup(ID,PARAMETER) - called by createobject once after creation
draw(ID) - draw the object with ID
update(ID) - update the object with ID
damage(ID,DAMAGE) - damage the object with ID

Use return 1 in the update function of an object if you do not want the turn to end!

You can also specify a collision image. Players and other stuff will collide with your object when you use a collision image. Otherwise nothing will collide with your object.

addprojectile('TABLE')

Parameters:
'TABLE' - Lua table which holds the projectile functions
Returns:
ID - projectile ID, required for createprojectile
Adds a projectile type to the game.
This command can be used several times in a single Lua script file.
A weapon does not have to have projectiles. It also can have multiple different projectiles.

A turn never ends when there are still projectiles. So you have to ensure that all projectiles are deleted properly. Use objects instead if you need to create things which can exist longer than one turn.

TABLE has to have at least 2 functions:
draw(ID) - draw the projectile with ID
update(ID) - update the projectile with ID

addweapon('TABLE', 'NAME', ICON, [AMOUNT=100], [FIRST USE=1])

Parameters:
'TABLE' - Lua table which holds the weapon functions
'NAME' - in-game name for the weapon
ICON - ID of an image which will be used as icon
[AMOUNT=100] - default amount, 0 to 99 or 100 for infinite amount
[FIRST USE=1] - first use in this round, 1-10, 1 for instant use
Returns:
ID - weapon ID
Adds a weapon to the game.
Please use this command exactly ONCE per Lua weapon script file!

TABLE is the Lua table which holds the weapon draw and attack functions. For example 'cc.grenade'.
draw() - draws the weapon
attack(ATTACK) - updates the weapon and contains the attack-code. ATTACK is 1 when the attack key is pressed, else 0.

NAME is the name for your weapon which will be displayed in-game.

ICON is the ID of a previously loaded image which will be used as inventory weapon icon. The image will be scaled if necessary so it fits the inventory slot.

AMOUNT is the amount of uses as number from 0 to 99 or 100 for an infinite number of uses. You can use a weapon infinite times by default.
Note: This setting can be changed in the in-game weapon set editor!

FIRST USE is the first round in which this weapon can be used. You can use values from 1 (first round) to 10 (tenth round). The weapon is available in the first round by default.
Note: This setting can be changed in the in-game weapon set editor as well!

loadgfx('PATH')

Parameters:
'PATH' - path to an image file (bmp,png,jpg) relative to the 'gfx'-folder of Carnage Contest
Returns:
ID - ID for the image which can be used with other commands
Loads an image file relative to the 'gfx'-folder of Carnage Contest and returns an ID.

Attention: Always use this function at the beginning of your script. NEVER use it in draw/update functions!

Attention: You can only load bmp, png or jpg/jpeg files. Other image formats are not supported.

loadsfx('PATH')

Parameters:
'PATH' - path to a sound file (wav,ogg) relative to the 'sfx'-folder of Carnage Contest
Returns:
ID - ID for the sound which can be used with other commands
Loads a sound file relative to the 'sfx'-folder of Carnage Contest and returns an ID.

Attention: Always use this function at the beginning of your script. NEVER use it in draw/update functions!

Attention: You can only load wav and ogg files. Other sound formats are not supported.