allow lua to specify template by number
authornemo
Tue, 21 Aug 2012 19:40:02 -0400
changeset 7567 da2aa8355d91
parent 7564 651d56a6e568
child 7569 c7d4e035cf9d
allow lua to specify template by number
hedgewars/uLand.pas
hedgewars/uScript.pas
hedgewars/uVariables.pas
--- a/hedgewars/uLand.pas	Tue Aug 21 13:26:26 2012 +0400
+++ b/hedgewars/uLand.pas	Tue Aug 21 19:40:02 2012 -0400
@@ -284,6 +284,8 @@
         3: SelectTemplate:= LargeTemplates[getrandom(Succ(High(LargeTemplates)))];
         4: SelectTemplate:= CavernTemplates[getrandom(Succ(High(CavernTemplates)))];
         5: SelectTemplate:= WackyTemplates[getrandom(Succ(High(WackyTemplates)))];
+// For lua only!
+        6: SelectTemplate:= LuaTemplateNumber;
     end;
 
     WriteLnToConsole('Selected template #'+inttostr(SelectTemplate)+' using filter #'+inttostr(cTemplateFilter));
--- a/hedgewars/uScript.pas	Tue Aug 21 13:26:26 2012 +0400
+++ b/hedgewars/uScript.pas	Tue Aug 21 19:40:02 2012 -0400
@@ -1745,6 +1745,7 @@
 ScriptSetInteger('GameFlags', GameFlags);
 ScriptSetString('Seed', cSeed);
 ScriptSetInteger('TemplateFilter', cTemplateFilter);
+ScriptSetInteger('TemplateNumber', LuaTemplateNumber);
 ScriptSetInteger('MapGen', cMapGen);
 ScriptSetInteger('ScreenHeight', cScreenHeight);
 ScriptSetInteger('ScreenWidth', cScreenWidth);
@@ -1773,6 +1774,7 @@
 // pop game variables
 ParseCommand('seed ' + ScriptGetString('Seed'), true);
 cTemplateFilter  := ScriptGetInteger('TemplateFilter');
+LuaTemplateNumber:= ScriptGetInteger('TemplateNumber');
 cMapGen          := ScriptGetInteger('MapGen');
 GameFlags        := ScriptGetInteger('GameFlags');
 cHedgehogTurnTime:= ScriptGetInteger('TurnTime');
--- a/hedgewars/uVariables.pas	Tue Aug 21 13:26:26 2012 +0400
+++ b/hedgewars/uVariables.pas	Tue Aug 21 19:40:02 2012 -0400
@@ -183,6 +183,8 @@
 
     LuaGoals        : shortstring;
 
+    LuaTemplateNumber : LongInt;
+
     VoiceList : array[0..7] of TVoice =  (
                     ( snd: sndNone; voicepack: nil),
                     ( snd: sndNone; voicepack: nil),
@@ -2623,6 +2625,8 @@
     SDWaterOpacity:= $80;
 
     LuaGoals:= '';
+
+    LuaTemplateNumber:= 0;
 end;
 
 procedure freeModule;