LuaAPI.wiki
changeset 491 9079444264ae
parent 478 7b95addbe9fc
child 502 7bd6701bb077
equal deleted inserted replaced
490:2b4a9ccb6613 491:9079444264ae
    56 c = 0x0000FF -- blue
    56 c = 0x0000FF -- blue
    57 c = 0xFFFFFF -- white
    57 c = 0xFFFFFF -- white
    58 c = 0x808080 -- gray (50%)</code>
    58 c = 0x808080 -- gray (50%)</code>
    59 
    59 
    60 
    60 
    61 == Global available Constants ==
    61 == Globally available variables and constants ==
    62 
    62 The following variables are made available by Hedgewars in Lua and can be used to quickly query a value. Lua scripts schould normally *not* write to these variables, only read from them.
    63 <blockquote><tt>LAND_WIDTH</tt>, <tt>LAND_HEIGHT</tt>
    63 
    64 </blockquote>
    64 === General variables and constants ===
    65 <blockquote><tt>!ScreenWidth</tt>, <tt>!ScreenHeight</tt>, <tt>!WaterLine</tt></blockquote>
    65 Here are some unsorted variables or constants which are available in Lua. You shouldn’t write to most of them.
    66 
    66 
    67 Game flags:
    67 || *Identifier* || *Description* ||
    68 
    68 || `LAND_WIDTH` || The width of the landscape in pixels ||
    69 <blockquote><tt>gfForts, gfMultiWeapon, gfBorder, gfSolidLand, gfDivideTeams, gfLowGravity, gfLaserSight, gfInvulnerable, gfMines, gfVampiric, gfKarma, gfArtillery, gfOneClanMode, gfRandomOrder, gfKing, gfPlaceHog, gfSharedAmmo, gfDisableGirders, gfExplosives, gfDisableLandObjects, gfAISurvival, gfInfAttack, gfResetWeps, gfResetHealth, gfPerHogAmmo, gfDisableWind, gfMoreWind, gfTagTeam</tt></blockquote>
    69 || `LAND_HEIGHT` || The height of the landscape in pixels ||
    70 
    70 || `WaterLine` || The y position of the water, used to determine at which position stuff drowns. Use `SetWaterLine` to change. ||
    71 *Note:* A few of these, e.g. gfResetHealth (and probably gfTagTeam) are not yet exposed to lua.
    71 || `ClansCount` || Number of clans in the game (teams with the same color belong to one clan) ||
    72 
    72 || `TeamsCount` || Number of teams in the game ||
    73 More constants at [GearTypes Gear Types] , [AmmoTypes Ammo Types], [Sounds], [States], [Sprites], [VisualGearTypes Visual Gear Types]
    73 || `TurnTimeLeft` || Number of game ticks (milliseconds) left until the current turn ends. You can change this variable directly. ||
    74 
    74 || `GameTime` || Number of total game ticks ||
    75 Additional global changing variables accessible:
    75 || `TotalRounds` || Number of rounds that have passed ||
    76 
    76 || `CurrentHedgehog` || The hedgehog gear that is currently in play ||
    77  * <tt>!ClansCount</tt> - number of clans in the game (teams with the same color belong to one clan)
    77 
    78  * <tt>!TeamsCount</tt> - number of teams in the game
    78 === !GameFlags ===
    79  * <tt>!TurnTimeLeft</tt> - number of game ticks left until the current turn ends
    79 The !GameFlags are used to store simple boolean settings of the game. All game flags are stored together in a bitmask. You don’t have to worry about this too much, the functions in [LuaAPI#GameFlags] do all the bitmask handling for you.
    80  * <tt>!GameTime</tt> - number of total game ticks
    80 
    81  * <tt>!TotalRounds</tt> - number of round that has passed
    81 || *Identifier* || *Description (active state)* ||
    82  * <tt>!CurrentHedgehog</tt> - the hedgehog gear that is currently in play
    82 || `gfOneClanMode` || Used when only one clan is in the game. This game flag is primarily used for training missions. ||
       
    83 || `gfMultiWeapon` || TODO (Used in training missions.) ||
       
    84 || `gfForts` || Fort Mode ||
       
    85 || `gfDivideTeams` || The teams will start at opposite sites of the terrain. Two clans maximum. ||
       
    86 || `gfBorder` || An indestrctible border is active around the map. ||
       
    87 || `gfBottomBorder` || There is an indestructable border at the bottom of the map. ||
       
    88 || `gfShoppaBorder` || TODO ||
       
    89 || `gfSolidLand` || The terrain is indestructible. ||
       
    90 || `gfLowGravity` || The gravity is low. ||
       
    91 || `gfLaserSight` || A laser sight is almost always active. ||
       
    92 || `gfInvulnerable` || All hedgehogs are invulnerable. ||
       
    93 || `gfVampiric` || All hedgehogs become vampires and get 80% of the damage they deal as health. ||
       
    94 || `gfKarma` || Attackers share the damage they deal to enemies. ||
       
    95 || `gfArtillery` || Hedgehogs can’t walk. ||
       
    96 || `gfRandomOrder` || The game is played in random order. ||
       
    97 || `gfPlaceHog` || Placement mode: At the beginning of the round, all hedgehogs are placed manually first. ||
       
    98 || `gfKing` || King Mode: One hedgehog per team becomes their king, if the king dies, the team loses. ||
       
    99 || `gfSharedAmmo` || Teams in the same clan share their ammo. ||
       
   100 || `gfDisableGirders` || No girders will be created in random maps ||
       
   101 || `gfDisableLandObjects` || No land objects will be created in random maps ||
       
   102 || `gfAISurvival` || Computer-controlled hedgehogs will be revived after they die. ||
       
   103 || `gfInfAttack` || Attacks don’t end the turn. ||
       
   104 || `gfResetWeps` || The weapons will be reset to the initial state each turn. ||
       
   105 || `gfPerHogAmmo` || Each hedgehog has its own weapon stash. ||
       
   106 || `gfDisableWind` || There is no wind. ||
       
   107 || `gfMoreWind` || There is always strong wind. ||
       
   108 || `gfTagTeam` || Tag Team: Teams in the same clan share their turn time. ||
       
   109 
       
   110 The following !GameFlag is not yet available to Lua:
       
   111 || *Identifier* || *Description (active state)* ||
       
   112 || `gfResetHealth` || The health of all living hedgehogs is reset at the end of each turn. ||
       
   113 
       
   114 === More constants ===
       
   115 More constants are at at [GearTypes Gear Types] , [AmmoTypes Ammo Types], [Sounds], [States], [Sprites], [VisualGearTypes Visual Gear Types]
    83 
   116 
    84 == Event Handlers ==
   117 == Event Handlers ==
    85 
   118 
    86 === <tt>onGameInit()</tt> ===
   119 === <tt>onGameInit()</tt> ===
    87 
   120