=== removed file 'api.html' --- api.html 2018-06-24 17:03:05 +0000 +++ api.html 1970-01-01 00:00:00 +0000 @@ -1,558 +0,0 @@ - - - - Scripting Library - - - - - -
- - Scripting Library -
-
- To use the library, you must first use import armagetron at the beginning of your python script. You must also call armagetron.run() after all of your handler initialization. This function will then go into a loop and parse all of the ladderlog commands for you. Examples are available at the bottom. -
-
-

Namespace armagetron:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
run()Description:Let the library listen to the ladderlog.
send_command(command)Description:Sends a command to the server.
Parameters:command (string) - Command to send to the server. A newline is added automatically.
add_handler(command, handler)Description:Adds a handler that will be called when the specified ladderlog command is received.
Parameters:command (string) - Ladderlog command to attach the handler.

- handler (function) - A callback function in the form of handler(command) where command is a list representing the parameters of the command where the first parameter is the command itself.
remove_handler(command, handler)Description:Removes a handler from a ladderlog command.
Parameters:command (string) - Ladderlog command of the handler.

- handler (function) - The handler to remove.
set_chat_handler(command, handler)Description:Sets the handler for a chat command.
Parameters:command (string) - Chat command (including the beginning slash) to attach the handler.

- handler (function) - A callback function in the form of handler(command) where command is a list representing the command where the first element is the command itself (including the beginning slash), the second element is the player's name who issued the command, the third element is the player's IP address, the fourth element is the player's access level, and the rest are the command arguments.
remove_chat_handler(command)Description:Removes a handler from a chat command (making the command unknown).
Parameters:command (string) - Chat command to remove the handler from (including the beginning slash).
say(message)Description:Sends the SAY command with the message. Appears as "Admin: message" in each player's console.
Parameters:message (string) - Message to say.
console_message(message)Description:Prints message to every player's console.
Parameters:message (string) - Message to send.
center_message(message)Description:Prints message on everybody's screens.
Parameters:message (string) - Message to send.
send_message(player, message)Description:Prints message to the specified player's console.
Parameters:player (string or Player) - Player to send the message.

- message (string) - Message to send.
pause_round()Description:Tell the server to wait before starting a new round.
continue_round()Description:Tell the server to start the round (if it was paused).
set_repository(address)Description:Sets the resource server.
Parameters:address (string) - URI of the resource server.
set_map(resource)Description:Sets the current map.
Parameters:resource (string) - Resource of the map.
include(config)Description:Includes a configuration file.
Parameters:config (string) - Name of the configuration file to include.
rinclude(config)Description:Includes a configuration file from a resource.
Parameters:config (string) - Resource address of the configuration file to include.
reload()Description:Reload's the server's configuration by including the default settings.
end_round()Description:Ends the round by spawning the win/death zone immediately.
-
-
-

Class Grid (instantiated at armagetron.grid):

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
get_team(name)Description:Get a Team object by name.
Parameters:name (string) - Name of the team to get.
Return:team (Team) - Team object with the given name.
get_player(name)Description:Get a Player object by name.
Parameters:name (string) - Name of the player to get.
Return:player (Player) - Player object with the given name.
get_zone(name)Description:Get a Zone object by name.
Parameters:name (string) - Name of the zone to get.
Return:zone (Zone) - Zone object with the given name.
create_zone(name, type, x, y, size, growth=0, xdir=0, ydir=0, interactive=None, r=None, g=None, b=None, target_size=None, rubber=None, player=None, owner=None, target_command=None)Description:Create a new zone.
Parameters:name (string) - Name of the new zone.

- type (string) - Type of the new zone.

- x (float) - The x coordinate of the new zone.

- y (float) - The y coordinate of the new zone.

- size (float) - Size of the new zone.

- growth (float) - Growth of the new zone. Defaults to 0.

- xdir (float) - Change in the x direction of the new zone. Defaults to 0.

- ydir (float) - Change in the y direction of the new zone. Defaults to 0.
Return:zone (Zone) - The newly created zone (also stored internally).
round (int)Description:Current round number.
num_players (int)Description:Number of people playing.
-
-
-

Class Team:

- - - - - - - - - - - - - - - - - - - - - -
name (string)Description:The team's name.
score (int)Description:The team's score.
players (Player[])Description:Dictionary of the team's players indexed by name.
positions (int[])Description:A list of players on the team representing their position. For example, you can get the player in position with positions[0].
-
-
-

Class Player:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
send_message(message)Description:Sends a message to the player's console.
Parameters:message (string) - The message to send.
kill()Description:Kills the player instantly.
kick(reason=None)Description:Kicks a player for a specified reason.
Parameters:reason (string) - The message displayed when the player is kicked. Defaults to None.
ban(time=None, reason=None)Description:Bans a player for the specified time and reason.
Parameters:time (int) - The amount of minutes to ban the player. Defaults to Armagetron's decision.

- reason (string) - The message displayed when the player is banned. Defaults to None.
ban_ip(time=None, reason=None)Description:Bans a player's IP address for a specified time and reason.
Parameters:time (int) - The amount of minutes to ban the player. Defaults to Armagetron's decision.

- reason (string) - The message displayed when the player is banned. Defaults to None.
declare_winner()Description:Sets the player as the winner and ends the round.
teleport(x, y, xdir, ydir)Description:Teleport the player to the specified location. Note: This function works in sty+ct only.
Parameters:x (float) - The x coordinate of the player.

- y (float) - The y coordinate of the player.

- xdir (int) - The x direction of the player. Its value is based on the current axis system. For example, you could put 1 here in four axes to mean go forward on the x axis.

- ydir (int) - The y direction of the player. Its value is based on the current axis system. For example, you could put 1 here in four axes to mean go forward on the y axis.
respawn(x, y, xdir, ydir)Description:Respawns the player at the specified location. Note: This function works in sty+ct only.
Parameters:x (float) - The x coordinate of the player.

- y (float) - The y coordinate of the player.

- xdir (int) - The x direction of the player. Its value is based on the current axis system. For example, you could put 1 here in four axes to mean go forward on the x axis.

- ydir (int) - The y direction of the player. Its value is based on the current axis system. For example, you could put 1 here in four axes to mean go forward on the y axis.
name (string)Description:The player's internal name or login.
screenname (string)Description:The player's visible name, UTF-8 (Python's native) encoded in the case of special characters.
ip (string)Description:The player's IP address.
score (int)Description:The player's score.
alive (bool)Description:Whether or not the player is alive.
-
-
-

Class Zone:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
change_color(r, g, b)Description:Sets the zone's color from an RGB triplet.
Parameters:r (int) - Red part of color.

- g (int) - Green part of color.

- b (int) - Blue part of color.
change_expansion(growth)Description:Sets the zone's growth factor.
Parameters:growth (float) - The zone's growth factor.
change_position(x, y)Description:Sets the zone's position.
Parameters:x (float) - The x coordinate of zone.

- y (float) - The y coordinate of zone.
change_size(size, growth=None)Description:Sets the zone's size and a growth rate to it.
Parameters:size (float) - The zone's size.

- growth (float) - The zone's growth rate to get to that size. Defaults to instantly.
change_speed(xdir, ydir)Description:Set the zone's speed by components.
Parameters:xdir (float) - The zone's x component of the velocity.

- ydir (float) - The zone's y component of the velocity.
set_command(command)Description:Set the command of the target zone.
Parameters:command (string) - Armagetron command to be called when the target zone is entered.
name (string)Description:The zone's name.
type (string)Description:The zone's type.
x (float)Description:The (set) x coordinate of the zone. Note: This will change if xdir is set.
y (float)Description:The (set) y coordinate of the zone. Note: This will change if the ydir is set.
size (float)Description:The (set) size of the zone.
growth (float)Description:The growth of the zone.
xdir (float)Description:The x component of the velocity of the zone.
ydir (float)Description:The y component of the velocity of the zone.
Note: If these parameters are changed outside of the zone's functions (i.e. an Armagetron command), these values will not be accurate.
On destruction, the zone is simply set to collapse.
-
-
-

Examples:

-
-

Reset the settings when everyone leaves the game:

-

-import armagetron
-
-def reload(command):
-  armagetron.reload()
-
-armagetron.add_handler("GAME_END", reload)
-
-armagetron.run()
-			
-
-

Simple echo chat command:

-

-import armagetron
-
-def echo(command):
-  armagetron.send_message(command[1], " ".join(command[4:]))
-
-armagetron.set_chat_handler("/echo", echo)
-
-armagetron.run()
-			
-
-

Map rotation:

-

-import armagetron
-
-maps = [ "Anonymous/polygon/regular/square-1.0.1.aamap.xml", "Anonymous/polygon/regular/40-gon-0.2.aamap.xml", "kyle/other/maze-0.0.1.aamap.xml" ]
-
-index = 0
-
-def change_map(command):
-  global index
-
-  armagetron.pause_round()
-  index++
-  if index > len(maps):
-    index = 0
-  armagetron.set_map(maps[index])
-  armagetron.continue_round()
-
-armagetron.add_handler("NEW_ROUND", change_map)
-
-armagetron.run()
-			
-
- - === added file 'doc.html' --- doc.html 1970-01-01 00:00:00 +0000 +++ doc.html 2018-06-24 21:48:17 +0000 @@ -0,0 +1,558 @@ + + + + Scripting Library + + + + + +
+ + Scripting Library +
+
+ To use the library, you must first use import armagetron at the beginning of your python script. You must also call armagetron.run() after all of your handler initialization. This function will then go into a loop and parse all of the ladderlog commands for you. Examples are available at the bottom. +
+
+

Namespace armagetron:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
run()Description:Let the library listen to the ladderlog.
send_command(command)Description:Sends a command to the server.
Parameters:command (string) - Command to send to the server. A newline is added automatically.
add_handler(command, handler)Description:Adds a handler that will be called when the specified ladderlog command is received.
Parameters:command (string) - Ladderlog command to attach the handler.

+ handler (function) - A callback function in the form of handler(command) where command is a list representing the parameters of the command where the first parameter is the command itself.
remove_handler(command, handler)Description:Removes a handler from a ladderlog command.
Parameters:command (string) - Ladderlog command of the handler.

+ handler (function) - The handler to remove.
set_chat_handler(command, handler)Description:Sets the handler for a chat command.
Parameters:command (string) - Chat command (including the beginning slash) to attach the handler.

+ handler (function) - A callback function in the form of handler(command) where command is a list representing the command where the first element is the command itself (including the beginning slash), the second element is the player's name who issued the command, the third element is the player's IP address, the fourth element is the player's access level, and the rest are the command arguments.
remove_chat_handler(command)Description:Removes a handler from a chat command (making the command unknown).
Parameters:command (string) - Chat command to remove the handler from (including the beginning slash).
say(message)Description:Sends the SAY command with the message. Appears as "Admin: message" in each player's console.
Parameters:message (string) - Message to say.
console_message(message)Description:Prints message to every player's console.
Parameters:message (string) - Message to send.
center_message(message)Description:Prints message on everybody's screens.
Parameters:message (string) - Message to send.
send_message(player, message)Description:Prints message to the specified player's console.
Parameters:player (string or Player) - Player to send the message.

+ message (string) - Message to send.
pause_round()Description:Tell the server to wait before starting a new round.
continue_round()Description:Tell the server to start the round (if it was paused).
set_repository(address)Description:Sets the resource server.
Parameters:address (string) - URI of the resource server.
set_map(resource)Description:Sets the current map.
Parameters:resource (string) - Resource of the map.
include(config)Description:Includes a configuration file.
Parameters:config (string) - Name of the configuration file to include.
rinclude(config)Description:Includes a configuration file from a resource.
Parameters:config (string) - Resource address of the configuration file to include.
reload()Description:Reload's the server's configuration by including the default settings.
end_round()Description:Ends the round by spawning the win/death zone immediately.
+
+
+

Class Grid (instantiated at armagetron.grid):

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
get_team(name)Description:Get a Team object by name.
Parameters:name (string) - Name of the team to get.
Return:team (Team) - Team object with the given name.
get_player(name)Description:Get a Player object by name.
Parameters:name (string) - Name of the player to get.
Return:player (Player) - Player object with the given name.
get_zone(name)Description:Get a Zone object by name.
Parameters:name (string) - Name of the zone to get.
Return:zone (Zone) - Zone object with the given name.
create_zone(name, type, x, y, size, growth=0, xdir=0, ydir=0, interactive=None, r=None, g=None, b=None, target_size=None, rubber=None, player=None, owner=None, target_command=None)Description:Create a new zone.
Parameters:name (string) - Name of the new zone.

+ type (string) - Type of the new zone.

+ x (float) - The x coordinate of the new zone.

+ y (float) - The y coordinate of the new zone.

+ size (float) - Size of the new zone.

+ growth (float) - Growth of the new zone. Defaults to 0.

+ xdir (float) - Change in the x direction of the new zone. Defaults to 0.

+ ydir (float) - Change in the y direction of the new zone. Defaults to 0.
Return:zone (Zone) - The newly created zone (also stored internally).
round (int)Description:Current round number.
num_players (int)Description:Number of people playing.
+
+
+

Class Team:

+ + + + + + + + + + + + + + + + + + + + + +
name (string)Description:The team's name.
score (int)Description:The team's score.
players (Player[])Description:Dictionary of the team's players indexed by name.
positions (int[])Description:A list of players on the team representing their position. For example, you can get the player in position with positions[0].
+
+
+

Class Player:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
send_message(message)Description:Sends a message to the player's console.
Parameters:message (string) - The message to send.
kill()Description:Kills the player instantly.
kick(reason=None)Description:Kicks a player for a specified reason.
Parameters:reason (string) - The message displayed when the player is kicked. Defaults to None.
ban(time=None, reason=None)Description:Bans a player for the specified time and reason.
Parameters:time (int) - The amount of minutes to ban the player. Defaults to Armagetron's decision.

+ reason (string) - The message displayed when the player is banned. Defaults to None.
ban_ip(time=None, reason=None)Description:Bans a player's IP address for a specified time and reason.
Parameters:time (int) - The amount of minutes to ban the player. Defaults to Armagetron's decision.

+ reason (string) - The message displayed when the player is banned. Defaults to None.
declare_winner()Description:Sets the player as the winner and ends the round.
teleport(x, y, xdir, ydir)Description:Teleport the player to the specified location. Note: This function works in sty+ct only.
Parameters:x (float) - The x coordinate of the player.

+ y (float) - The y coordinate of the player.

+ xdir (int) - The x direction of the player. Its value is based on the current axis system. For example, you could put 1 here in four axes to mean go forward on the x axis.

+ ydir (int) - The y direction of the player. Its value is based on the current axis system. For example, you could put 1 here in four axes to mean go forward on the y axis.
respawn(x, y, xdir, ydir)Description:Respawns the player at the specified location. Note: This function works in sty+ct only.
Parameters:x (float) - The x coordinate of the player.

+ y (float) - The y coordinate of the player.

+ xdir (int) - The x direction of the player. Its value is based on the current axis system. For example, you could put 1 here in four axes to mean go forward on the x axis.

+ ydir (int) - The y direction of the player. Its value is based on the current axis system. For example, you could put 1 here in four axes to mean go forward on the y axis.
name (string)Description:The player's internal name or login.
screenname (string)Description:The player's visible name, UTF-8 (Python's native) encoded in the case of special characters.
ip (string)Description:The player's IP address.
score (int)Description:The player's score.
alive (bool)Description:Whether or not the player is alive.
+
+
+

Class Zone:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
change_color(r, g, b)Description:Sets the zone's color from an RGB triplet.
Parameters:r (int) - Red part of color.

+ g (int) - Green part of color.

+ b (int) - Blue part of color.
change_expansion(growth)Description:Sets the zone's growth factor.
Parameters:growth (float) - The zone's growth factor.
change_position(x, y)Description:Sets the zone's position.
Parameters:x (float) - The x coordinate of zone.

+ y (float) - The y coordinate of zone.
change_size(size, growth=None)Description:Sets the zone's size and a growth rate to it.
Parameters:size (float) - The zone's size.

+ growth (float) - The zone's growth rate to get to that size. Defaults to instantly.
change_speed(xdir, ydir)Description:Set the zone's speed by components.
Parameters:xdir (float) - The zone's x component of the velocity.

+ ydir (float) - The zone's y component of the velocity.
set_command(command)Description:Set the command of the target zone.
Parameters:command (string) - Armagetron command to be called when the target zone is entered.
name (string)Description:The zone's name.
type (string)Description:The zone's type.
x (float)Description:The (set) x coordinate of the zone. Note: This will change if xdir is set.
y (float)Description:The (set) y coordinate of the zone. Note: This will change if the ydir is set.
size (float)Description:The (set) size of the zone.
growth (float)Description:The growth of the zone.
xdir (float)Description:The x component of the velocity of the zone.
ydir (float)Description:The y component of the velocity of the zone.
Note: If these parameters are changed outside of the zone's functions (i.e. an Armagetron command), these values will not be accurate.
On destruction, the zone is simply set to collapse.
+
+
+

Examples:

+
+

Reset the settings when everyone leaves the game:

+

+import armagetron
+
+def reload(command):
+  armagetron.reload()
+
+armagetron.add_handler("GAME_END", reload)
+
+armagetron.run()
+			
+
+

Simple echo chat command:

+

+import armagetron
+
+def echo(command):
+  armagetron.send_message(command[1], " ".join(command[4:]))
+
+armagetron.set_chat_handler("/echo", echo)
+
+armagetron.run()
+			
+
+

Map rotation:

+

+import armagetron
+
+maps = [ "Anonymous/polygon/regular/square-1.0.1.aamap.xml", "Anonymous/polygon/regular/40-gon-0.2.aamap.xml", "kyle/other/maze-0.0.1.aamap.xml" ]
+
+index = 0
+
+def change_map(command):
+  global index
+
+  armagetron.pause_round()
+  index++
+  if index > len(maps):
+    index = 0
+  armagetron.set_map(maps[index])
+  armagetron.continue_round()
+
+armagetron.add_handler("NEW_ROUND", change_map)
+
+armagetron.run()
+			
+
+ +