LuaAPI: Add SetAmmoDescriptionAppendix, SetAmmoTexts and update GetAmmoName
Sat, 19 Nov 2016 22:19:47 +0000
changeset 918 87e1d0a11e99
parent 917 c05279ae1ac2
child 919 47ff2b524869
LuaAPI: Add SetAmmoDescriptionAppendix, SetAmmoTexts and update GetAmmoName
--- a/	Mon Nov 14 23:53:09 2016 +0000
+++ b/	Sat Nov 19 22:19:47 2016 +0000
@@ -946,13 +946,39 @@
 ==== <tt>!SetAmmoDelay(ammoType, delay)</tt> ====
 Changes the delay of a specified [AmmoTypes Ammo Type].
+==== <tt>!SetAmmoTexts(ammoType, name, caption, description)</tt> (0.9.23) ====
+Allows you to overwrite the displayed name and tooltip descriptions of a given ammo type.
+* `ammoType`: The ammo type to set the text for
+* `name`: Name of the ammo type (e.g. “Grenade” for `amGrenade`), affects both name in ammo menu and in the “ticker” message on the screen top.
+* `caption`: The second line in the ammo menu (below the title). E.g. “Timed grenade” for `amGrenade`.
+* `description`: Description text in ammo menu, below the caption.
+`title`, `caption`, `description` can be `nil`, in which case they will be reverted to the engine default value. This function returns `nil`.
+<code language="lua">
+-- Overwrites bazooka name and description
+SetAmmoTexts(amBazooka, "Spoon Missile", "Crazy weapon", "This crazy weapon looks like a spoon and explodes on impact.|Attack: Hold to launch with more power")</code>
+==== <tt>!SetAmmoDescriptionAppendix(ammoType, descAppend)</tt> (0.9.23) ====
+Will set a string `descAppend` to be appended below the “core” description (ammo tooltip) of the specified `ammoType`, without changing the ordinary description.
+Note that calling this function always sets the complete appended string, you can't use this function to append multiple texts in row.
+This function is recommended if you heave tweaked an existing ammo type only a little and want to keep the original description intact as much as possible.
+<code language="lua">
+-- Appends a text to the ammo tooltip of the bazooka but leaves name and main description intact
+SetAmmoTexts(amBazooka, "This weapon deals double the damage than usually.")</code>
 ==== <tt>!AddAmmo(gearUid, ammoType, ammoCount) (0.9.16) </tt> ====
 Adds `ammoType` to the specified gear. The amount added is determined by the arguments passed via `SetAmmo()` in the `onAmmoStoreInit()` event handler. In 0.9.16 ammo can be set directly via the optional third parameter, `ammoCount`. A value of 0 will remove the weapon, a value of 100 will give infinite ammo.
 *Note:* The effectiveness of this function may be limited due to problems with `gfPerHogAmmo` in Lua scripting.
-==== <tt>!GetAmmoName(ammoType)</tt> (0.9.23) ====
-Returns the localized name for the specified `ammoType`.
+==== <tt>!GetAmmoName(ammoType [, ignoreOverwrite ])</tt> (0.9.23) ====
+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`.
 === Map ===
 ==== <tt>!MapHasBorder()</tt> ====