LuaAPI.wiki
changeset 477 8c326a00ead3
parent 476 dd4470df66ad
child 478 7b95addbe9fc
equal deleted inserted replaced
476:dd4470df66ad 477:8c326a00ead3
    30 
    30 
    31 === Important things to know ===
    31 === Important things to know ===
    32 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.
    32 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.
    33 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.
    33 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.
    34 
    34 
    35 
       
    36 === Global variables/constants ===
    35 === Global variables/constants ===
    37 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.
    36 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.
    38 
    37 
    39   	  	 
    38   	  	 
    40 === Functions called by the game: Event Handlers ===
    39 === Functions called by the game: Event Handlers ===
    41 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.
    40 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.
       
    41 
       
    42 == Color ==
       
    43 Some functions take a `color` parameter.
       
    44 
       
    45 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.
       
    46 The first byte is for the red component, the second byte for the green component and the third byte for the blue component.
       
    47 
       
    48 Specifying the color number becomes much easier if you write it in hexadecimal notation.
       
    49 
       
    50 Examples:
       
    51 <code language="lua">
       
    52 c = 0x000000 -- black (R, G, B are all 0)
       
    53 c = 0xFF0000 -- red
       
    54 c = 0x00FF00 -- green
       
    55 c = 0x0000FF -- blue
       
    56 c = 0xFFFFFF -- white
       
    57 c = 0x808080 -- gray (50%)</code>
    42 
    58 
    43 
    59 
    44 == Global available Constants ==
    60 == Global available Constants ==
    45 
    61 
    46 <blockquote><tt>LAND_WIDTH</tt>, <tt>LAND_HEIGHT</tt>
    62 <blockquote><tt>LAND_WIDTH</tt>, <tt>LAND_HEIGHT</tt>
   885 You *must* add at least one hedgehog with `AddHog` after calling this. The engine does not support empty teams.
   901 You *must* add at least one hedgehog with `AddHog` after calling this. The engine does not support empty teams.
   886 
   902 
   887 Arguments:
   903 Arguments:
   888 
   904 
   889  * `teamname`: The name of the team.
   905  * `teamname`: The name of the team.
   890  * `color`: The color of the team, provided as a 3-byte number
   906  * `color`: The color of the team as defined in [LuaAPI#Color]
   891  * `grave`: The name of the team’s grave (equals file name without the suffix)
   907  * `grave`: The name of the team’s grave (equals file name without the suffix)
   892  * `fort`: The name of the team’s fort
   908  * `fort`: The name of the team’s fort
   893  * `voicepack`: The name of the team’s voice pack (equals the directory name)
   909  * `voicepack`: The name of the team’s voice pack (equals the directory name)
   894  * `flag`: Optional argument (only in development version at the moment) for the name of the team’s flag (equals file name without the suffix)
   910  * `flag`: Optional argument (only in development version at the moment) for the name of the team’s flag (equals file name without the suffix)
   895 
   911 
   903 
   919 
   904 ==== <tt>!DismissTeam(teamname)</tt> ====
   920 ==== <tt>!DismissTeam(teamname)</tt> ====
   905 Removes the team with the given team name from the game.
   921 Removes the team with the given team name from the game.
   906 
   922 
   907 ==== <tt>!GetClanColor(clan)</tt> ====
   923 ==== <tt>!GetClanColor(clan)</tt> ====
   908 
   924 Returns the color of the chosen clan by its number. The color data type is described in [LuaAPI#Color]
   909 <blockquote>Returns the colour of the chosen clan by its number.
   925 
   910 </blockquote>
       
   911 ==== <tt>!SetClanColor(clan, color)</tt> ====
   926 ==== <tt>!SetClanColor(clan, color)</tt> ====
   912 
   927 Sets the color of the chosen clan by its number. The color data type is described in [LuaAPI#Color]
   913 <blockquote>Sets the colour of the chosen clan by its number.
   928 
   914 </blockquote>
       
   915 
   929 
   916 
   930 
   917 
   931 
   918 
   932 
   919 == Functions affecting the GUI ==
   933 == Functions affecting the GUI ==