—» 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: all

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!

ai_attack()

Let the current player attack - like hitting space (AI script only)

ai_backjump()

Let the current player perform a backjump (AI script only)

ai_down()

Let the current player aim down (AI script only)

ai_jump()

Let the current player perform a jump (AI script only)

ai_left()

Move the current player left (AI script only)

ai_right()

Move the current player right (AI script only)

ai_settimer(VALUE)

Parameters:
VALUE - timer value from 1 to 10
Let the current player change the weapon timer to VALUE. This is only possible if the currently selected weapon allows it (AI script only)

ai_up()

Let the current player aim up (AI script only)

ai_weapon(WEAPON)

Parameters:
WEAPON - name of a weapon
Returns:
SUCCESS - 1 if the weapon is available, else 0
Let the current player switch to WEAPON (AI script only).

The command returns 1 if switching is currently possible and if WEAPON is available.

Attention: Do NOT execute ai_attack in the same script call. Otherwise the player will attack with the old weapon and switching will fail!

angledelta(ANGLE A, ANGLE B)

Parameters:
ANGLE A - an angle
ANGLE B - an angle
Returns:
ANGLE DELTA - difference between two angles
Returns the shortest of the two possible differences between the two angles ANGLE A and ANGLE B.
It's either a positive or a negative value depending on the rotation direction.

arealdamage(X, Y, RADIUS, DAMAGE)

Parameters:
X - x coordinate
Y - y coordinate
RADIUS - radius of damage
DAMAGE - maximum damage
Damages all players within RADIUS at the coordinate (X|Y). The maximum damage at the center is defined with DAMAGE.

blood(X, Y, [AMOUNT=5])

Parameters:
X - x coordinate
Y - y coordinate
[AMOUNT=5] - particle amount
Create some blood particles at the (X|Y) coordinate. The amount depends on AMOUNT and the gore settings.

changeturntime(TIME)

Parameters:
TIME - time in seconds
Increases (or decreases in case of negative values) the turn time by TIME in seconds.

channelplaying(CHANNEL)

Parameters:
CHANNEL - sound channel from 0 to 9
Returns:
PLAYING - 1 if sound is still playing, else 0
Returns 1 if there is a sound playing in this channel or 0 if there is no sound playing.

collision(IMAGE, X, Y, [TERRAIN=1], [PLAYERS=1], [OBJECTS=1], [IGNORE PLAYER=-1], [IGNORE OBJECT=-1])

Parameters:
IMAGE - image ID for collision check
X - x coordinate
Y - y coordinate
[TERRAIN=1] - check col. with terrain
[PLAYERS=1] - check col. with players
[OBJECTS=1] - check col. with objects
[IGNORE PLAYER=-1] - ignore this player, 0 for current, -1 for none
[IGNORE OBJECT=-1] - ignore this object, -1 for none
Returns:
COLLISION - 1 if a collision occurred, else 0
Checks if IMAGE at the (X|Y) coordinate collides.
Use TERRAIN 0 if you do NOT want to check for collision with the terrain.
Use PLAYERS 0 if you do NOT want to check for collision with players.
Use OBJECTS 0 if you do NOT want to check for collision with objects.

Use IGNORE PLAYER to ignore the collision with a certain player. You can also use the value -1 to ignore no player or 0 to ignore the current player.

Use IGNORE OBJECT to ignore the collision with a certain object. Use the value -1 to ignore no object.

You can use the commands terraincollision, playercollision and objectcollision afterwards to get details about the collision.

Moreover Carnage Contest has some built in collision images. You can use the following values for IMAGE to use them:
col1x1
col2x2
col3x3
col4x4
col5x5
col10x10
col20x20
col30x30
colplayer

(the X x X col images are boxes with these sizes in pixels. the colplayer image is the collision image for the player)

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 with random item
o_mine - a mine which explodes when a player is close
o_beartrap - a trap
o_medikit - a medikit which heals you

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)

createprojectile(TYPE)

Parameters:
TYPE - projectile type ID (return value of addprojectile)
Returns:
ID - unique projectile ID
Creates a new instance of a projectile of the given TYPE.
This projectile will then automatically call the corresponding draw and update Lua functions.
The turn will not end until it has been deleted with freeprojectile.

It is recommended to use the Lua table "projectiles" as an array to store your projectile data. The array index is the ID of the projectile. Carnage Contest will reset this table for each turn.
Example:
projectiles[id].myvariable

drawhud(IMAGE, X, Y)

Parameters:
IMAGE - ID of an image
X - x coordinate
Y - y coordinate
Draws IMAGE at the (X|Y) coordinate. The position is NOT affected by scrolling.
Use this function to draw your own interface elements.

drawimage(IMAGE, X, Y)

Parameters:
IMAGE - ID of an image
X - x coordinate
Y - y coordinate
Draws IMAGE at the (X|Y) coordinate on the map. The Position is affected by scrolling.

drawinhand(IMAGE, [X OFFSET=0], [Y OFFSET=0], [SIZE=1.0])

Parameters:
IMAGE - ID of an image
[X OFFSET=0] - x offset value
[Y OFFSET=0] - y offset value
[SIZE=1.0] - size modification
Draws IMAGE in the hand of the current player.
The weapon is automatically rotated into the right direction. Moreover you can use the recoil command to easily create a recoil effect.
Use X OFFSET and Y OFFSET to change the position relative to the player position. Use SIZE to change the size of the image.
Moreover note that the weapon is always drawn with a vertical (Y) base offset of 3 pixels. This is important to know for spawning projectiles / drawing a crosshair.

drawline(X1, Y1, X2, Y2, [WIDTH=1])

Parameters:
X1 - start x coordinate
Y1 - start y coordinate
X2 - end x coordinate
Y2 - end y coordinate
[WIDTH=1] - line width/thickness
Draws a line from X1|Y1 to X2|Y2 with the given width (1 pixel by default).

This command is affected by setblend, setcolor and setalpha.

Attention: It is NOT affected by setscale and setrotation! It actually RESETS the scale factors to 1 and the rotation to 0!

endturn()

Ends the current turn and starts the backing time. It's not possible to use or switch the weapon after ending the turn.

firecollision(IMAGE, X, Y)

Parameters:
IMAGE - image ID for collision check
X - x coordinate
Y - y coordinate
Returns:
FIREOBJECT - ID of collided fire object if a collision occurred, else 0
Checks if IMAGE at the (X|Y) coordinate collides with fire.

The returned value is either the ID of a fire object or a 0 if no fire collides.

freeprojectile(ID)

Parameters:
ID - unique projectile ID (return value of createprojectile)
Frees the projectile with the given ID.

getframe()

Returns:
FRAME - frame of this turn
Returns the current frame of this turn. The game runs with 50 FPS. 50 frames = 1 second.

getframesleft()

Returns:
FRAMES LEFT - number of frames left until turn ends
Returns the number of frames which are left in this turn before it ends.

getgravity()

Returns:
GRAVITY - current gravity
Returns the current gravity value.

getmapheight()

Returns:
HEIGHT - map height in pixels
Returns the height of the map in pixels.

getmapwidth()

Returns:
WIDTH - map width in pixels
Returns the width of the map in pixels.

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

getplayeraction(PLAYER)

Parameters:
PLAYER - ID of player, 0 for current
Returns:
ACTION - action state of a player
Returns the action state of a player.
ACTION 0 means that the player is standing on the ground or walking. Other action states mean that he is either jumping or flying through the air.

getplayeralliance(PLAYER)

Parameters:
PLAYER - ID of player, 0 for current
Returns:
ALLIANCE - an alliance from 1 to 8
Returns the ALLIANCE (= color) of PLAYER.
ALLIANCE is a value from 1 to 8. All players with the same ALLIANCE are friends, players with different ALLIANCE are enemies.

The command returns 0 if it failed to get the alliance (for example if PLAYER does not exist).

getplayerdirection(PLAYER)

Parameters:
PLAYER - ID of player, 0 for current
Returns:
DIRECTION - player direction
Returns the direction of PLAYER either as -1 for left or as 1 for right.

getplayerhealth(PLAYER)

Parameters:
PLAYER - ID of player, 0 for current
Returns:
HEALTH - health of player
Returns the health of PLAYER.
Values smaller than 1 mean that PLAYER is dead.
A value of -2147483648 means that PLAYER drowned.

getplayerrotation(PLAYER)

Parameters:
PLAYER - ID of player, 0 for current
Returns:
ANGLE - current weapon rotation angle
Returns the current weapon rotation angle of PLAYER.

getplayerstate(PLAYER, STATE)

Parameters:
PLAYER - ID of player, 0 for current
STATE - a state
Returns:
ACTIVE - 1 if state is active, else 0
Checks if a STATE of a PLAYER is active or not. Returns either 1 for an active state or 0 for an inactive state.

States are:
state_poisoned
state_confused
state_frozen
state_sleeping

getplayerteam(PLAYER)

Parameters:
PLAYER - ID of player, 0 for current
Returns:
TEAM - team ID of this player
Returns the TEAM of PLAYER.

getplayerx(PLAYER)

Parameters:
PLAYER - ID of player, 0 for current
Returns:
X - x coordinate of player
Returns the X coordinate/position of PLAYER.

getplayerxspeed(PLAYER)

Parameters:
PLAYER - ID of player, 0 for current
Returns:
X SPEED - x speed of player
Returns the x speed of PLAYER (flying speed).

getplayery(PLAYER)

Parameters:
PLAYER - ID of player, 0 for current
Returns:
Y - y coordinate of player
Returns the Y coordinate/position of PLAYER.

getplayeryspeed(PLAYER)

Parameters:
PLAYER - ID of player, 0 for current
Returns:
Y SPEED - y speed of player
Returns the y speed of PLAYER (flying speed).

getround()

Returns:
ROUND - current round
Returns the current round. A game starts with round 1. The round is increased when every living character in the game had one turn.

getwatery()

Returns:
Y - y-coordinate where the water starts
Returns the height (y-coordinate) of the water.

The initial water y-coordinate equals getmapheight-10. This is also the highest possible value for the water (=lowest possible water level).

getwind()

Returns:
WIND - current wind speed/direction
Returns the current wind speed and direction.
Positive values indicate that the wind blows rightwards. Negative values stand for wind blowing leftwards.

-0.1 = maximum wind to the left
0.0 = calm (no wind)
+0.1 = maximum wind to the right

hudammobar(AMMO, TOTAL)

Parameters:
AMMO - left ammo value
TOTAL - total ammo value
Draws a 'ammo bar' HUD element which shows how many ammo is left.

hudchargebar(CHARGE, TOTAL)

Parameters:
CHARGE - current charge value
TOTAL - maximum charge value
Draws a 'charge bar' HUD element which shows the charge power of your weapon.
CHARGE has to be <= TOTAL. The bar is full as soon as CHARGE equals TOTAL.

hudcrosshair([X OFFSET=0], [Y OFFSET=0])

Parameters:
[X OFFSET=0] - crosshair x offset
[Y OFFSET=0] - crosshair y offset
Draws a crosshair for the current player. Use X OFFSET and Y OFFSET to adjust the crosshair position.

hudinfo('TEXT', [CURRENT ONLY=1], [RED=255], [GREEN=255], [BLUE=255])

Parameters:
'TEXT' - info text
[CURRENT ONLY=1] - show for current player only?
[RED=255] - color red (0 to 255)
[GREEN=255] - color green (0 to 255)
[BLUE=255] - color blue (0 to 255)
Displays TEXT at the screen.
By default this message is only displayed for the current player. All other players don't see it. Use 0 for CURRENT ONLY if you want everyone to see the message.
The color of TEXT is white by default. You can use the RED, GREEN and BLUE parameters to change this color.

Attention: The weapon selection menu has to be closed to see TEXT!

hudmapborder()

Draws a red border around the map (the same border is also displayed in certain positioning modes)

hudpositioning(MODE, [IMAGE=0], [RANGE=100], [TERRAIN=1], [PLAYERS=1], [OBJECTS=1])

Parameters:
MODE - positioning mode
[IMAGE=0] - optional ID of image which will be positioned
[RANGE=100] - positioning range around the player
[TERRAIN=1] - check col. with terrain
[PLAYERS=1] - check col. with players
[OBJECTS=1] - check col. with objects
Lets the player define a position by left-clicking the map. A valid click will then set some Lua variables.
There are different modes availabe:

pos_normal: free positioning, RANGE doesn't matter, an X marks the position

pos_invisible: same as pos_normal but without the X

pos_build: positioning within RANGE around the player, also displays the borders of the map

pos_range: positioning within RANGE around the player, doesn't show borders of the map

This command affects 3 global weapon variables. As soon as the player clicks a valid position it will set:
weapon_position = 1
weapon_x = clicked X coordinate
weapon_y = clicked Y coordinate

Use IMAGE to define an image which will check collisions at the clicked position. The position will only be accepted when this image does not collide with terrain/players/objects (depending on TERRAIN, PLAYERS and OBJECTS). The image will also be drawn at the players mouse position when using pos_build as MODE. Just use 0 for IMAGE if you do not want to use an image.

hudtimer(INITIAL, [MIN=1], [MAX=5])

Parameters:
INITIAL - initial timer value
[MIN=1] - minimum timer value (1-10)
[MAX=5] - maximum timer value (1-10)
Draws a 'timer bar' HUD element which shows the current weapon timer setting. The setting can be changed in-game with the numeric keys (1,2,3,4,5,6,7,8,9,0[=10]) on the keyboard and will be saved in the global Lua variable weapon_timer.
By default the timer ranges from 1 (minimum) to 5 (maximum).
It will be automatically set to the initial value on each turn/weapon change.

keydown(KEY)

Parameters:
KEY - a key ID
Returns:
DOWN - 1 if key is pressed, else 0
Returns 1 if KEY is pressed, else 0.
Valid values for KEY are:
key_up
key_down
key_left
key_right
key_jump
key_backjump
key_attack

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.

objectcollision()

Returns:
OBJECT - id of a object which collided, or 0
Returns the ID of an object which collided. It returns 0 if no object collided. This command has to be used after the collision command.

objectdamage(OBJECT, DAMAGE)

Parameters:
OBJECT - ID of an object
DAMAGE - damage value
Calls the damage function of OBJECT with the same parameter values.

This command is for custom objects only. It has no effect on built-in objects.

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.

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.

outofscreenarrow(X, Y)

Parameters:
X - x coordinate
Y - y coordinate
Checks if the (X|Y) coordinate is outside of the screen (the currently displayed area). If this is the case it will draw an arrow at the border of the screen which will point at the (X|Y) coordinate.

particle(TYPE, X, Y)

Parameters:
TYPE - particle type
X - x coordinate
Y - y coordinate
Creates a new particle at the (X|Y) coordinate.
The particle can be modified with other particle commands right after creation.

Possible TYPE values are:
p_smoke
p_lightpuff
p_fragment
p_blood
p_bigblood
p_muzzle
p_bubble
p_waterray
p_waterhit
p_bodypart
p_ring
p_firefragment
p_explosion
p_dust
p_flare
p_spark
p_bullet

particlealpha(ALPHA)

Parameters:
ALPHA - alpha from 0.0 to 1.0
Changes the alpha value (transparency) of the last particle created with the particle command.

particlecolor(RED, GREEN, BLUE)

Parameters:
RED - red value from 0 to 255
GREEN - green value from 0 to 255
BLUE - blue value from 0 to 255
Changes the color of the last particle created with the particle command.

particlefadealpha(FADE ALPHA)

Parameters:
FADE ALPHA - a (positive) fade value
Changes the alpha fade value of the last particle created with the particle command.
The alpha value of the particle will be decreased by this value each frame in order to create a fadeout effect.

particlerotation(ROTATION)

Parameters:
ROTATION - rotation angel
Changes the rotation of the last particle created with the particle command.

particlesize(SIZE X, SIZE Y)

Parameters:
SIZE X - x size factor
SIZE Y - y size factor
Changes the size of the last particle created with the particle command.

Attention: The original size scale factor of many particles is NOT 1.0! You have to try around a bit to find the right size.

particlespeed(SPEED X, SPEED Y)

Parameters:
SPEED X - x speed
SPEED Y - y speed
Changes the speed of the last particle created with the particle command.

playercollision()

Returns:
PLAYER - id of a player who collided, or 0
Returns the ID of a player who collided. It returns 0 if no player collided. This command has to be used after the collision command.

playercontrol(CONTROL)

Parameters:
CONTROL - control active (1) or not (0)
(De-)activates the player control. The player will only be controlled if playercontrol is set to 1. The game sets playercontrol to 1 automatically on the start of each turn.
Disable playercontrol if you want to create weapons which can be controlled after launching.

playercurrent()

Returns:
PLAYER - ID of player who is currently controlled
Returns the ID of the player who is currently controlled.

playerdamage(PLAYER, DAMAGE)

Parameters:
PLAYER - ID of player, 0 for current
DAMAGE - damage value
Decreases the health of PLAYER by DAMAGE.

playerforceframe(PLAYER, FRAME)

Parameters:
PLAYER - ID of player, 0 for current
FRAME - player frame (0-11)
Forces the game to render the player with a certain frame, no matter if he is falling/walking/standing/...

Most important frames are:
0 - standing (with arms)
1 - walking frame 1 / standing (no arms)
2 - walking frame 2 (no arms)
3 - jumping (with arms)
4 - falling (with arms)

Note: The frame will be forced for the next render only. You have to call this command continuously to keep that frame. Therefore you should call this command in a draw-function!

playerheal(PLAYER, HEAL)

Parameters:
PLAYER - ID of player, 0 for current
HEAL - heal value
Increases the health of PLAYER by HEAL.

playerposition(PLAYER, X, Y)

Parameters:
PLAYER - ID of player, 0 for current
X - x coordinate
Y - y coordinate
Sets the position of a player to the (X|Y) coordinate.

playerpush(PLAYER, PUSH X, PUSH Y, [ABSOLUTE=0], [PUSH OTHERS=1])

Parameters:
PLAYER - ID of player, 0 for current
PUSH X - x push value
PUSH Y - y push value
[ABSOLUTE=0] - set absolute (1) or add to current values (0)
[PUSH OTHERS=1] - push players on contact (1) or not (0)
Pushs a certain player 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 PUSH OTHERS to control if this push is able to move other players on contact or not.

playerstate(PLAYER, STATE, SET)

Parameters:
PLAYER - ID of player, 0 for current
STATE - a state
SET - enable(1) or disable(0)
Enables (SET=1) or disables (SET=0) a STATE of PLAYER.

States are:
state_poisoned
state_confused
state_frozen
state_sleeping

playerswitch(PLAYER)

Parameters:
PLAYER - ID of player
Passes the control to PLAYER.
PLAYER has to be a player who is in the same team as the current player and who is still living.

playertable([MODE=0], [INC DEAD=1])

Parameters:
[MODE=0] - list mode
[INC DEAD=1] - include dead players (1) or not (0)?
Returns:
PLAYER TABLE - a table containing player IDs
Returns a table/array which contains the IDs of players in the game.

For MODE you can use these values:
0 - list of all players
1 - list of team-members of current player
2 - list of allied players of current player (same and other teams)
3 - list of enemies of current player

Note that all modes - besides mode 0 - exclude the current player (this means that the current player will not appear in the list).

By default all dead players are included. You can exclude them by setting INC DEAD to 0.

playsound(SOUND, [CHANNEL=-1])

Parameters:
SOUND - sound ID
[CHANNEL=-1] - channel for sound control, 0 to 9, or -1 for no channel
Plays a sound.
You can also use one of 10 channels (0-9) which allows you to check when the playback is finished and to stop the sound. Use -1 as CHANNEL if you do not want to use a channel.

print('TEXT')

Parameters:
'TEXT' - a text you want to print
Print a text in the console. The console can be opened with tab.

projectileid()

Returns:
ID - unique projectile ID
Returns the unique ID of the current projectile.
This function only works properly when called within the draw or update Lua function of a projectile!

quake([POWER=15])

Parameters:
[POWER=15] - quake power from 0 to 30
Creates a quake effect. POWER controls the quake strength and duration. Use POWER 0 to stop the quake effect instantly.

Attention: This is just a visual effect. It does not move players or objects.

recoil(STRENGTH)

Parameters:
STRENGTH - recoil strength in pixels
Recoil effect which pushes back the weapon by STRENGTH pixels. This command only takes effect when the weapon is drawn with the command drawinhand.

removeobject(OBJECT)

Parameters:
OBJECT - ID of object
Removes OBJECT.

scroll(X, Y)

Parameters:
X - x coordinate
Y - y coordinate
Scroll the camera to the (X|Y)-coordinate on the map.

setalpha(ALPHA)

Parameters:
ALPHA - 0.0 to 1.0 alpha value
Sets the alpha value. Affects drawimage, drawhud and drawline.
The alpha value defines the transparency.
1.0 = 100% visible
0.0 = 0% visible (=invisible)

setbgcolor(RED, GREEN, BLUE, [ALPHA=1.0], [FADE=0.1])

Parameters:
RED - red value (0 to 255)
GREEN - green value (0 to 255)
BLUE - blue value (0 to 255)
[ALPHA=1.0] - 0.0 to 1.0 alpha mixing value
[FADE=0.1] - 0.001 to 1.0 fade-out speed
Sets the color for the background. The color consists of red, green and blue values.
ALPHA defines how much these colors will be mixed with the original/default background color. It ranges from 0.0 to 1.0.

Examples:
0.0 = 100% original background color
0.5 = 50% original / 50% custom colors
1.0 = 100% custom colors

The command should be called every frame you want the background to have another color. Call it with ALPHA 0.0 or FADE 1.0 to instantly remove the custom background color.

If you don't call it anymore the background will fade back to the original color with the speed of FADE (ALPHA will be decremented by FADE each frame until it reaches zero).

setblend(BLENDMODE)

Parameters:
BLENDMODE - a blend mode you want to use
Changes the blend mode. Affects drawimage, drawhud and drawline.
Possible blendmodes are:
blend_mask - don't draw magenta pixels
blend_solid - draw complete image
blend_alpha - draw transparent
blend_light - draw bright
blend_shade - draw dark

setcolor(RED, GREEN, BLUE)

Parameters:
RED - red value (0 to 255)
GREEN - green value (0 to 255)
BLUE - blue value (0 to 255)
Set the color for an image. The color consists of red, green and blue values which are mixed. Affects drawimage, drawhud and drawline.
Use 255 for RED, GREEN and BLUE (=white) in order to draw images with their original color.

sethandle(IMAGE, X, Y)

Parameters:
IMAGE - ID of an image
X - x handle coordinate
Y - y handle coordinate
Sets the handle (origin for drawing) of IMAGE to the coordinate (X|Y).

Attention: It will lead to problems when you load the same image several times and set different handles for it right after loading. In this case you have to set the handles always before drawing in order to avoid problems.

setmidhandle(IMAGE)

Parameters:
IMAGE - ID of an image
Sets the handle (origin for drawing) of IMAGE to its center.

Attention: It will lead to problems when you load the same image several times and set different handles for it right after loading. In this case you have to set the handles always before drawing in order to avoid problems.

setrotation(ROTATION)

Parameters:
ROTATION - rotation angle (360 degrees)
Changes the rotation for images. Affects drawimage and drawhud.
ROTATION 0 draws images without rotation.

setscale(X SCALE, Y SCALE)

Parameters:
X SCALE - x scale factor
Y SCALE - y scale factor
Changes the scale factor for images. Affects drawimage and drawhud.
Use 1 for X SCALE and Y SCALE in order to draw images at their original size. Use negative values to mirror images.

stopchannel(CHANNEL)

Parameters:
CHANNEL - sound channel from 0 to 9
Stops the playback of a sound in a channel.

terrainalphaimage(IMAGE, X, Y, [ALPHA=1.0], [RED=-1], [GREEN=-1], [BLUE=-1], [ROTATION=0])

Parameters:
IMAGE - ID of an image
X - x coordinate
Y - y coordinate
[ALPHA=1.0] - alpha value
[RED=-1] - use another red value
[GREEN=-1] - use another green value
[BLUE=-1] - use another blue value
[ROTATION=0] - rotation angle?
Mixes IMAGE with the terrain at the (X|Y) coordinate. IMAGE then becomes part of the terrain.
The image will only by drawn on pixels which are terrain and the ALPHA value will be used.
Use the RED, GREEN and BLUE parameters to influence the color. -1 means that the original colors will be used. Values between 0 and 255 mean that these colors will be used instead.
Change ROTATION to draw the image rotated. Attention: Rotating the image is slow and reduces the quality!

terrainbackimage(IMAGE, X, Y, [RED=0], [GREEN=0], [BLUE=0], [ROTATION=0])

Parameters:
IMAGE - ID of an image
X - x coordinate
Y - y coordinate
[RED=0] - modify red value
[GREEN=0] - modify green value
[BLUE=0] - modify blue value
[ROTATION=0] - rotation angle?
Draws IMAGE on the terrain at the (X|Y) coordinate. IMAGE then becomes part of the terrain.
The image will only by drawn on pixels which are sky (looks like it is drawn in the background).
Use the RED, GREEN and BLUE parameters to influence the color. These values will be added to the image pixel colors. 0 means no modification.
Change ROTATION to draw the image rotated. Attention: Rotating the image is slow and reduces the quality!

terraincircle(X, Y, RADIUS, COLOR)

Parameters:
X - x coordinate
Y - y coordinate
RADIUS - radius of the circle
COLOR - color (0xAARRGGBB)
Draws a circle. The (X|Y) coordinate is the center of the circle.

COLOR is a hexadecimal number with
0xAARRGGBB = alpha (sky/terrain)
0xAARRGGBB = red
0xAARRGGBB = green
0xAARRGGBB = blue

You can use values from 00 (0) to FF (255). For the alpha value please only use 00 (sky) or FF (terrain).

Commonly COLOR 0x00000000 is used to erase the the terrain.

terraincollision()

Returns:
COLLISION - 1 if a collision with terrain occured, else 0
Returns 1 if a collision with the terrain occured, else 0. This command has to be used after the collision command.

terrainexplosion(X, Y, RADIUS, [EFFECT=0])

Parameters:
X - x coordinate
Y - y coordinate
RADIUS - explosion radius
[EFFECT=0] - effect type
Destroys the terrain at the (X|Y) coordinate and creates some effects and sounds.

Available effects are:
0: gun impact
1: explosion
2: digging

terrainimage(IMAGE, X, Y, [IGNORE MASK=0], [ROTATION=0])

Parameters:
IMAGE - ID of an image
X - x coordinate
Y - y coordinate
[IGNORE MASK=0] - ignore mask?
[ROTATION=0] - rotation angle
Draws IMAGE into the terrain at the (X|Y) coordinate. IMAGE then becomes part of the terrain.
Use IGNORE MASK 1 if you want to draw the full image including the masked areas / alpha channel.
Change ROTATION to draw the image rotated. Attention: Rotating the image is slow and reduces the quality!

terrainmodification()

Returns:
MODIFICATION - 1 if a terrain modification occurred recently, else 0
Returns a 1 if the terrain shape has been modified recently, otherwise 0.

terrainrect(X, Y, WIDTH, HEIGHT, COLOR)

Parameters:
X - x coordinate
Y - y coordinate
WIDTH - width
HEIGHT - height
COLOR - color (0xAARRGGBB)
Draws an rectangle. The (X|Y) coordinate is the upper left corner of the rectangle.

COLOR is a hexadecimal number with
0xAARRGGBB = alpha (sky/terrain)
0xAARRGGBB = red
0xAARRGGBB = green
0xAARRGGBB = blue

You can use values from 00 (0) to FF (255). For the alpha value please only use 00 (sky) or FF (terrain).

Commonly COLOR 0x00000000 is used to erase the the terrain.

useweapon([ALLOW MORE=0])

Parameters:
[ALLOW MORE=0] - allow to use more? 0/1
Uses the current weapon and decreases its amount.
ALLOW MORE defines if you are allowed to use other weapons afterwards (1) or not (0).

watery(Y)

Parameters:
Y - y-coordinate where the water starts
Changes the height (y-coordinate) of the water.

Attention: You have to DECREASE the value to RAISE the water level. INCREASE the value to LOWER the water level!


The initial water y-coordinate equals getmapheight-10. This is also the highest possible value for the water (=lowest possible water level).

wind(WIND)

Parameters:
WIND - wind speed and direction
Sets the wind speed and direction. WIND has to be a floating point value between -0.1 and 0.1

-0.1 = maximum wind to the left
0.0 = calm (no wind)
+0.1 = maximum wind to the right