hedgewars/uScript.pas
changeset 5245 ce407084728f
parent 5243 f2e31a7f953a
child 5272 a85d331ab5bb
equal deleted inserted replaced
5243:f2e31a7f953a 5245:ce407084728f
   655             lua_pushnil(L);
   655             lua_pushnil(L);
   656         end;
   656         end;
   657     lc_gethogname:= 1
   657     lc_gethogname:= 1
   658 end;
   658 end;
   659 
   659 
       
   660 function lc_sethogname(L : Plua_State) : LongInt; Cdecl;
       
   661 var gear : PGear;
       
   662   hogName: ShortString;
       
   663 begin
       
   664     if lua_gettop(L) <> 2 then
       
   665         begin
       
   666         LuaError('Lua: Wrong number of parameters passed to SetHogName!');
       
   667         lua_pushnil(L)
       
   668         end
       
   669     else
       
   670         begin
       
   671         gear:= GearByUID(lua_tointeger(L, 1));
       
   672         if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then
       
   673 
       
   674 	    hogName:= lua_tostring(L, 2);
       
   675             gear^.Hedgehog^.Name:= hogName;
       
   676 
       
   677 	    FreeTexture(gear^.Hedgehog^.NameTagTex);
       
   678             gear^.Hedgehog^.NameTagTex:= RenderStringTex(gear^.Hedgehog^.Name, gear^.Hedgehog^.Team^.Clan^.Color, fnt16);
       
   679 
       
   680         end;
       
   681     lc_sethogname:= 0;
       
   682 end;
       
   683 
   660 function lc_gettimer(L : Plua_State) : LongInt; Cdecl;
   684 function lc_gettimer(L : Plua_State) : LongInt; Cdecl;
   661 var gear : PGear;
   685 var gear : PGear;
   662 begin
   686 begin
   663     if lua_gettop(L) <> 1 then
   687     if lua_gettop(L) <> 1 then
   664         begin
   688         begin
   854         begin
   878         begin
   855         gear:= GearByUID(lua_tointeger(L, 1));
   879         gear:= GearByUID(lua_tointeger(L, 1));
   856         if gear <> nil then
   880         if gear <> nil then
   857             begin
   881             begin
   858             gear^.Health:= lua_tointeger(L, 2);
   882             gear^.Health:= lua_tointeger(L, 2);
       
   883 
       
   884 	    if (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then
       
   885             begin  
       
   886 		RenderHealth(gear^.Hedgehog^);
       
   887             end;
       
   888 
   859             SetAllToActive;
   889             SetAllToActive;
   860             end
   890             end
   861         end;
   891         end;
   862     lc_sethealth:= 0
   892     lc_sethealth:= 0
   863 end;
   893 end;
  1710 lua_register(luaState, 'GetHogClan', @lc_gethogclan);
  1740 lua_register(luaState, 'GetHogClan', @lc_gethogclan);
  1711 lua_register(luaState, 'GetClanColor', @lc_getclancolor);
  1741 lua_register(luaState, 'GetClanColor', @lc_getclancolor);
  1712 lua_register(luaState, 'SetClanColor', @lc_setclancolor);
  1742 lua_register(luaState, 'SetClanColor', @lc_setclancolor);
  1713 lua_register(luaState, 'GetHogTeamName', @lc_gethogteamname);
  1743 lua_register(luaState, 'GetHogTeamName', @lc_gethogteamname);
  1714 lua_register(luaState, 'GetHogName', @lc_gethogname);
  1744 lua_register(luaState, 'GetHogName', @lc_gethogname);
       
  1745 lua_register(luaState, 'SetHogName', @lc_sethogname);
  1715 lua_register(luaState, 'GetHogLevel', @lc_gethoglevel);
  1746 lua_register(luaState, 'GetHogLevel', @lc_gethoglevel);
  1716 lua_register(luaState, 'SetHogLevel', @lc_sethoglevel);
  1747 lua_register(luaState, 'SetHogLevel', @lc_sethoglevel);
  1717 lua_register(luaState, 'GetX', @lc_getx);
  1748 lua_register(luaState, 'GetX', @lc_getx);
  1718 lua_register(luaState, 'GetY', @lc_gety);
  1749 lua_register(luaState, 'GetY', @lc_gety);
  1719 lua_register(luaState, 'CopyPV', @lc_copypv);
  1750 lua_register(luaState, 'CopyPV', @lc_copypv);