hedgewars/uScript.pas
changeset 11852 38e7206a5df4
parent 11851 6bf91006d630
child 11854 bc5714636364
--- a/hedgewars/uScript.pas	Thu Sep 15 23:16:49 2016 +0200
+++ b/hedgewars/uScript.pas	Fri Sep 16 00:01:43 2016 +0200
@@ -1307,6 +1307,7 @@
     if CheckLuaParamCount(L, 1, 'GetHogFlag', 'gearUid') then
         begin
         gear:= GearByUID(lua_tointeger(L, 1));
+        // TODO error messages
         if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then
             lua_pushstring(L, str2pchar(gear^.Hedgehog^.Team^.Flag))
         else
@@ -1317,12 +1318,30 @@
     lc_gethogflag:= 1
 end;
 
+function lc_ishoglocal(L : Plua_State) : LongInt; Cdecl;
+var gear : PGear;
+begin
+    if CheckLuaParamCount(L, 1, 'IsHogLocal', 'gearUid') then
+        begin
+        gear:= GearByUID(lua_tointeger(L, 1));
+        // TODO error messages
+        if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then
+            lua_pushboolean(L, IsHogLocal(gear^.Hedgehog))
+        else
+            lua_pushnil(L);
+        end
+    else
+        lua_pushnil(L); // return value on stack (nil)
+    lc_ishoglocal:= 1
+end;
+
 function lc_gethogteamname(L : Plua_State) : LongInt; Cdecl;
 var gear : PGear;
 begin
     if CheckLuaParamCount(L, 1, 'GetHogTeamName', 'gearUid') then
         begin
         gear:= GearByUID(lua_tointeger(L, 1));
+        // TODO error messages
         if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then
             lua_pushstring(L, str2pchar(gear^.Hedgehog^.Team^.TeamName))
         else
@@ -3325,6 +3344,7 @@
 lua_register(luaState, _P'GetHogVoicepack', @lc_gethogvoicepack);
 lua_register(luaState, _P'GetHogFlag', @lc_gethogflag);
 lua_register(luaState, _P'GetHogGrave', @lc_gethoggrave);
+lua_register(luaState, _P'IsHogLocal', @lc_ishoglocal);
 lua_register(luaState, _P'GetHogTeamName', @lc_gethogteamname);
 lua_register(luaState, _P'SetHogTeamName', @lc_sethogteamname);
 lua_register(luaState, _P'GetHogName', @lc_gethogname);