hedgewars/uScript.pas
changeset 11736 e9481c5a130b
parent 11678 b76b7372a2a6
child 11737 571d06a86bb6
equal deleted inserted replaced
11735:a6d097f23138 11736:e9481c5a130b
  1208         lua_pushnil(L); // return value on stack (nil)
  1208         lua_pushnil(L); // return value on stack (nil)
  1209     lc_gethogclan:= 1
  1209     lc_gethogclan:= 1
  1210 end;
  1210 end;
  1211 
  1211 
  1212 function lc_getclancolor(L : Plua_State) : LongInt; Cdecl;
  1212 function lc_getclancolor(L : Plua_State) : LongInt; Cdecl;
  1213 begin
  1213 var idx: integer;
  1214     if CheckLuaParamCount(L, 1, 'GetClanColor', 'clan') then
  1214 begin
  1215         lua_pushinteger(L, ClansArray[lua_tointeger(L, 1)]^.Color shl 8 or $FF)
  1215     if CheckLuaParamCount(L, 1, 'GetClanColor', 'clanIdx') then
       
  1216         begin
       
  1217         idx:= lua_tointeger(L, 1);
       
  1218         if (not lua_isnumber(L, 1)) then
       
  1219             begin
       
  1220             LuaError('Argument ''clanIdx'' must be a number!');
       
  1221             lua_pushnil(L);
       
  1222             end
       
  1223         else if (idx < 0) or (idx >= ClansCount) then
       
  1224             begin
       
  1225             LuaError('Argument ''clanIdx'' out of range! (There are currently ' + IntToStr(ClansCount) + ' clans, so valid range is: 0-' + IntToStr(ClansCount-1) + ')');
       
  1226             lua_pushnil(L);
       
  1227             end
       
  1228         else
       
  1229             lua_pushinteger(L, ClansArray[idx]^.Color shl 8 or $FF);
       
  1230         end
  1216     else
  1231     else
  1217         lua_pushnil(L); // return value on stack (nil)
  1232         lua_pushnil(L); // return value on stack (nil)
  1218     lc_getclancolor:= 1
  1233     lc_getclancolor:= 1
  1219 end;
  1234 end;
  1220 
  1235