merge
authormikade <redgrinner@gmail.com>
Fri, 01 Jun 2012 00:19:30 +0200
changeset 7163 7db1e3a7422a
parent 7156 09262f82e99d (diff)
parent 7161 21a9c70b2070 (current diff)
child 7164 fad64b97947e
merge
--- a/hedgewars/uScript.pas	Thu May 31 12:52:31 2012 -0400
+++ b/hedgewars/uScript.pas	Fri Jun 01 00:19:30 2012 +0200
@@ -1162,6 +1162,25 @@
     lc_getstate:= 1
 end;
 
+function lc_gettag(L : Plua_State) : LongInt; Cdecl;
+var gear : PGear;
+begin
+    if lua_gettop(L) <> 1 then
+        begin
+        LuaError('Lua: Wrong number of parameters passed to GetX!');
+        lua_pushnil(L); // return value on stack (nil)
+        end
+    else
+        begin
+        gear:= GearByUID(lua_tointeger(L, 1));
+        if gear <> nil then
+            lua_pushinteger(L, gear^.Tag)
+        else
+            lua_pushnil(L);
+        end;
+    lc_gettag:= 1
+end;
+
 function lc_settag(L : Plua_State) : LongInt; Cdecl;
 var gear : PGear;
 begin
@@ -2207,6 +2226,7 @@
 lua_register(luaState, _P'GetFollowGear', @lc_getfollowgear);
 lua_register(luaState, _P'SetState', @lc_setstate);
 lua_register(luaState, _P'GetState', @lc_getstate);
+lua_register(luaState, _P'GetTag', @lc_gettag);
 lua_register(luaState, _P'SetTag', @lc_settag);
 lua_register(luaState, _P'SetTimer', @lc_settimer);
 lua_register(luaState, _P'GetTimer', @lc_gettimer);