# HG changeset patch # User Wuzzy # Date 1548046621 -3600 # Node ID bc4296649bbf74c4f97c012c3358602269bdef26 # Parent 7de65fa1f68623c8c548c63c802de066d71eb45e SetClanColor: Accept negative color argument to select user color diff -r 7de65fa1f686 -r bc4296649bbf ChangeLog.txt --- a/ChangeLog.txt Mon Jan 21 05:51:35 2019 +0100 +++ b/ChangeLog.txt Mon Jan 21 05:57:01 2019 +0100 @@ -80,6 +80,7 @@ + New call: AddMissionHog(health): Add a hedgehog for the mission team + New call: SetTeamPassive(teamname, isPassive): Mark a team as passive. Passive teams do not play and are treated like frozen teams. + New return value: AddTeam/AddMissionTeam return , + + SetClanColor: Now accepts negative color argument for user clan color, like in AddTeam + Utils library: New calls: getReadableChallengeRecord, updateChallengeRecord + New callback: onGameResult(winningClan): Called when the game ends normally. winningClan = index of winning clan or -1 on draw + SendStat extension: Option to use predefined modes with siPointType, like "!POINTS" or "!TIME" diff -r 7de65fa1f686 -r bc4296649bbf hedgewars/uScript.pas --- a/hedgewars/uScript.pas Mon Jan 21 05:51:35 2019 +0100 +++ b/hedgewars/uScript.pas Mon Jan 21 05:57:01 2019 +0100 @@ -1361,13 +1361,29 @@ hht : THedgehog; hhp : PHedgehog; i, j : LongInt; + colorArg: Int64; + color: LongWord; begin if CheckLuaParamCount(L, 2, 'SetClanColor', 'clan, color') then begin i:= Trunc(lua_tonumber(L,1)); if i >= ClansCount then exit(0); clan := ClansArray[i]; - clan^.Color:= Trunc(lua_tonumber(L, 2)) shr 8; + colorArg:= Trunc(lua_tonumber(L, 2)); + if (colorArg < 0) and (abs(colorArg) <= cClanColors) then + // Pick clan color from settings (recommended) + color:= ClanColorArray[Pred(abs(colorArg))] + else if (colorArg >= 0) and (colorArg <= $ffffffff) then + // Specify color directly + color:= colorArg shr 8 + else + begin + OutError('Lua error: SetClanColor: Invalid ''color'' argument, must be between '+IntToStr(-cClanColors)+' and 0xffffffff!', true); + lc_setclancolor:= 0; + exit; + end; + + clan^.Color:= color; for i:= 0 to Pred(clan^.TeamsNumber) do begin