Bitfighter  021
The Bitfighter Lua Documentation - Robots, Levelgens, and Plugins
Ship Class Reference
Inheritance diagram for Ship:
MoveObject Item BfObject Robot
Warning
There is no Lua constructor for Ships; they cannot be created from a script. Sorry!
You might be able to do what you want by spawning a Robot.

Member Functions

getActiveWeapon()
 Checks if the given module is active.
 
getAngle()
 Get the angle of the Ship.
 
getCaptureZone()
 Returns capture zone holding the item. [details]
 
getEnergy()
 Gets the enegy of this ship. [details]
 
getFlagCount()
 Get the number of flags carried by this Ship. [details]
 
getGeom()
 Returns an object's geometry. [details]
 
getHealth()
 Returns the health of this ship. [details]
 
getId()
 Gets an object's user assigned id. [details]
 
getLoadout()
 Get the current loadout. [details]
 
getMountedItems()
 Get all Items carried by this Ship. [details]
 
getObjType()
 Gets an object's ObjType. [details]
 
getOwner()
 Gets an object's owner as a PlayerInfo. [details]
 
getPlayerInfo()
 Get the PlayerInfo for this Ship. [details]
 
getPos()
 Gets an object's position. [details]
 
getRad()
 Returns the radius of an item. [details]
 
getShip()
 Returns the ship where the item is mounted. [details]
 
getTeamIndex()
 Gets the index of the object's team. [details]
 
getVel()
 Get the items's velocity. [details]
 
hasFlag()
 Check if this Ship is carrying a flag. [details]
 
isAlive()
 Check if this Ship is alive. [details]
 
isInCaptureZone()
 Is item in a capture zone? [details]
 
isModActive(module)
 Checks if the given module is active. [details]
 
isSelected()
 Determine if an object is selected in the editor. [details]
 
removeFromGame()
 Removes the object from the current game or editor session. [details]
 
setAngle(angle)
 Sets the item's rotation angle. [details]
 
setEnergy(energy)
 Set the current energy of this ship. [details]
 
setGeom(geometry)
 Sets an object's geometry. [details]
 
setHealth(health)
 Set the current health of this ship. [details]
 
setId(id)
 Sets an object's user assigned id. [details]
 
setLoadout(loadout)
 Sets the requested loadout for the ship. [details]
 
setLoadout(w1, w2, w3, m1, m2)
 Convenience alias for setLoadout(table) [details]
 
setLoadoutNow(loadout)
 Immediately sets the loadout for the ship. [details]
 
setOwner(playerName)
 Sets the owner of the object. [details]
 
setPos(pos)
 Set the object's position. [details]
 
setSelected(selected)
 Set whether an object is selected in the editor. [details]
 
setTeam(teamIndex)
 Assigns the object to a team. [details]
 
setVel(vel)
 Sets the item's velocity. [details]
 

Member Function Documentation

◆ getActiveWeapon()

returns Weapon

Checks if the given module is active.

This will return an item of the Weapon enum, e.g. Weapon.Phaser.

Returns
The Weapon that is currently active on this ship.

◆ getAngle()

returns num

Get the angle of the Ship.

Returns
The Ship's angle in radians.

◆ getCaptureZone()

Returns capture zone holding the item.

Many games do not feature capture zones. For those games, this function will always return nil. Currently only FlagItems can be captured.

Returns
Zone where the item has been captured. Returns nil if the item is not in a capture zone.

◆ getEnergy()

returns num

Gets the enegy of this ship.

Energy is specified as a number between 0 and 1 where 0 means no energy and 1 means full energy.

Returns
Returns a value between 0 and 1 indicating the energy of the item.

◆ getFlagCount()

returns int

Get the number of flags carried by this Ship.

Returns
The number of flags carried by this Ship.

◆ getGeom()

Returns an object's geometry.

Returns
A geometry as described on the Geom page

◆ getHealth()

returns num

Returns the health of this ship.

Health is specified as a number between 0 and 1 where 0 is completely dead and 1 is full health.

Returns
Returns a value between 0 and 1 indicating the health of the item.

◆ getId()

Gets an object's user assigned id.

Users can assign an id to elements in the editor with the ! or # keys. Use this function to obtain this id. If the user has not assigned an object an id, getId() will return a negative id that will remain consistent throught the game.

Returns
The object's id.

◆ getLoadout()

returns table

Get the current loadout.

This method will return a table with the loadout in the following order:

Module 1, Module 2, Weapon 1, Weapon 2, Weapon 3

Returns
A table with the current loadout, as described above.

◆ getMountedItems()

returns table

Get all Items carried by this Ship.

Returns
A table of all Items mounted on ship (e.g. ResourceItems and Flags)

◆ getObjType()

Gets an object's ObjType.

obj = TestItem.new()
print(obj:getObjType() == ObjType.TestItem) -- prints 'true'
ObjType getObjType()
Gets an object's ObjType.
Definition: BfObject__cpp.h:9
Large bouncy ball type item.
Definition: moveObject__cpp.h:41

See ObjType for a list of possible return values.

Returns
The object's ObjType.

◆ getOwner()

Gets an object's owner as a PlayerInfo.

Some objects (like projectiles) have an owning player associated. This method returns a PlayerInfo object if there is an owner. Otherwise, returns nil.

This method is intended to be used with bullets and other projectiles, not with game objects like zones.

Returns
A PlayerInfo representing the object's owner, or nil.

◆ getPlayerInfo()

returns PlayerInfo

Get the PlayerInfo for this Ship.

Returns
The PlayerInfo for this Ship.

◆ getPos()

Gets an object's position.

For objects that are not points (such as a LoadoutZone), will return the object's centroid.

Returns
A Point representing the object's position.

◆ getRad()

returns num
inherited from Item

Returns the radius of an item.

Returns
The radius of the item. For a Teleporter, this is the radius of the entrance. For a ForceFieldProjector, this is the radius of the base.

◆ getShip()

Returns the ship where the item is mounted.

Most objects cannot be mounted. For those, this function will always return nil.

Returns
Ship where the item is mounted. Returns nil if the item is not mounted.

◆ getTeamIndex()

Gets the index of the object's team.

Many BfObjects (such as TestItems) are never part of any particular team. For these objects, this method will return Team.Neutral.

Note
Remember that in Lua, indices start with 1!
Returns
Team index of the object.

◆ getVel()

Get the items's velocity.

Returns
The velocity as an axis-aligned vector.

◆ hasFlag()

returns bool

Check if this Ship is carrying a flag.

Returns
true if the Ship is carrying at least one flag, false otherwise.

◆ isAlive()

returns bool

Check if this Ship is alive.

Returns
true if the Ship is present in the game world and still alive, false otherwise.

◆ isInCaptureZone()

returns bool
inherited from Item

Is item in a capture zone?

Returns
true if item is held in a capture zone, false if it is not.

◆ isModActive(module)

Arg types: module: Module  |  returns bool

Checks if the given module is active.

This method takes a Module item as a parameter, e.g. Module.Shield

Parameters
moduleThe Module to check.
Returns
true if the given Module is in active use, false otherwise.

◆ isSelected()

Determine if an object is selected in the editor.

This is useful for editor plugins only.

Returns
Returns true if the object is selected, false if not.

◆ removeFromGame()

returns nothing
inherited from BfObject

Removes the object from the current game or editor session.

May not be implemented for all objects.

◆ setAngle(angle)

Arg types: angle: num  |  returns nothing
inherited from MoveObject

Sets the item's rotation angle.

Set the rotation angle (in radians) of this MoveObject

Parameters
angleA rotation angle in radians

◆ setEnergy(energy)

Arg types: energy: num  |  returns nothing

Set the current energy of this ship.

Energy is specified as a number between 0 and 1 where 0 means no energy and 1 means full energy. Values outside this range will be clamped to the valid range.

Parameters
energyA value between 0 and 1.

◆ setGeom(geometry)

Arg types: geometry: Geom  |  returns nothing
inherited from BfObject

Sets an object's geometry.

Parameters
geometryThe object's new geometry.

Note that not all objects support changing geometry if the object has already been added to a game.

◆ setHealth(health)

Arg types: health: num  |  returns nothing

Set the current health of this ship.

Health is specified as a number between 0 and 1 where 0 is completely dead and 1 is full health. Values outside this range will be clamped to the valid range.

Parameters
healthA value between 0 and 1.
Note
A setting of 0 will kill the ship instantly.

◆ setId(id)

Arg types: id: int  |  returns nothing
inherited from BfObject

Sets an object's user assigned id.

Users can assign an id to elements in the editor with the ! or # keys. Use this function to set this id from Lua. When called from an editor plugin, the value passed will be displayed in the editor when the player presses ! or #.

◆ setLoadout(loadout)[1/2]

Arg types: loadout: table  |  returns nothing

Sets the requested loadout for the ship.

When setting the loadout, normal rules apply for updating the loadout, e.g. moving over a loadout zone.

This method will take a table with 5 entries in any order comprised of 3 weapons and 2 modules.

Note
This method will also take 5 parameters as a new loadout, instead of a table. See setLoadout(Weapon, Weapon, Weapon, Module, Module)
Parameters
loadoutThe new loadout to request.
See also
setLoadoutNow()

◆ setLoadout(w1, w2, w3, m1, m2)[2/2]

Arg types: w1: Weapon, w2: Weapon, w3: Weapon, m1: Module, m2: Module  |  returns nothing

Convenience alias for setLoadout(table)

Parameters
w1The new Weapon for slot 1.
w2The new Weapon for slot 2.
w3The new Weapon for slot 3.
m1The new Module for slot 1.
m2The new Module for slot 2.

◆ setLoadoutNow(loadout)

Arg types: loadout: table  |  returns nothing

Immediately sets the loadout for the ship.

This method does not require that you follow normal loadout-switching rules.

The parameters for this method follow the same rules as Ship::setLoadout().

Parameters
loadoutThe new loadout to set.
See also
setLoadout(loadout)

◆ setOwner(playerName)

Arg types: playerName: string  |  returns nothing
inherited from BfObject

Sets the owner of the object.

Parameters
playerNameName of player as a string.
Note
This method only works if the item in question has already been added to the game via addItem(object). The owner cannot be set beforehand. Also, 'playerName' must exactly match a the name of a player already in the game (case-sensitive).

This method is intended to be used with bullets and other projectiles, not with game objects like zones.

◆ setPos(pos)

Arg types: pos: point  |  returns nothing
inherited from BfObject

Set the object's position.

To set the full geometry of a more complex object, see the setGeom() method.

Parameters
posThe new position of the object.

◆ setSelected(selected)

Arg types: selected: bool  |  returns nothing
inherited from BfObject

Set whether an object is selected in the editor.

This is useful for editor plugins only.

Parameters
selectedtrue to select the object, false to deselect it.

◆ setTeam(teamIndex)

Arg types: teamIndex: int  |  returns nothing
inherited from BfObject

Assigns the object to a team.

Parameters
teamIndexIndex of the team the object should be assigned to. (first team index is 1; there is no team 0)

Instead of a team index, you can use the special team enums Team.Neutral and Team.Hostile.

Limitations:

  • Will have no effect on items that are inherently teamless (such as a NexusZone).
  • Neither Ships nor Robots can be assigned to Team.Neutral or Team.Hostile.

◆ setVel(vel)

Arg types: vel: point  |  returns nothing
inherited from MoveObject

Sets the item's velocity.

As with other functions that take a point as an input, you can also specify the x and y components as numeric arguments.

Parameters
velA point representing item's velocity.