Expose TargetX/TargetY to scripting
authornemo
Sun, 07 Aug 2011 12:40:14 -0400
changeset 5517 80bc6c0be5d4
parent 5515 3768e9a6ec40
child 5518 4b0ea752dec7
Expose TargetX/TargetY to scripting
hedgewars/uScript.pas
--- a/hedgewars/uScript.pas	Sun Aug 07 12:25:21 2011 -0400
+++ b/hedgewars/uScript.pas	Sun Aug 07 12:40:14 2011 -0400
@@ -1214,6 +1214,44 @@
     lc_setgearposition:= 0
 end;
 
+function lc_getgeartarget(L : Plua_State) : LongInt; Cdecl;
+var gear: PGear;
+begin
+    if lua_gettop(L) <> 1 then
+        begin
+        LuaError('Lua: Wrong number of parameters passed to GetGearTarget!');
+        lua_pushnil(L);
+        lua_pushnil(L)
+        end
+    else
+        begin
+        gear:= GearByUID(lua_tointeger(L, 1));
+        if gear <> nil then
+            begin
+            lua_pushinteger(L, gear^.TargetX);
+            lua_pushinteger(L, gear^.TargetY)
+            end
+        end;
+    lc_getgeartarget:= 2;
+end;
+
+function lc_setgeartarget(L : Plua_State) : LongInt; Cdecl;
+var gear: PGear;
+begin
+    if lua_gettop(L) <> 3 then
+        LuaError('Lua: Wrong number of parameters passed to SetGearTarget!')
+    else
+        begin
+        gear:= GearByUID(lua_tointeger(L, 1));
+        if gear <> nil then
+            begin
+            gear^.TargetX:= lua_tointeger(L, 2);
+            gear^.TargetY:= lua_tointeger(L, 3)
+            end
+        end;
+    lc_setgeartarget:= 0
+end;
+
 function lc_getgearvelocity(L : Plua_State) : LongInt; Cdecl;
 var gear: PGear;
 begin
@@ -1843,6 +1881,8 @@
 lua_register(luaState, 'FindPlace', @lc_findplace);
 lua_register(luaState, 'SetGearPosition', @lc_setgearposition);
 lua_register(luaState, 'GetGearPosition', @lc_getgearposition);
+lua_register(luaState, 'SetGearTarget', @lc_setgeartarget);
+lua_register(luaState, 'GetGearTarget', @lc_getgeartarget);
 lua_register(luaState, 'SetGearVelocity', @lc_setgearvelocity);
 lua_register(luaState, 'GetGearVelocity', @lc_getgearvelocity);
 lua_register(luaState, 'ParseCommand', @lc_parsecommand);