Add SetAmmoDescriptionAppendix to Lua API, see issue 82
authorWuzzy <almikes@aol.com>
Tue, 10 May 2016 01:59:54 +0200
changeset 11941 7ece39a537bd
parent 11940 156f1866b8bd
child 11942 abdb24f0c2d9
Add SetAmmoDescriptionAppendix to Lua API, see issue #82
hedgewars/uScript.pas
hedgewars/uStore.pas
hedgewars/uVariables.pas
--- a/hedgewars/uScript.pas	Tue May 10 01:33:23 2016 +0200
+++ b/hedgewars/uScript.pas	Tue May 10 01:59:54 2016 +0200
@@ -560,6 +560,23 @@
     lc_setammotexts:= 0;
 end;
 
+function lc_setammodescriptionappendix(L : Plua_State) : LongInt; Cdecl;
+const
+    call = 'SetAmmoDescriptionAppendix';
+    params = 'ammoType, descAppend';
+var
+    ammoType: TAmmoType;
+    descAppend: ansistring;
+begin
+    if CheckLuaParamCount(L, 2, call, params) then
+        begin
+        ammoType := TAmmoType(LuaToAmmoTypeOrd(L, 1, call, params));
+        descAppend := lua_tostringA(L, 2);
+        trluaammoa[Ammoz[ammoType].NameId] := descAppend;
+        end;
+    lc_setammodescriptionappendix := 0;
+end;
+
 function lc_enablegameflags(L : Plua_State) : LongInt; Cdecl;
 var i, n : integer;
 begin
@@ -3360,6 +3377,7 @@
 lua_register(luaState, _P'ShowMission', @lc_showmission);
 lua_register(luaState, _P'HideMission', @lc_hidemission);
 lua_register(luaState, _P'SetAmmoTexts', @lc_setammotexts);
+lua_register(luaState, _P'SetAmmoDescriptionAppendix', @lc_setammodescriptionappendix);
 lua_register(luaState, _P'AddCaption', @lc_addcaption);
 lua_register(luaState, _P'SetAmmo', @lc_setammo);
 lua_register(luaState, _P'SetAmmoDelay', @lc_setammodelay);
--- a/hedgewars/uStore.pas	Tue May 10 01:33:23 2016 +0200
+++ b/hedgewars/uStore.pas	Tue May 10 01:59:54 2016 +0200
@@ -996,6 +996,9 @@
 else
     ammodesc := trammod[Ammoz[atype].NameId];
 
+if length(trluaammoa[Ammoz[atype].NameId]) > 0 then
+    ammodesc := ammodesc + '|' + trluaammoa[Ammoz[atype].NameId];
+
 // render window and return the texture
 WeaponTooltipTex:= RenderHelpWindow(ammoname, ammocap, ammodesc, extra, extracolor, SpritesData[sprAMAmmos].Surface, @r)
 end;
--- a/hedgewars/uVariables.pas	Tue May 10 01:33:23 2016 +0200
+++ b/hedgewars/uVariables.pas	Tue May 10 01:59:54 2016 +0200
@@ -2474,6 +2474,7 @@
     trluaammo: array[TAmmoStrId] of ansistring; // name of the weapon (Lua overwrite)
     trluaammoc: array[TAmmoStrId] of ansistring; // caption of the weapon (Lua overwrite)
     trluaammod: array[TAmmoStrId] of ansistring;  // description of the weapon (Lua overwrite)
+    trluaammoa: array[TAmmoStrId] of ansistring; // description appendix of the weapon (Lua only)
     trmsg:   array[TMsgStrId]  of ansistring;   // message of the event
     trgoal:  array[TGoalStrId] of ansistring;   // message of the goal
     cTestLua : Boolean;