Allow scripting to delete gears
authornemo
Wed, 08 Aug 2012 10:26:10 -0400
changeset 7517 f287f00063e8
parent 7515 8957b05d368a
child 7519 14261378d074
Allow scripting to delete gears
hedgewars/uConsts.pas
hedgewars/uGears.pas
hedgewars/uScript.pas
--- a/hedgewars/uConsts.pas	Tue Aug 07 13:21:15 2012 -0400
+++ b/hedgewars/uConsts.pas	Wed Aug 08 10:26:10 2012 -0400
@@ -245,6 +245,7 @@
 
     gmRemoveFromList = $00004000;
     gmAddToList      = $00008000;
+    gmDelete         = $00010000;
     gmAllStoppable = gmLeft or gmRight or gmUp or gmDown or gmAttack or gmPrecise;
 
     cMaxSlotIndex       = 9;
--- a/hedgewars/uGears.pas	Tue Aug 07 13:21:15 2012 -0400
+++ b/hedgewars/uGears.pas	Wed Aug 08 10:26:10 2012 -0400
@@ -207,6 +207,8 @@
     curHandledGear:= t;
     t:= curHandledGear^.NextGear;
 
+    if curHandledGear^.Message and gmDelete <> 0 then
+        DeleteGear(curHandledGear);
     if curHandledGear^.Message and gmRemoveFromList <> 0 then 
         begin
         RemoveGearFromList(curHandledGear);
--- a/hedgewars/uScript.pas	Tue Aug 07 13:21:15 2012 -0400
+++ b/hedgewars/uScript.pas	Wed Aug 08 10:26:10 2012 -0400
@@ -412,7 +412,7 @@
         begin
         gear:= GearByUID(lua_tointeger(L, 1));
         if gear <> nil then
-            DeleteGear(gear);
+            gear^.Message:= gear^.Message or gmDelete;
         end;
     lc_deletegear:= 0
 end;