Add information about the “color” parameter found in some functions.
authoralmikes@aol.com
Sat, 13 Dec 2014 15:32:42 +0000
changeset 477 8c326a00ead3
parent 476 dd4470df66ad
child 478 7b95addbe9fc
Add information about the “color” parameter found in some functions.
LuaAPI.wiki
--- a/LuaAPI.wiki	Sat Dec 13 15:21:20 2014 +0000
+++ b/LuaAPI.wiki	Sat Dec 13 15:32:42 2014 +0000
@@ -32,7 +32,6 @@
 It is possible to play missions in multiplayer. However this requires all participating players to have the exact same version of the map files, including the "map.lua" script file. If this isn't the case the game will probably desync and kick at least the one player using a different version of the map files. To avoid problems when running prepackaged maps, you should never modify any maps provided with the Hedgewars default package. Instead, create a copy of the existing map and modify this one. Feel free to share your work on the forums.
 Another thing to note is the current status of our scripting implementation. Similar to the whole game, this is still work in progress and we can't guarantee that scripts working in this version will run in future revisions of the game as we might extend, change or rename parts of the scripting engine.
 
-
 === Global variables/constants ===
 Global variables are used by the game to interact with the scripts by passing and retrieving their values. While some of the variables are never read by the engine some allow you to modify the engine's behaviour, e.g. the theme to be used for the current map.
 
@@ -40,6 +39,23 @@
 === Functions called by the game: Event Handlers ===
 After successfully loading the Lua script the game will call the following functions on different occasions. To be used, they have to use the exact same name as defined below.
 
+== Color ==
+Some functions take a `color` parameter.
+
+Colors are stored in RGB and are always specified as a three-byte number, where each byte defines a component. The value 0 means no intensity and 255 is largest intensity of the component.
+The first byte is for the red component, the second byte for the green component and the third byte for the blue component.
+
+Specifying the color number becomes much easier if you write it in hexadecimal notation.
+
+Examples:
+<code language="lua">
+c = 0x000000 -- black (R, G, B are all 0)
+c = 0xFF0000 -- red
+c = 0x00FF00 -- green
+c = 0x0000FF -- blue
+c = 0xFFFFFF -- white
+c = 0x808080 -- gray (50%)</code>
+
 
 == Global available Constants ==
 
@@ -887,7 +903,7 @@
 Arguments:
 
  * `teamname`: The name of the team.
- * `color`: The color of the team, provided as a 3-byte number
+ * `color`: The color of the team as defined in [LuaAPI#Color]
  * `grave`: The name of the team’s grave (equals file name without the suffix)
  * `fort`: The name of the team’s fort
  * `voicepack`: The name of the team’s voice pack (equals the directory name)
@@ -905,13 +921,11 @@
 Removes the team with the given team name from the game.
 
 ==== <tt>!GetClanColor(clan)</tt> ====
+Returns the color of the chosen clan by its number. The color data type is described in [LuaAPI#Color]
 
-<blockquote>Returns the colour of the chosen clan by its number.
-</blockquote>
 ==== <tt>!SetClanColor(clan, color)</tt> ====
+Sets the color of the chosen clan by its number. The color data type is described in [LuaAPI#Color]
 
-<blockquote>Sets the colour of the chosen clan by its number.
-</blockquote>