hedgewars/uScript.pas
changeset 11847 38e7206a5df4
parent 11846 6bf91006d630
child 11849 bc5714636364
equal deleted inserted replaced
11846:6bf91006d630 11847:38e7206a5df4
  1305 var gear : PGear;
  1305 var gear : PGear;
  1306 begin
  1306 begin
  1307     if CheckLuaParamCount(L, 1, 'GetHogFlag', 'gearUid') then
  1307     if CheckLuaParamCount(L, 1, 'GetHogFlag', 'gearUid') then
  1308         begin
  1308         begin
  1309         gear:= GearByUID(lua_tointeger(L, 1));
  1309         gear:= GearByUID(lua_tointeger(L, 1));
       
  1310         // TODO error messages
  1310         if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then
  1311         if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then
  1311             lua_pushstring(L, str2pchar(gear^.Hedgehog^.Team^.Flag))
  1312             lua_pushstring(L, str2pchar(gear^.Hedgehog^.Team^.Flag))
  1312         else
  1313         else
  1313             lua_pushnil(L);
  1314             lua_pushnil(L);
  1314         end
  1315         end
  1315     else
  1316     else
  1316         lua_pushnil(L); // return value on stack (nil)
  1317         lua_pushnil(L); // return value on stack (nil)
  1317     lc_gethogflag:= 1
  1318     lc_gethogflag:= 1
  1318 end;
  1319 end;
  1319 
  1320 
       
  1321 function lc_ishoglocal(L : Plua_State) : LongInt; Cdecl;
       
  1322 var gear : PGear;
       
  1323 begin
       
  1324     if CheckLuaParamCount(L, 1, 'IsHogLocal', 'gearUid') then
       
  1325         begin
       
  1326         gear:= GearByUID(lua_tointeger(L, 1));
       
  1327         // TODO error messages
       
  1328         if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then
       
  1329             lua_pushboolean(L, IsHogLocal(gear^.Hedgehog))
       
  1330         else
       
  1331             lua_pushnil(L);
       
  1332         end
       
  1333     else
       
  1334         lua_pushnil(L); // return value on stack (nil)
       
  1335     lc_ishoglocal:= 1
       
  1336 end;
       
  1337 
  1320 function lc_gethogteamname(L : Plua_State) : LongInt; Cdecl;
  1338 function lc_gethogteamname(L : Plua_State) : LongInt; Cdecl;
  1321 var gear : PGear;
  1339 var gear : PGear;
  1322 begin
  1340 begin
  1323     if CheckLuaParamCount(L, 1, 'GetHogTeamName', 'gearUid') then
  1341     if CheckLuaParamCount(L, 1, 'GetHogTeamName', 'gearUid') then
  1324         begin
  1342         begin
  1325         gear:= GearByUID(lua_tointeger(L, 1));
  1343         gear:= GearByUID(lua_tointeger(L, 1));
       
  1344         // TODO error messages
  1326         if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then
  1345         if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then
  1327             lua_pushstring(L, str2pchar(gear^.Hedgehog^.Team^.TeamName))
  1346             lua_pushstring(L, str2pchar(gear^.Hedgehog^.Team^.TeamName))
  1328         else
  1347         else
  1329             lua_pushnil(L);
  1348             lua_pushnil(L);
  1330         end
  1349         end
  3323 lua_register(luaState, _P'GetClanColor', @lc_getclancolor);
  3342 lua_register(luaState, _P'GetClanColor', @lc_getclancolor);
  3324 lua_register(luaState, _P'SetClanColor', @lc_setclancolor);
  3343 lua_register(luaState, _P'SetClanColor', @lc_setclancolor);
  3325 lua_register(luaState, _P'GetHogVoicepack', @lc_gethogvoicepack);
  3344 lua_register(luaState, _P'GetHogVoicepack', @lc_gethogvoicepack);
  3326 lua_register(luaState, _P'GetHogFlag', @lc_gethogflag);
  3345 lua_register(luaState, _P'GetHogFlag', @lc_gethogflag);
  3327 lua_register(luaState, _P'GetHogGrave', @lc_gethoggrave);
  3346 lua_register(luaState, _P'GetHogGrave', @lc_gethoggrave);
       
  3347 lua_register(luaState, _P'IsHogLocal', @lc_ishoglocal);
  3328 lua_register(luaState, _P'GetHogTeamName', @lc_gethogteamname);
  3348 lua_register(luaState, _P'GetHogTeamName', @lc_gethogteamname);
  3329 lua_register(luaState, _P'SetHogTeamName', @lc_sethogteamname);
  3349 lua_register(luaState, _P'SetHogTeamName', @lc_sethogteamname);
  3330 lua_register(luaState, _P'GetHogName', @lc_gethogname);
  3350 lua_register(luaState, _P'GetHogName', @lc_gethogname);
  3331 lua_register(luaState, _P'SetHogName', @lc_sethogname);
  3351 lua_register(luaState, _P'SetHogName', @lc_sethogname);
  3332 lua_register(luaState, _P'GetHogLevel', @lc_gethoglevel);
  3352 lua_register(luaState, _P'GetHogLevel', @lc_gethoglevel);