Lua API:
authorsheepluva
Sun, 23 Nov 2014 18:16:54 +0100
changeset 10541 7b74aa1bb58d
parent 10540 de6ab85ac761
child 10542 383328755384
Lua API: onSpritePlacement(spriteId, centerX, centerY) onGirderPlacement(frameIdx, centerX, centerY) onRubberPlacement(frameIdx, centerX, centerY)
hedgewars/uLandGraphics.pas
--- a/hedgewars/uLandGraphics.pas	Sun Nov 23 16:13:35 2014 +0100
+++ b/hedgewars/uLandGraphics.pas	Sun Nov 23 18:16:54 2014 +0100
@@ -54,7 +54,7 @@
 function GetPlaceCollisionTex(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt): PTexture;
 
 implementation
-uses SDLh, uLandTexture, uTextures, uVariables, uUtils, uDebug;
+uses SDLh, uLandTexture, uTextures, uVariables, uUtils, uDebug, uScript;
 
 
 procedure calculatePixelsCoordinates(landX, landY: Longint; var pixelX, pixelY: Longint); inline;
@@ -722,7 +722,14 @@
 w:= Min(cpX + Image^.w, LAND_WIDTH) - x;
 y:= Max(cpY, topY);
 h:= Min(cpY + Image^.h, LAND_HEIGHT) - y;
-UpdateLandTexture(x, w, y, h, true)
+UpdateLandTexture(x, w, y, h, true);
+
+ScriptCall('onSpritePlacement', ord(Obj), cpX + w div 2, cpY + h div 2);
+if Obj = sprAmGirder then
+    ScriptCall('onGirderPlacement', frame, cpX + w div 2, cpY + h div 2)
+else if Obj = sprAmRubber then
+    ScriptCall('onRubberPlacement', frame, cpX + w div 2, cpY + h div 2);
+
 end;
 
 function GetPlaceCollisionTex(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt): PTexture;