Lua API: Add SkipTurn() to replace ParseCommand("skip")
authorWuzzy <Wuzzy2@mail.ru>
Mon, 12 Mar 2018 12:27:13 +0100
changeset 13175 98a0edb4bb5a
parent 13174 6869d27a2f3f
child 13176 9f80c08cdae9
Lua API: Add SkipTurn() to replace ParseCommand("skip")
ChangeLog.txt
hedgewars/uScript.pas
share/hedgewars/Data/Maps/ClimbHome/map.lua
share/hedgewars/Data/Scripts/Multiplayer/HedgeEditor.lua
--- a/ChangeLog.txt	Mon Mar 12 02:09:21 2018 +0100
+++ b/ChangeLog.txt	Mon Mar 12 12:27:13 2018 +0100
@@ -103,6 +103,7 @@
  + New call: HealHog(gearUid, healthBoost[, showMessage[, tint]]): Heal hedgehog with graphical effects and message
  + New call: SetTeamLabel(teamname[, label]): Set an arbitrary label for a team, will be displayed next to the team bar
  + New call: SetSoundMask(soundId, isMasked): Allows to disable playing a sound effect from engine
+ + New call: SkipTurn(): Force current hedgehog to skip turn
  + New param: PlaySound accepts 3rd parameter for voices: instaVoice: If true, sound plays instantly instead of being queued
  + New callback: onEndTurn(): Called at the end of a turn (when gears have settled)
  + New hedgehog effect: heArtillery: Per-hedgehog artillery mode (can't walk). Values: 1 = permanently active. 2 = temporarily active (sniper rifle). 0 = not active
--- a/hedgewars/uScript.pas	Mon Mar 12 02:09:21 2018 +0100
+++ b/hedgewars/uScript.pas	Mon Mar 12 12:27:13 2018 +0100
@@ -1926,6 +1926,13 @@
     lc_endturn:= 0
 end;
 
+function lc_skipturn(L : Plua_State): LongInt; Cdecl;
+begin
+    L:= L; // avoid compiler hint
+    ParseCommand('skip', true, true);
+    lc_skipturn:= 0;
+end;
+
 function lc_sendstat(L : Plua_State) : LongInt; Cdecl;
 var statInfo : TStatInfoType;
     i, n     : LongInt;
@@ -3791,6 +3798,7 @@
 lua_register(luaState, _P'GetGearType', @lc_getgeartype);
 lua_register(luaState, _P'EndGame', @lc_endgame);
 lua_register(luaState, _P'EndTurn', @lc_endturn);
+lua_register(luaState, _P'SkipTurn', @lc_skipturn);
 lua_register(luaState, _P'GetTeamStats', @lc_getteamstats);
 lua_register(luaState, _P'SendStat', @lc_sendstat);
 lua_register(luaState, _P'SendGameResultOff', @lc_sendgameresultoff);
--- a/share/hedgewars/Data/Maps/ClimbHome/map.lua	Mon Mar 12 02:09:21 2018 +0100
+++ b/share/hedgewars/Data/Maps/ClimbHome/map.lua	Mon Mar 12 12:27:13 2018 +0100
@@ -260,7 +260,7 @@
 
     if math.random(20) == 1 then AddVisualGear(2012,56,vgtSmoke,0,false) end
     if CurrentHedgehog == dummyHog and dummySkip ~= 0 and dummySkip < GameTime then
-        ParseCommand("/skip")
+        SkipTurn()
         dummySkip = 0
     end
 
--- a/share/hedgewars/Data/Scripts/Multiplayer/HedgeEditor.lua	Mon Mar 12 02:09:21 2018 +0100
+++ b/share/hedgewars/Data/Scripts/Multiplayer/HedgeEditor.lua	Mon Mar 12 12:27:13 2018 +0100
@@ -3789,7 +3789,7 @@
 	if GetHogLevel(CurrentHedgehog) == 0 then
 		TurnTimeLeft = -1	-- is that turntime in your pocket? :D
 	else
-		ParseCommand("skip") -- skip the computer's turn
+		SkipTurn() -- skip the computer's turn
 	end
 
 end