-
Notifications
You must be signed in to change notification settings - Fork 0
Lua Library: `tanks`
The tanks library is globally available across all script contexts. Its primary purpose is convenience, and secondarily the ability to have your scripts run across different versions of Tanks with relative ease.
Send a notification to the player using TanksLua's Notification API
-
message: The message to send in the notification. -
duration: The amount of time units that the notification should be visible for. Will default to 200 if left blank.
Send a notification to the player using TanksLua's Notification API
-
sound: The name of the sound to play. -
pitch: The pitch the sound should be played at. Will default to 1 if left blank.
| Name | Type | Description |
|---|---|---|
version |
string |
A string that is equal to the field version in the class tanks.Game. Exists for convenience. |
isModApi |
boolean |
A boolean that will be true if the game is running Lancelot's ModAPI |
tileSize |
number |
A number that is equal to the field tile_size in the class tanks.Game. Exists for convenience. |
Get the Euclidean distance between two Movables
-
a: The first movable -
b: The second movable
- The distance.
Get the squared Euclidean distance between two Movables. More performant than distance as it does not perform a sqrt.
-
a: The firstMovable -
b: The secondMovable
- The squared distance.
Get a table of all Movables in movables in the class tanks.Game.
- Table containing the Movables.
Get the current value of the field playerTank in the class tanks.Game.
- The current player tank.
Convenience function primarily for use in update functions. Checks if the game is considered to be currently "playing". The criteria is as follows:
- The screen is currently an instance of
ScreenGame - The screen's
pausedfield isfalse - The screen's
playingfield istrue - The player tank's
destroyfield isfalse
- Whether the current state meets the criteria.
Check if the two Movables are considered to be allied. The criteria is as follows:
- Their teams both are non-null
- Their teams are both equal to each other
-
a: The firstMovable -
b: The secondMovable
- Whether they are considered allied.
| Name | Type | Description |
|---|---|---|
codes |
{[string]:number} |
A dictionary of input code names to the input codes. Exists for convenience. |
Check if the key keyToCheck is currently held.
-
keyToCheck: The key to check.
- Whether the key is held.
Check if the mouse button buttonToCheck is currently held.
-
buttonToCheck: The button to check.
- Whether the button is held.
| Name | Type | Description |
|---|---|---|
objWidth |
number |
A number that is equal to the field objWidth of the object in the field drawing of tanks.Drawing
|
objHeight |
number |
A number that is equal to the field objHeight of the object in the field drawing of tanks.Drawing
|
objXSpace |
number |
A number that is equal to the field objXSpace of the object in the field drawing of tanks.Drawing
|
objYSpace |
number |
A number that is equal to the field objYSpace of the object in the field drawing of tanks.Drawing
|
Set the current draw color.
-
r: The red value of the color. Should between0and1. -
g: The green value of the color. Should between0and1. -
b: The blue value of the color. Should between0and1. -
a: The alpha value of the color. Should between0and1. Will default to 1 if left blank.
oval (x: number, y: number, width: number, height: number, drawMode: string, coordinateMode: string)
Draw an oval to the screen.
-
x: The X position of the oval. -
y: The Y position of the oval. -
width: The width of the oval. -
height: The height of the oval. -
drawMode: A string that should be either"fill"or"line"to pick whether the oval should be filled in. -
coordinateMode: A string that should be either"interface"or"game"to pick what kind of coordinate system the oval should be drawn in.
rect (x: number, y: number, width: number, height: number, drawMode: string, coordinateMode: string)
Draw a rectangle to the screen.
-
x: The X position of the rectangle. -
y: The Y position of the rectangle. -
width: The width of the rectangle. -
height: The height of the rectangle. -
drawMode: A string that should be either"fill"or"line"to pick whether the rectangleshould be filled in. -
coordinateMode: A string that should be either"interface"or"game"to pick what kind of coordinate system the rectangle should be drawn in.
Either get or set the font size for text drawing.
-
newSize: The number to set the font size to. Should benilif you want to get the font size. -
coordinateMode: A string that should be either"interface"or"game"to pick what kind of coordinate system the font operation should be performed on.
- The current font size, if
newSizeisnil.
Draw text to the screen.
-
x: The X position of the text. -
y: The Y position of the text. -
text: The text to draw. -
coordinateMode: A string that should be either"interface"or"game"to pick what kind of coordinate system the text should be drawn in.
Get the screen size of a given coordinate system.
-
coordinateMode: A string that should be either"interface"or"game"to pick what kind of coordinate system to get the size of.
- The width
- The height
Check if the game is currently hosting a multiplayer party.
- Whether the game is currently hosting a multiplayer party.
Check if the game is currently playing on a multiplayer party hosted by someone else.
- Whether the game is currently playing on a multiplayer party hosted by someone else.