Bitfighter  021
The Bitfighter Lua Documentation - Robots, Levelgens, and Plugins
SpeedZone Class Reference

Propels ships at high speed.

Inheritance diagram for SpeedZone:
BfObject

Member Functions

SpeedZone()
 Constructor.
 
SpeedZone(lineGeom)
 Constructor. [details]
 
SpeedZone(lineGeom, speed)
 Constructor. [details]
 
getDir()
 Returns the object's direction. [details]
 
getGeom()
 Returns an object's geometry. [details]
 
getId()
 Gets an object's user assigned id. [details]
 
getObjType()
 Gets an object's ObjType. [details]
 
getOwner()
 Gets an object's owner as a PlayerInfo. [details]
 
getPos()
 Gets an object's position. [details]
 
getSnapping()
 Returns the SpeedZone's snapping parameter. [details]
 
getSpeed()
 Returns the SpeedZone's speed. [details]
 
getTeamIndex()
 Gets the index of the object's team. [details]
 
isSelected()
 Determine if an object is selected in the editor. [details]
 
removeFromGame()
 Removes the object from the current game or editor session. [details]
 
setDir(dest)
 Sets the direction of the SpeedZone. [details]
 
setGeom(geometry)
 Sets an object's geometry. [details]
 
setId(id)
 Sets an object's user assigned id. [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]
 
setSnapping(snapping)
 Sets the SpeedZone's snapping parameter. [details]
 
setSpeed(speed)
 Sets the SpeedZone's speed. [details]
 
setTeam(teamIndex)
 Assigns the object to a team. [details]
 

Detailed Description

Propels ships at high speed.

SpeedZones are game objects that propel ships around a level. Each SpeedZone has a direction point that is only used for aiming the SpeedZone. The speed at which ships are flung can be set with the setSpeed() method. SpeedZones also have a snapping parameter which, when true, will first move the ship to the SpeedZone's center before propelling them. This allows level designers to control the exact path a ship will take, which can be useful if there is a target that the ships should hit.

Note that a SpeedZone's setGeom() method will take two points. The first will be the SpeedZone's location, the second represents its direction. The distance between the two points is not important; only the angle between them matters.

Constructor Documentation

◆ SpeedZone.new()[1/3]

returns SpeedZone

Constructor.

Example:

speedzone = SpeedZone.new()
...
levelgen:addItem(speedzone)
Propels ships at high speed.
Definition: speedZone__cpp.h:7

◆ SpeedZone.new(lineGeom)[2/3]

Arg types: lineGeom: Geom  |  returns SpeedZone

Constructor.

Example:

speedzone = SpeedZone.new(lineGeom)
...
levelgen:addItem(speedzone)

◆ SpeedZone.new(lineGeom, speed)[3/3]

Arg types: lineGeom: Geom, speed: int  |  returns SpeedZone

Constructor.

Example:

speedzone = SpeedZone.new(lineGeom, speed)
...
levelgen:addItem(speedzone)

Member Function Documentation

◆ getDir()

returns point

Returns the object's direction.

The distance between the returned point and the object's location is not important; only the angle between them matters.

Returns
A point object representing the SpeedZone's direction.

◆ getGeom()

Returns an object's geometry.

Returns
A geometry as described on the Geom page

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

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

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

◆ getSnapping()

returns bool

Returns the SpeedZone's snapping parameter.

Returns
true if snapping is enabled, false if not.

◆ getSpeed()

returns int

Returns the SpeedZone's speed.

Returns
A number representing the SpeedZone's speed. Bigger is faster.

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

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

◆ setDir(dest)

Arg types: dest: point  |  returns nothing

Sets the direction of the SpeedZone.

Parameters
destA point which the speed zone should aim at

Example:

s = SpeedZone.new()
s:setDir(100,150)
levelgen:addItem(s) -- or plugin:addItem(s) in a plugin
void setDir(point dest)
Sets the direction of the SpeedZone.
Definition: speedZone__cpp.h:15

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

◆ 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 #.

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

◆ setSnapping(snapping)

Arg types: snapping: bool  |  returns nothing

Sets the SpeedZone's snapping parameter.

When a ship hits a SpeedZone, it is flung at speed in the direction the SpeedZone is pointing. Depending on exactly how the ship approaches the SpeedZone, its trajectory may differ slightly. By enabling snapping, the ship will first be moved to the center of the SpeedZone before its velocity is calculated. This will cause the ship to follow an exact and predictable path, which may be important if there is a specific target you want the ship to hit.

Snapping is off by default.

Parameters
snappingtrue if snapping should be enabled, false otherwise.

◆ setSpeed(speed)

Arg types: speed: int  |  returns nothing

Sets the SpeedZone's speed.

Speed must be a positive number, and will be limited to a maximum of

  1. Default speed is 2000.
Parameters
speedThe speed that the SpeedZone should propel ships.

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