LuaAPI.wiki
changeset 476 dd4470df66ad
parent 461 168508caf60d
child 477 8c326a00ead3
equal deleted inserted replaced
475:0dd8a7078412 476:dd4470df66ad
     4 
     4 
     5 == Introduction ==
     5 == Introduction ==
     6 
     6 
     7 Version 0.9.13 of Hedgewars introduced the ability to use Lua scripts to modify Hedgewars behaviour for different maps without having to recompile the whole game. The till then used triggers (only appeared in training maps) were removed.
     7 Version 0.9.13 of Hedgewars introduced the ability to use Lua scripts to modify Hedgewars behaviour for different maps without having to recompile the whole game. The till then used triggers (only appeared in training maps) were removed.
     8 
     8 
     9 Lua is an easy to learn scripting language that's implemented using open source libraries. If you'd like to learn more about Lua, have a look at [http://www.lua.org Lua's official homepage]. Even though its easy to learn syntax this wiki page won't explain all basics of using Lua, e.g. declaring variables or using control structures. There are tons of step-by-step tutorials and documentation available on the internet. Just throw "Lua" into your favourite search engine and give it a try.
     9 Lua is an easy to learn scripting language that's implemented using open/v source libraries. If you'd like to learn more about Lua, have a look at [http://www.lua.org Lua's official homepage]. Even though its easy to learn syntax this wiki page won't explain all basics of using Lua, e.g. declaring variables or using control structures. There are tons of step-by-step tutorials and documentation available on the internet. Just throw "Lua" into your favourite search engine and give it a try.
    10 
    10 
    11 
    11 
    12 How Hedgewars handles Lua scripts As of Version 0.9.13 Hedgewars supports Lua scripts for two similar tasks: Define tutorial missions or provide special map behaviour for precreated maps.
    12 How Hedgewars handles Lua scripts As of Version 0.9.13 Hedgewars supports Lua scripts for two similar tasks: Define tutorial missions or provide special map behaviour for precreated maps.
    13 
    13 
    14 
    14 
   879 </blockquote>
   879 </blockquote>
   880 
   880 
   881 === Clans and teams ===
   881 === Clans and teams ===
   882 ==== <tt>!AddTeam(teamname, color, grave, fort, voicepack, flag)</tt> ====
   882 ==== <tt>!AddTeam(teamname, color, grave, fort, voicepack, flag)</tt> ====
   883 
   883 
   884 <blockquote>Adds a new team. Note that this can only be done in `onGameInit`, not at a later time. First argument is the team name followed by color, grave, fort, voicepack and flag settings.
   884 Adds a new team. Note that this can only be done in `onGameInit`, not at a later time.
   885 </blockquote>
   885 You *must* add at least one hedgehog with `AddHog` after calling this. The engine does not support empty teams.
   886 Notice: This works only for singleplayer's training missions for now and will desync multiplayer games. Flag setting is dev only.
   886 
   887 
   887 Arguments:
   888 Example:
   888 
   889 
   889  * `teamname`: The name of the team.
   890 <code language="lua">    AddTeam("team 1", 0xDD0000, "Simple", "Island", "Default", "hedgewars")</code>
   890  * `color`: The color of the team, provided as a 3-byte number
       
   891  * `grave`: The name of the team’s grave (equals file name without the suffix)
       
   892  * `fort`: The name of the team’s fort
       
   893  * `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)
       
   895 
       
   896 Note: This works only for singleplayer's training missions for now and will desync multiplayer games.
       
   897 
       
   898 Example:
       
   899 
       
   900 <code language="lua">AddTeam("team 1", 0xDD0000, "Simple", "Tank", "Default", "hedgewars")
       
   901 --[[ Adds a new team with name “team 1”, red color (hexadecimal notation), the grave “Simple”,
       
   902 the fort “Tank” the voicepack “Default” and the flag “hedgewars”. ]]</code>
   891 
   903 
   892 ==== <tt>!DismissTeam(teamname)</tt> ====
   904 ==== <tt>!DismissTeam(teamname)</tt> ====
   893 Removes the team with the given team name from the game.
   905 Removes the team with the given team name from the game.
   894 
   906 
   895 ==== <tt>!GetClanColor(clan)</tt> ====
   907 ==== <tt>!GetClanColor(clan)</tt> ====