Help Home

Tutorials

Weapon Scr. I
Weapon Scr. II
Missions

Reference

All Commands
General
Load/Add
Graphics
HUD
Sounds
Player
Terrain
Projectiles
Particles
Collision
Objects
AI
Nodes
Missions

Commands: general

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!)
  • hard sync - command is hard synced

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.

hard sync changeturntime(TIME)

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

endturn()

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

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.

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 at least one turn.
Note that some characters may have multiple turns in one round. This happens when one team has more players than another.

getturn([MODE=0])

Parameters:
[MODE=0] - define the turn data you want to get (0=absolute turn number, 1=current turn of round, 2=turns in round)
Returns:
TURN - current turn (or -1 when being in "manual positioning"-mode)
With MODE 0 (default) it returns the current turn. A game starts with turn 1. The turn is increased when a player finishes a turn.

There is one special case for this command:
It will always return -1 when being in the "manual positioning"-mode (this mode will be active when manual player positioning is activated and players need to be placed).

There are also 2 other modes:

In mode 1 you will get the current turn of the current round.

In mode 2 you will get the total number of turns of the current round.

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

getweaponcount('TABLE', TEAM)

Parameters:
'TABLE' - Lua table which holds the weapon functions
TEAM - Team ID
Returns:
COUNT - The weapon count for the specified team
Returns the count of a weapon for TEAM.

getweaponinfo('TABLE', 'VALUE')

Parameters:
'TABLE' - Lua table which holds the weapon functions
'VALUE' - Value you want to get ('name','flags','image','x','y','group','firstuse')
Returns:
VALUE - The requested value of a weapon (can be an integer or string)
Gets information from a certain weapon. TABLE must be the table of an existing weapon ('cc.axe' for example).

VALUE has to be one of the following values:

'id' - returns the internal weapon ID (same as the value returned by addweapon)
'name' - returns the name of the weapon as string
'flags' - returns the flags as string
'image' - returns the image icon id as integer
'x' - returns the X position in the weaponset as integer, ranging from 0 to 13
'y' - returns the Y position in the weaponset as integer, ranging from 0 to 8
'group' - returns the weapon menu group as integer, ranging from 0 to 2
'firstuse' - returns the round were you are able to use this weapon the first time as integer

getweaponlist()

Returns:
WEAPON TABLE - A Lua table containing weapon table names
Returns a table/array which contains the table names of all loaded weapons. The index starts at 1!

You can use the table names with the command getweaponinfo to get more weapon details.

Sample:
w=getweaponlist()
for i=1,#w do
print(w[i])
end

getweaponlock('TABLE', TEAM)

Parameters:
'TABLE' - Lua table which holds the weapon functions
TEAM - Team ID
Returns:
LOCKED - boolean, true if weapon is locked, else false
Returns the lock-state of a weapon for TEAM.

true if the weapon is locked.
false if the weapon is not locked.

Locked weapons can not be selected by the player.

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

keydown(KEY)

Parameters:
KEY - a key ID
Returns:
DOWN - 1 if key is pressed down, else 0
Returns 1 if KEY is currently pressed down, else 0.

Valid values for KEY are:
key_up
key_down
key_left
key_right
key_jump
key_backjump
key_attack

keyhit(KEY)

Parameters:
KEY - a key ID
Returns:
HIT - 1 if key has just been hit, else 0
Returns 1 if KEY has just been hit (was not pressed down before but is now), else 0.

Valid values for KEY are:
key_up
key_down
key_left
key_right
key_jump
key_backjump
key_attack

keyrelease(KEY)

Parameters:
KEY - a key ID
Returns:
RELEASED - 1 if key has just been released, else 0
Returns 1 if KEY has just been released (was pressed down before but isn't anymore now), else 0.

Valid values for KEY are:
key_up
key_down
key_left
key_right
key_jump
key_backjump
key_attack

print('TEXT')

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

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.

random(V1, [V2])

Parameters:
V1 - minimum (or maximum) value
[V2] - maximum value
Returns:
RANDOM FLOAT - a random floating point value in the specified range
Returns a cross-platform synchronous random number.

Don't forget to use randomseed with synchronous values first!

Always use this command if you need synchronous random values. The built in random function of Lua (math.random) does NOT deliver the same random values on different platforms and is therefore not recommended.

There are 3 ways to call this function:

- no parameters: a random float between 0.0 and 1.0
- one parameters: a random float between 1.0 and V1
- two parameters: a random float between V1 and V2

(All mentioned values are INCLUSIVE. The "no paramters" case can also deliver 1.0 and 0.0 for instance!)

randomseed(SEED)

Parameters:
SEED - a number to setup the random number generator
Sets up the cross-platform synchronous random number generator. Use the random command afterwards.

IMPORTANT: Use synchronous values to synchronize the random generator on all systems. Good values are:
getframe()*CONSTANT
getround()*CONSTANT
(with CONSTANT beeing a constant value like -123 or 652 or 3773)

All random-command calls will generate the same random numbers on all platforms afterwards.

Do not use other commands in between because they may confuse the random number sequence.

You can still use math.random and math.randomseed which are the native random functions of Lua - but these functions will deliver different values on different platforms. So you should only use them for unimportant stuff like particle effects.

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.

screenheight()

Returns:
HEIGHT - height of the screen in pixels
Returns the height of the screen (in-game screen resolution) in pixels.

screenwidth()

Returns:
WIDTH - width of the screen in pixels
Returns the width of the screen (in-game screen resolution) in pixels.

scroll(X, Y)

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

hard sync setweaponcount('TABLE', TEAM, COUNT)

Parameters:
'TABLE' - Lua table which holds the weapon functions
TEAM - Team ID
COUNT - The new weapon count (0-99 or 100 for infinite count)
Sets the count of a weapon for TEAM. Use COUNT 100 for an infinite weapon count.

hard sync setweaponlock('TABLE', TEAM, LOCKED)

Parameters:
'TABLE' - Lua table which holds the weapon functions
TEAM - Team ID
LOCKED - The lock state, 1 (or true) to lock, 0 (or false) to unlock
Sets the lock-state of a weapon for TEAM.

1 (true) to lock a weapon.
0 (false) to unlock a weapon.

Locked weapons can not be selected by the player.

useweapon([ALLOW MORE=0])

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

ALLOW MORE 2 also allows you to decrease the amount of a weapon several times without the need to select it again from the weapon menu.

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

hard sync 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