LuaAPI.wiki
changeset 1704 09694f0d4e90
parent 1703 c7d3e5459a58
child 1706 5acc46053f37
equal deleted inserted replaced
1703:c7d3e5459a58 1704:09694f0d4e90
   427 
   427 
   428 You can set an optional `layer` to specify which visual gears get drawn on top.
   428 You can set an optional `layer` to specify which visual gears get drawn on top.
   429 
   429 
   430 Most visual gears delete themselves eventually.
   430 Most visual gears delete themselves eventually.
   431 
   431 
   432 *NOTE:* Visual gears *must only* be used for decorational/informational/rendering purposes. *Never* use the visual gear's internal state to manipulate anything gameplay-related. Visual gears are not safe for reliable storage and using them as that would lead to strange bugs.
   432 *NOTE:* Visual gears *must* only be used for decorational/informational/rendering purposes. *Never* use the visual gear's internal state to manipulate anything gameplay-related. Visual gears are not safe for reliable storage and using them as that would lead to strange bugs.
   433 
   433 
   434 *NOTE:* Since 0.9.25, visual gears will never spawn when Hedgewars is run in a testing mode (i.e. not as the real game), so don't rely for visual gears to spawn even if they're critical.
   434 *NOTE:* Since 0.9.25, visual gears will never spawn when Hedgewars is run in a testing mode (i.e. not as the real game), so don't rely for visual gears to spawn even if they're critical.
   435 
   435 
   436 Example:
   436 Example:
   437 
   437 
   783 
   783 
   784 Some visual gears interpret these values differently, just like normal gears. See [VisualGearTypes] for details.  Also, most visual gears are not using all possible values, while some values are just ignored.
   784 Some visual gears interpret these values differently, just like normal gears. See [VisualGearTypes] for details.  Also, most visual gears are not using all possible values, while some values are just ignored.
   785 
   785 
   786 Note that most visual gears require little to no modification of their values.
   786 Note that most visual gears require little to no modification of their values.
   787 
   787 
   788 *NOTE:* *Never* use the visual gear's internal state to manipulate/store anything gameplay-related.  Visual gears are not safe for reliable storage and using them as that would lead to strange bugs.
   788 *NOTE*: *Never* use the visual gear's internal state to manipulate/store anything gameplay-related.  Visual gears are not safe for reliable storage and using them as that would lead to strange bugs.
   789 
   789 
   790 Example 1:
   790 Example 1:
   791 
   791 
   792 <code language="lua">  -- set a circle to position 1000,1000 pulsing from opacity 20 to 200 (8%-78%), radius of 50, 3px thickness, bright red.
   792 <code language="lua">  -- set a circle to position 1000,1000 pulsing from opacity 20 to 200 (8%-78%), radius of 50, 3px thickness, bright red.
   793     SetVisualGearValues(circleUid, 1000,1000, 20, 200, 0, 0, 100, 50, 3, 0xff0000ff)</code>
   793     SetVisualGearValues(circleUid, 1000,1000, 20, 200, 0, 0, 100, 50, 3, 0xff0000ff)</code>
  1194 <code language="lua">
  1194 <code language="lua">
  1195 -- Appends a text to the ammo tooltip of the bazooka but leaves name and main description intact
  1195 -- Appends a text to the ammo tooltip of the bazooka but leaves name and main description intact
  1196 SetAmmoTexts(amBazooka, "This weapon deals double the damage than usually.")</code>
  1196 SetAmmoTexts(amBazooka, "This weapon deals double the damage than usually.")</code>
  1197 
  1197 
  1198 ==== <tt>!AddAmmo(gearUid, ammoType, ammoCount)</tt> ====
  1198 ==== <tt>!AddAmmo(gearUid, ammoType, ammoCount)</tt> ====
  1199 Adds `ammoType` to the specified gear. The amount added is determined by the arguments passed via `SetAmmo()` in the `onAmmoStoreInit()` event handler. `ammoCount` is an optional parameter. If this is set, the ammo will **not** be added, but instead set to `ammoCount`. A value of `0` will remove the weapon, a value of `AMMO_INFINITE` will give infinite ammo.
  1199 Adds `ammoType` to the specified gear. The amount added is determined by the arguments passed via `SetAmmo()` in the `onAmmoStoreInit()` event handler. `ammoCount` is an optional parameter. If this is set, the ammo will *not* be added, but instead set to `ammoCount`. A value of `0` will remove the weapon, a value of `AMMO_INFINITE` will give infinite ammo.
  1200 
  1200 
  1201 Note: By default, ammo is per-team, so calling `AddAmmo` for a hedgehog will give the ammo for the whole team. The game flags `gfPerHogAmmo` and `gfSharedAmmo` change how ammo is managed in the game, so these game flags also affect `AddAmmo`.
  1201 Note: By default, ammo is per-team, so calling `AddAmmo` for a hedgehog will give the ammo for the whole team. The game flags `gfPerHogAmmo` and `gfSharedAmmo` change how ammo is managed in the game, so these game flags also affect `AddAmmo`.
  1202 
  1202 
  1203 ==== <tt>!GetAmmoName(ammoType [, ignoreOverwrite ])</tt> (0.9.23) ====
  1203 ==== <tt>!GetAmmoName(ammoType [, ignoreOverwrite ])</tt> (0.9.23) ====
  1204 Returns the localized name for the specified `ammoType`, taking an ammo name overwritten by `SetAmmoTexts` into account. If `ignoreOverwrite` is `true`, this function will always return the original ammo name of the weapon and ignores names which may have been overwritten by `SetAmmoTexts`.
  1204 Returns the localized name for the specified `ammoType`, taking an ammo name overwritten by `SetAmmoTexts` into account. If `ignoreOverwrite` is `true`, this function will always return the original ammo name of the weapon and ignores names which may have been overwritten by `SetAmmoTexts`.
  1735 === <tt>!ParseCommand(string)</tt> ===
  1735 === <tt>!ParseCommand(string)</tt> ===
  1736 Makes the game client parse and execute the specified internal game engine command.
  1736 Makes the game client parse and execute the specified internal game engine command.
  1737 
  1737 
  1738 The available commands depend on the current engine protocol version. The *engine protocol can (and will) change* between releases.
  1738 The available commands depend on the current engine protocol version. The *engine protocol can (and will) change* between releases.
  1739 
  1739 
  1740 **Important**: If you use `ParseCommand` to overcome a shortcoming in our Lua API (e.g. a missing function), please make sure to [https://issues.hedgewars.org/enter_bug.cgi report the issue].
  1740 *Important*: If you use `ParseCommand` to overcome a shortcoming in our Lua API (e.g. a missing function), please make sure to [https://issues.hedgewars.org/enter_bug.cgi report the issue].
  1741 
  1741 
  1742 With your report we can fix the shortcoming in future releases. We will try to remove the reliance on `ParseCommand` as good as possible. This will allow scripts to use the previously missing feature in a way that won’t break!
  1742 With your report we can fix the shortcoming in future releases. We will try to remove the reliance on `ParseCommand` as good as possible. This will allow scripts to use the previously missing feature in a way that won’t break!
  1743 
  1743 
  1744 There are many available commands, but actual use in scripting is rare, and even then it's discouraged for long-term use. As of 0.9.24, the only command used in official scripts is:
  1744 There are many available commands, but actual use in scripting is rare, and even then it's discouraged for long-term use. As of 0.9.24, the only command used in official scripts is:
  1745 
  1745