LuaAPI.wiki
changeset 413 6d90d6994e95
parent 412 d2f4b5b9b77c
child 414 14ec7b5cb560
equal deleted inserted replaced
412:d2f4b5b9b77c 413:6d90d6994e95
   354 Spawns a crate which looks exactly like a real utility crate but contains not any ammo. It can be use useful for scripted events or to create a trap.
   354 Spawns a crate which looks exactly like a real utility crate but contains not any ammo. It can be use useful for scripted events or to create a trap.
   355 `explode` and `poison` are booleans.
   355 `explode` and `poison` are booleans.
   356 If `explode` is `true`, the crate will explode when collected.
   356 If `explode` is `true`, the crate will explode when collected.
   357 If `poison` is `true`, the collector will be poisoned.
   357 If `poison` is `true`, the collector will be poisoned.
   358 
   358 
   359 
       
   360 === <tt>!AddTeam(teamname, color, grave, fort, voicepack, flag)</tt> ===
       
   361 
       
   362 <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.
       
   363 </blockquote>
       
   364 Notice: This works only for singleplayer's training missions for now and will desync multiplayer games. Flag setting is dev only.
       
   365 
       
   366 Example:
       
   367 
       
   368 <code lang="lua">    AddTeam("team 1", 14483456, "Simple", "Island", "Default", "hedgewars")</code>
       
   369 === <tt>!AddHog(hogname, botlevel, health, hat)</tt> ===
   359 === <tt>!AddHog(hogname, botlevel, health, hat)</tt> ===
   370 
   360 
   371 <blockquote>Adds a new hedgehog for current team (last created one), with botlevel and specified health also head.
   361 Adds a new hedgehog for current team (last created one with the `AddTeam` function), with bot level and specified health, also hat.
   372 </blockquote>
   362 `botlevel` ranges from `0` to `5`, where `0` denotes a human player and `1` to `5` denote the skill level of a bot.
       
   363 
   373 Notice: This works only for singleplayers training missions for now and will desync multiplayer games.
   364 Notice: This works only for singleplayers training missions for now and will desync multiplayer games.
   374 
   365 
   375 Example:
   366 Example:
   376 
   367 
   377 <code lang="lua">    local player = AddHog("HH 1", 0, 100, "NoHat") -- botlevel 0 means human player
   368 <code lang="lua">    local player = AddHog("HH 1", 0, 100, "NoHat") -- botlevel 0 means human player
   803 ==== <tt>!GetRandom(number)</tt> ====
   794 ==== <tt>!GetRandom(number)</tt> ====
   804 
   795 
   805 <blockquote>Returns a randomly generated number in the range of 0 to number - 1.  This random number uses the game seed, so is synchronised, and thus safe for multiplayer and saved games.  Use GetRandom for anything that could impact the engine state.  For example, a visual gear can use the Lua random, but adding a regular gear should use GetRandom.
   796 <blockquote>Returns a randomly generated number in the range of 0 to number - 1.  This random number uses the game seed, so is synchronised, and thus safe for multiplayer and saved games.  Use GetRandom for anything that could impact the engine state.  For example, a visual gear can use the Lua random, but adding a regular gear should use GetRandom.
   806 </blockquote>
   797 </blockquote>
   807 
   798 
   808 === Clans ===
   799 === Clans and teams ===
       
   800 ==== <tt>!AddTeam(teamname, color, grave, fort, voicepack, flag)</tt> ====
       
   801 
       
   802 <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.
       
   803 </blockquote>
       
   804 Notice: This works only for singleplayer's training missions for now and will desync multiplayer games. Flag setting is dev only.
       
   805 
       
   806 Example:
       
   807 
       
   808 <code lang="lua">    AddTeam("team 1", 0xDD0000, "Simple", "Island", "Default", "hedgewars")</code>
       
   809 
       
   810 ==== <tt>!DismissTeam(teamname)</tt> ====
       
   811 Removes the team with the given team name from the game.
       
   812 
   809 ==== <tt>!GetClanColor(clan)</tt> ====
   813 ==== <tt>!GetClanColor(clan)</tt> ====
   810 
   814 
   811 <blockquote>Returns the colour of the chosen clan by its number.
   815 <blockquote>Returns the colour of the chosen clan by its number.
   812 </blockquote>
   816 </blockquote>
   813 ==== <tt>!SetClanColor(clan, color)</tt> ====
   817 ==== <tt>!SetClanColor(clan, color)</tt> ====