added PlaceGirder to lua
authorHenek
Sat, 05 Mar 2011 13:07:02 +0100
changeset 4985 304d149bb3dd
parent 4984 20da3c5c7dee
child 4986 33fe91b2bcbf
added PlaceGirder to lua
hedgewars/uScript.pas
--- a/hedgewars/uScript.pas	Sat Mar 05 09:34:21 2011 +0300
+++ b/hedgewars/uScript.pas	Sat Mar 05 13:07:02 2011 +0100
@@ -61,6 +61,7 @@
     uCollisions,
     uRenderUtils,
     uTextures,
+    uLandGraphics,
     SDLh; 
 
 var luaState : Plua_State;
@@ -1272,6 +1273,18 @@
         end;
     lc_sethoghat:= 0;
 end;
+
+function lc_placegirder(L : Plua_State) : LongInt; Cdecl;
+begin
+    if lua_gettop(L) <> 3 then
+        LuaError('Lua: Wrong number of parameters passed to PlaceGirder!')
+    else
+        TryPlaceOnLand(
+            lua_tointeger(L, 1) - SpritesData[sprAmGirder].Width div 2,
+            lua_tointeger(L, 2) - SpritesData[sprAmGirder].Height div 2,
+            sprAmGirder, lua_tointeger(L, 3), true, false);
+    lc_placegirder:= 0
+end;
 ///////////////////
 
 procedure ScriptPrintStack;
@@ -1691,6 +1704,7 @@
 lua_register(luaState, 'MapHasBorder', @lc_maphasborder);
 lua_register(luaState, 'GetHogHat', @lc_gethoghat);
 lua_register(luaState, 'SetHogHat', @lc_sethoghat);
+lua_register(luaState, 'PlaceGirder', @lc_placegirder);
 
 
 ScriptClearStack; // just to be sure stack is empty