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: projectiles

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

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

hard sync freeprojectile(ID)

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

getprojectileid()

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!

getprojectileinfo(TYPE, 'VALUE')

Parameters:
TYPE - projectile type ID (return value of addprojectile/getprojectiletype)
'VALUE' - Value you want to get ('table','flags','weapon')
Returns:
VALUE - The requested value of a projectile (string)
Gets information from a certain projectile type. TYPE must be the projectile type ID which is returned by the commands addprojectile and getprojectiletype.

VALUE has to be one of the following values:

'table' - returns the Lua table which holds the projectile functions (same table as specified in addprojectile)
'flags' - returns the flags as string (note: projectiles also inherit flags of their parent weapon)
'weapon' - returns the Lua table which holds the parent weapon of this projectile

An empty string is returned if the projectile type does not exist.

getprojectiletype(ID)

Parameters:
ID - unique projectile ID (= return value of createprojectile)
Returns:
TYPE - projectile type ID (= return value of addprojectile)
Returns the TYPE of the projectile with the given ID.

Returns 0 if there is no projectile with that ID.

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!

ATTENTION: This command is obsolete. It's recommended to use "getprojectileid" instead.