abs(n)
Returns the absolute value of n.
angle_clamp(angle)
Returns angle normalized to [0, 360).
angle_diff(a, b)
Returns the relative angle in (-180, 180) between angle a and b such that (a + angle_diff(a, b)) = b (mod 360)
angle_vector(angle[, length = 1])
Returns a tuple representing the angle with length length.
bindings.afterRender()
This is called after a rendering cycle is complete
bindings.afterUpdate()
This is called after every logic cycle is complete.
(available from version 0.9c)
bindings.gameEnded(reason)
This is called when the game ended and no new game is pending.
reason can be one of the following: EndReason.ServerQuit : the server disconnected. EndReason.Kicked : you were kicked from the server. EndReason.IncompatibleProtocol : you are running a protocol incompatible with the server's. EndReason.IncompatibleData : your data does not match the server's.
(available from version 0.9c)
bindings.gameNetworkInit(connID)
This is called when a new client joins the game. connID is the connection ID of the new client.
The connection ID can be passed to the send() method of a NetworkGameEvent to send events only to the new client.
bindings.playerInit(player)
This is called when a new player is added to the game. player is the Player object that was added.
bindings.playerNetworkInit(player, connID)
This is called when a player is replicated to a new client. player is the player replicated. connID is the connection ID of the new client.
The connection ID can be passed to the send() method of a NetworkPlayerEvent to send events only to the player on the new client.
(available from version 0.9c)
bindings.playerRemoved(player)
This is called when a player is removed from the game. player is the Player object that will be removed.
bindings.playerUpdate(player)
This is called in every logic cycle for every player. player is the relevant Player object.
bindings.viewportRender(viewport, worm)
This is called for every viewport when it's time to render the viewport HUD.
viewport is the Viewport object it should be rendered to and worm is the Worm object of the Player object that owns viewport.
bindings.wormDeath(worm)
This is called when a worm dies. worm is the Worm object that died.
bindings.wormRemoved(worm)
This is called when a worm is removed from the game. worm is the Worm object that will be removed.
bindings.wormRender(x, y, worm, viewport, ownerPlayer)
This is called for every worm and viewport combination when it's time to render the worm HUD.
(x, y) is the position of the worm in viewport coordinates.
worm is the Worm object for which HUD should be rendered and viewport is the Viewport object it should be rendered to. Use the bitmap() method of Viewport to retrieve the relevant bitmap to draw on.
ownerPlayer is the Player object that owns viewport.
connect(address)
Connects to the address passed.
console_register_command(name, function)
Registers the function function as a command in the Gusanos console. When it is called, it will be passed each console parameter as a seperate parameter to the function. The command will be removed automatically when a new map is loaded.
(available from version 0.9c)
console_register_control(name, function)
Registers a number of console commands that work like player controls.
function is a function that is called when the control is activated or deactivated. It is of the form:
function(player, state) end
Where player is the Player object the control applies to, and state is either true or false depending on if the control is activated or deactivated.
The control can be bound to keys like built-in controls such as FIRE and JUMP by binding to the command +Px_name where x is the local player number and name is the name passed to this function.
fetch_server_list(handler)
Fetches the server list from the master server and calls handler with one parameter containing an array of the servers.
floor(n)
Returns the number n rounded down towards infinity.
font_load(name)
Loads and returns a Font object of the font with the passed name.
If the font couldn't be loaded, nil is returned.
game_local_player(i)
Returns a Player object of the local player with index i. If the index is invalid, nil is returned.
game_players()
Returns an iterator object that returns a Player object for every player in the game.
Intended to be use together with a for loop, like this:
for p in game_players() do
-- Do something with p here
end
gfx_draw_box(bitmap, x1, y1, x2, y2, r, g, b)
This function is deprecated in 0.9c and later. Use the draw_box method of Bitmap instead.
gfx_reset_blending()
Deactivates any blender that was active. Everything drawn after this is called will be drawn solid.
gfx_set_add(alpha)
Activates the add blender. alpha is a value in [0, 255] that specifies the scaling factor of things drawn after this is called.
gfx_set_alpha(alpha)
Activates the alpha blender. alpha is a value in [0, 255] that specifies the opacity of things drawn after this is called.
(available from version 0.9c)
gfx_set_alphach(alpha)
Activates the alphach blender. alpha is a value in [0, 255] that specifies the opacity of things drawn after this is called.
host(map)
Hosts a networked game with the current mod and map map.
load_particle(name)
Loads a particle type with the name name and returns it as a ParticleType object.
map(map)
Loads the map map with the current mod.
map_is_blocked(x1, y1, x2, y2)
Returns true if the line between (x1, y1) and (x2, y2) on the map is blocked for particles. Otherwise false.
map_is_loaded()
Returns true if a map is loaded, otherwise false.
map_is_particle_pass(x1, y1)
Returns true if the point (x1, y1) on the map is passable by particles.
maps()
Returns an iterator that iterates through all maps.
network_game_event(name, handler)
Creates and returns a NetworkGameEvent object. name is any string that is unique to this NetworkGameEvent. handler is a function that is called when this event is recieved on this client/server. It has the the form:
function(event, data)
Where event is the NetworkGameEvent returned by network_game_event and data is a bitstream with data sent with the event.
network_particle_event(name, handler)
Creates and returns a NetworkParticleEvent object. name is any string that is unique to this NetworkParticleEvent. handler is a function that is called when this event is recieved on this client/server. It has the the form:
function(event, particle, data)
Where event is the NetworkParticleEvent returned by network_particle_event, particle is the Particle object the event was sent on, and data is a bitstream with data sent with the event.
network_player_event(name, handler)
Creates and returns a NetworkPlayerEvent object. name is any string that is unique to this NetworkPlayerEvent. handler is a function that is called when this event is recieved on this client/server. It has the the form:
function(event, player, data)
Where event is the NetworkPlayerEvent returned by network_player_event, player is the Player object the event was sent on, and data is a bitstream with data sent with the event.
network_worm_event(name, handler)
Creates and returns a NetworkWormEvent object. name is any string that is unique to this NetworkWormEvent. handler is a function that is called when this event is recieved on this client/server. It has the the form:
function(event, worm, data)
Where event is the NetworkWormEvent returned by network_worm_event, worm is the Worm object the event was sent on, and data is a bitstream with data sent with the event.
new_bitstream()
Returns a new Bitstream object.
randomfloat(l, u)
Returns a random floating point number in the interval [l, u].
randomint(l, u)
Returns a random integer in the interval [l, u].
(available from version 0.9c)
sounds
This table returns Sound objects when indexed with a valid sound name, and nil otherwise.
Example:
local mySound = sounds["bazooka.wav"] mySound:play(10, 10)
sprites_load(name)
Loads and returns a SpriteSet object of the sprite set with the passed name.
If the sprite set couldn't be loaded, nil is returned.
sqrt(n)
Returns the squareroot of n.
tcp_connect(addr, port)
Returns a TCPSocket object connecting to addr on port port.
to_time_string(v)
Converts a frame count v to a string showing hours, minutes and seconds as HH:MM:SS.
vector_add(x1, y1, x2, y2)
Returns a tuple equal to (x1 + x2, y1 + y2)
vector_diff(x1, y1, x2, y2)
Returns a tuple equal to (x2 - x1, y2 - y1)
vector_direction(x1, y1, x2, y2)
Returns the angle between (x1, y1) and (x2, y2) in degrees.
vector_distance(x1, y1, x2, y2)
Returns the distance from (x1, y1) to (x2, y2)
weapon_count()
Returns the total number of weapons.
weapon_random()
Returns a random WeaponType object.