Add WorldEdge to Lua API to expose/change world edge type
authorWuzzy <almikes@aol.com>
Tue, 15 Nov 2016 00:17:31 +0100
changeset 11884 c6eafb6f2735
parent 11883 74e838b7eecc
child 11885 2eac7a96b342
Add WorldEdge to Lua API to expose/change world edge type
ChangeLog.txt
hedgewars/uScript.pas
hedgewars/uUtils.pas
--- a/ChangeLog.txt	Mon Nov 14 21:33:59 2016 +0100
+++ b/ChangeLog.txt	Tue Nov 15 00:17:31 2016 +0100
@@ -60,6 +60,7 @@
 Lua-API:
  + New call: SetCinematicMode(enable) -- e.g. for cutscenes etc.
  + New call: GetAmmoName(ammoType) -- returns the localized name for the specified ammoType
+ + New variable: WorldEdge -- World edge type (weNone, weWrap, weBounce, weSea)
 
 0.9.21 -> 0.9.22
  + New Weapon / Map object: AirMine (floating mine that will follow nearby hedgehogs)
--- a/hedgewars/uScript.pas	Mon Nov 14 21:33:59 2016 +0100
+++ b/hedgewars/uScript.pas	Tue Nov 15 00:17:31 2016 +0100
@@ -2758,6 +2758,7 @@
 ScriptSetInteger('CursorY', CursorPoint.Y);
 ScriptSetInteger('BorderColor', ExplosionBorderColor);
 ScriptSetInteger('GameFlags', GameFlags);
+ScriptSetInteger('WorldEdge', ord(WorldEdge));
 ScriptSetString('Seed', cSeed);
 ScriptSetInteger('TemplateFilter', cTemplateFilter);
 ScriptSetInteger('TemplateNumber', LuaTemplateNumber);
@@ -2794,6 +2795,7 @@
 cMapGen          := TMapGen(ScriptGetInteger('MapGen'));
 cFeatureSize     := ScriptGetInteger('MapFeatureSize');
 GameFlags        := ScriptGetInteger('GameFlags');
+WorldEdge        := TWorldEdge(ScriptGetInteger('WorldEdge'));
 cHedgehogTurnTime:= ScriptGetInteger('TurnTime');
 cCaseFactor      := ScriptGetInteger('CaseFreq');
 cHealthCaseProb  := ScriptGetInteger('HealthCaseProb');
@@ -3152,6 +3154,7 @@
     cg : TCapGroup;
     spr: TSprite;
     mg : TMapGen;
+    we : TWorldEdge;
 begin
 // initialize lua
 luaState:= lua_open;
@@ -3247,6 +3250,9 @@
 for mg:= Low(TMapGen) to High(TMapGen) do
     ScriptSetInteger(EnumToStr(mg), ord(mg));
 
+for we:= Low(TWorldEdge) to High(TWorldEdge) do
+    ScriptSetInteger(EnumToStr(we), ord(we));
+
 ScriptSetInteger('gstDrowning'      , gstDrowning);
 ScriptSetInteger('gstHHDriven'      , gstHHDriven);
 ScriptSetInteger('gstMoving'        , gstMoving);
--- a/hedgewars/uUtils.pas	Mon Nov 14 21:33:59 2016 +0100
+++ b/hedgewars/uUtils.pas	Tue Nov 15 00:17:31 2016 +0100
@@ -42,6 +42,7 @@
 function  EnumToStr(const en : TCapGroup) : shortstring; overload;
 function  EnumToStr(const en : TSprite) : shortstring; overload;
 function  EnumToStr(const en : TMapGen) : shortstring; overload;
+function  EnumToStr(const en : TWorldEdge) : shortstring; overload;
 
 function  Min(a, b: LongInt): LongInt; inline;
 function  MinD(a, b: double) : double; inline;
@@ -296,6 +297,11 @@
 EnumToStr := GetEnumName(TypeInfo(TMapGen), ord(en))
 end;
 
+function EnumToStr(const en: TWorldEdge) : shortstring; overload;
+begin
+EnumToStr := GetEnumName(TypeInfo(TWorldEdge), ord(en))
+end;
+
 
 function Min(a, b: LongInt): LongInt;
 begin