LuaAPI.wiki
changeset 583 0818d57c392f
parent 579 9895045e9963
child 608 9a49d69316f2
equal deleted inserted replaced
582:96dd549eeead 583:0818d57c392f
    46 This section defines some commonly used non-primitive parameter types which are used in multiple functions. This section is a bit incomplete at the moment.
    46 This section defines some commonly used non-primitive parameter types which are used in multiple functions. This section is a bit incomplete at the moment.
    47 
    47 
    48 === Color ===
    48 === Color ===
    49 Some functions take a `color` parameter.
    49 Some functions take a `color` parameter.
    50 
    50 
    51 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.
    51 Colors are stored in RGB or RGBA format and are specified as a three- or four-byte number, respecively.
       
    52 In 3-byte (RGB) colors, each byte represents a color component. The value 0 means no intensity and 255 is largest intensity of the component.
    52 The first byte is for the red component, the second byte for the green component and the third byte for the blue component.
    53 The first byte is for the red component, the second byte for the green component and the third byte for the blue component.
       
    54 Four-byte (RGBA) colors use the first 3 bytes for the color components (like for the 3-byte colors) and the fourth byte is used for opacity, where 255 means maximum opacity and 0 means fully transparent (also called the “alpha channel”).
    53 
    55 
    54 Specifying the color number becomes much easier if you write it in hexadecimal notation.
    56 Specifying the color number becomes much easier if you write it in hexadecimal notation.
    55 
    57 
    56 Examples:
    58 Examples for RGB (3-byte) colors:
    57 <code language="lua">
    59 <code language="lua">
    58 c = 0x000000 -- black (R, G, B are all 0)
    60 c = 0x000000 -- black (R, G, B are all 0)
    59 c = 0xFF0000 -- red
    61 c = 0xFF0000 -- red
    60 c = 0x00FF00 -- green
    62 c = 0x00FF00 -- green
    61 c = 0x0000FF -- blue
    63 c = 0x0000FF -- blue
   898 You *must* add at least one hedgehog with `AddHog` after calling this. The engine does not support empty teams.
   900 You *must* add at least one hedgehog with `AddHog` after calling this. The engine does not support empty teams.
   899 
   901 
   900 Arguments:
   902 Arguments:
   901 
   903 
   902  * `teamname`: The name of the team.
   904  * `teamname`: The name of the team.
   903  * `color`: The color of the team as defined in [LuaAPI#Color]
   905  * `color`: The RGB color of the team as defined in [LuaAPI#Color]
   904  * `grave`: The name of the team’s grave (equals file name without the suffix)
   906  * `grave`: The name of the team’s grave (equals file name without the suffix)
   905  * `fort`: The name of the team’s fort
   907  * `fort`: The name of the team’s fort
   906  * `voicepack`: The name of the team’s voice pack (equals the directory name)
   908  * `voicepack`: The name of the team’s voice pack (equals the directory name)
   907  * `flag`: Optional argument for the name of the team’s flag (equals file name without the suffix)
   909  * `flag`: Optional argument for the name of the team’s flag (equals file name without the suffix)
   908 
   910 
   916 
   918 
   917 ==== <tt>!DismissTeam(teamname)</tt> ====
   919 ==== <tt>!DismissTeam(teamname)</tt> ====
   918 Removes the team with the given team name from the game.
   920 Removes the team with the given team name from the game.
   919 
   921 
   920 ==== <tt>!GetClanColor(clan)</tt> ====
   922 ==== <tt>!GetClanColor(clan)</tt> ====
   921 Returns the color of the chosen clan by its number. The color data type is described in [LuaAPI#Color].
   923 Returns the RGB color of the chosen clan by its number. The color data type is described in [LuaAPI#Color].
   922 
   924 
   923 ==== <tt>!SetClanColor(clan, color)</tt> ====
   925 ==== <tt>!SetClanColor(clan, color)</tt> ====
   924 Sets the color of the chosen clan by its number. The color data type is described in [LuaAPI#Color].
   926 Sets the RGB color of the chosen clan by its number. The color data type is described in [LuaAPI#Color].
   925 
   927 
   926 === Campaign management ===
   928 === Campaign management ===
   927 ==== <tt>!SaveCampaignVar(varname, value)</tt> ====
   929 ==== <tt>!SaveCampaignVar(varname, value)</tt> ====
   928 Stores the value `value` (a string) into the campaign variable `varname` (also a string). Campaign variables allow you to save progress of a team in a certain campaign. Campaign variables are saved on a per-team per-campaign basis. They are written into the team file (see [ConfigurationFiles#TeamName.hwt]).
   930 Stores the value `value` (a string) into the campaign variable `varname` (also a string). Campaign variables allow you to save progress of a team in a certain campaign. Campaign variables are saved on a per-team per-campaign basis. They are written into the team file (see [ConfigurationFiles#TeamName.hwt]).
   929 
   931 
   935 == Functions affecting the GUI ==
   937 == Functions affecting the GUI ==
   936 
   938 
   937 === <tt>!AddCaption(text)</tt> ===
   939 === <tt>!AddCaption(text)</tt> ===
   938 Display an event text in the upper part of the screen. The text will be white and the caption group will be `capgrpMessage`.
   940 Display an event text in the upper part of the screen. The text will be white and the caption group will be `capgrpMessage`.
   939 
   941 
       
   942 Example:
       
   943 <code language="lua">
       
   944 AddCaption("Hello, world!")
       
   945 </code>
       
   946 
   940 === <tt>!AddCaption(text, color, captiongroup)</tt> ===
   947 === <tt>!AddCaption(text, color, captiongroup)</tt> ===
   941 Display an event text in the upper part of the screen with the specified [LuaAPI#Color color] (4 bytes, the 4th byte is for transparency) and caption group.
   948 Display an event text in the upper part of the screen with the specified RGBA [LuaAPI#Color color] and caption group. Although an RBGA color is used, Hedgewars does not actually support transparent or semi-transparent captions, so the fourth byte is ignored. We recommend you to always specify a full opacity (`FF` in hexadecimal) for the caption.
   942 
   949 
   943 || *`captiongroup`* || *Meaning* ||
   950 || *`captiongroup`* || *Meaning* ||
   944 || `capgrpGameState` || Used for important global game events, like Sudden Death ||
   951 || `capgrpGameState` || Used for important global game events, like Sudden Death ||
   945 || `capgrpAmmoinfo` || Used for new weapon crates and some other events ||
   952 || `capgrpAmmoinfo` || Used for new weapon crates and some other events ||
   946 || `capgrpVolume` || Used when adjusting volume ||
   953 || `capgrpVolume` || Used when adjusting volume ||
   947 || `capgrpMessage` || Generic message ||
   954 || `capgrpMessage` || Generic message ||
   948 || `capgrpMessage2` || Generic message ||
   955 || `capgrpMessage2` || Generic message ||
   949 || `capgrpAmmostate` || Used to show information about weapon state, i.e. bounce level, timer, remaining shots, etc. ||
   956 || `capgrpAmmostate` || Used to show information about weapon state, i.e. bounce level, timer, remaining shots, etc. ||
   950 
   957 
       
   958 Example:
       
   959 <code language="lua">
       
   960 AddCaption("Melon bomb rain in 2 rounds!", 0xFF0000FF, capgrpGameState)
       
   961 -- Green example message.
       
   962 </code>
   951 
   963 
   952 === <tt>!ShowMission(caption, subcaption, text, icon, time)</tt> ===
   964 === <tt>!ShowMission(caption, subcaption, text, icon, time)</tt> ===
   953 Use to tell the player what he is supposed to do.
   965 Use to tell the player what he is supposed to do.
   954 
   966 
   955 As of version 0.9.15, `icon` currently accepts the following values:
   967 As of version 0.9.15, `icon` currently accepts the following values: