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

Instantly transports ships from here to there.

Inheritance diagram for Teleporter:
BfObject

Member Functions

Teleporter()
 Constructor.
 
Teleporter(simpleLine)
 Constructor. [details]
 
addDest(dest)
 Adds a destination to the teleporter. [details]
 
clearDests()
 Removes all destinations from the teleporter. [details]
 
delDest(index)
 Removes a destination from the teleporter. [details]
 
getDelay()
 
getDest(index)
 Returns the specified destination. [details]
 
getDestCount()
 Returns the number of destinations this teleporter has. [details]
 
getEngineered()
 
getGeom()
 Gets teleporter geometry; differs from standard conventions. [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]
 
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]
 
setDelay(delay)
 Sets the minimum cooldown delay in milliseconds, for when the next ship may enter this teleporter. [details]
 
setEngineered(engineered)
 Sets whether the item can be destroyed when its health reaches zero. [details]
 
setGeom(simpleLine)
 Sets teleporter geometry; differs from standard conventions. [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]
 
setTeam(teamIndex)
 Assigns the object to a team. [details]
 

Detailed Description

Instantly transports ships from here to there.

A Teleporter represents the basic teleporter object. Every teleporter has an intake location and one or more destinations. When a ship enters the teleporter, a destination will be chosen randomly if there is more than one.

Constructor Documentation

◆ Teleporter.new()[1/2]

returns Teleporter

Constructor.

Example:

teleporter = Teleporter.new()
...
levelgen:addItem(teleporter)
Instantly transports ships from here to there.
Definition: Teleporter__cpp.h:7

◆ Teleporter.new(simpleLine)[2/2]

Arg types: simpleLine: Geom  |  returns Teleporter

Constructor.

Example:

teleporter = Teleporter.new(simpleLine)
...
levelgen:addItem(teleporter)

Note that teleporter geom is a strange beast and should be documented here!

Member Function Documentation

◆ addDest(dest)

Arg types: dest: point  |  returns nothing

Adds a destination to the teleporter.

Parameters
destA point or coordinate pair representing the location of the destination.

Example:

t = Teleporter.new()
t:addDest(100,150)
levelgen:addItem(t) -- or plugin:addItem(t) in a plugin
void addDest(point dest)
Adds a destination to the teleporter.
Definition: Teleporter__cpp.h:13

◆ clearDests()

returns nothing

Removes all destinations from the teleporter.

◆ delDest(index)

Arg types: index: int  |  returns nothing

Removes a destination from the teleporter.

Parameters
indexThe index of the destination to delete. If you specify an invalid index, will generate an error.
Note
Remember that in Lua, indices start with 1!

◆ getDelay()

returns bool
Returns
milliseconds between teleporter usages

This is the minimum time a ship must wait to use the teleporter after another ship has just entered

◆ getDest(index)

Arg types: index: int  |  returns point

Returns the specified destination.

Parameters
indexIndex of the dest to return. Will generate an error if index is invalid.
Returns
A point object representing the requested destination.

◆ getDestCount()

returns int

Returns the number of destinations this teleporter has.

Returns
The number of destinations this teleporter has.

◆ getEngineered()

returns bool
Returns
true if the item can be destroyed, false otherwise.

◆ getGeom()

returns Geom

Gets teleporter geometry; differs from standard conventions.

In this case, geometry represents both Teleporter's location and those of all destinations. The first point in the Geom will be the teleporter's intake location. Each destination will be represented by an additional point. In the editor, all teleporters are simple lines, and will return geometries with two points – an origin and a destination.

Returns
geo geometry: New geometry for Teleporter.

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

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

◆ setDelay(delay)

Arg types: delay: num  |  returns nothing

Sets the minimum cooldown delay in milliseconds, for when the next ship may enter this teleporter.

Parameters
delaymilliseconds to delay next teleporter usage. Example: 500 (1/2 second)
Note
This cannot go below 100 milliseconds for practical networking purposes. A setting of 0 will still be 100 milliseconds.

◆ setEngineered(engineered)

Arg types: engineered: bool  |  returns nothing

Sets whether the item can be destroyed when its health reaches zero.

Parameters
engineeredtrue to make the item destructible, false to make it permanent.

◆ setGeom(simpleLine)

Arg types: simpleLine: Geom  |  returns nothing

Sets teleporter geometry; differs from standard conventions.

In this case, geometry represents both Teleporter's location and those of all destinations. The first point specified will be used to set the location. If two or more points are supplied, all existing destinations will be deleted, and the remaining points will be used to define new destinations.

Note that in the editor, teleporters can only have a single destination. Since scripts can add or modify editor items, when the script has finished running, all affected teleporters will be converted into a series of single destination items, all having the same location but with different destinations. (In a game, multi-destination teleporters will remain as created.)

If the teleporter has no destinations, it will not be added to the editor.

Parameters
geometryNew geometry for Teleporter.

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

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