--- a/ChangeLog.txt Thu Dec 20 18:23:13 2018 +0100
+++ b/ChangeLog.txt Thu Dec 20 19:03:34 2018 +0100
@@ -25,7 +25,7 @@
+ New call: GetTurnTimePaused(): Returns true if turn time is paused due to Lua
+ New call: AddMissionTeam(color): Add mission team, i.e. the team selected by player in campaign/mission page
+ New call: AddMissionHog(health): Add a hedgehog for the mission team
- + New return value: AddTeam and AddMissionTeam return team index of new team
+ + New return value: AddTeam/AddMissionTeam return <real team name>, <team index>
+ 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
+ SimpleMission: Add isMissionTeam attribute for teams
--- a/hedgewars/uScript.pas Thu Dec 20 18:23:13 2018 +0100
+++ b/hedgewars/uScript.pas Thu Dec 20 19:03:34 2018 +0100
@@ -2290,7 +2290,9 @@
else
begin
OutError('Lua error: AddTeam: Invalid ''color'' argument, must be between '+IntToStr(-cClanColors)+' and 0xffffffff!', true);
- lc_addteam:= 0;
+ lua_pushnil(L);
+ lua_pushnil(L);
+ lc_addteam:= 2;
exit;
end;
ParseCommand('addteam x ' + colorStr + ' ' + lua_tostring(L, 1), true, true);
@@ -2299,12 +2301,16 @@
ParseCommand('voicepack ' + lua_tostring(L, 5), true, true);
if (np = 6) then ParseCommand('flag ' + lua_tostring(L, 6), true, true);
CurrentTeam^.Binds:= DefaultBinds;
- // push team index
+ // push team name and index
+ lua_pushstring(L, str2pchar(CurrentTeam^.TeamName));
lua_pushnumber(L, TeamsCount - 1);
end
else
+ begin
lua_pushnil(L);
- lc_addteam:= 1;
+ lua_pushnil(L);
+ end;
+ lc_addteam:= 2;
end;
function lc_addmissionteam(L : Plua_State) : LongInt; Cdecl;
@@ -2330,7 +2336,9 @@
else
begin
OutError('Lua error: AddMissionTeam: Invalid ''color'' argument, must be between '+IntToStr(-cClanColors)+' and 0xffffffff!', true);
- lc_addmissionteam:= 0;
+ lua_pushnil(L);
+ lua_pushnil(L);
+ lc_addmissionteam:= 2;
exit;
end;
@@ -2340,12 +2348,16 @@
ParseCommand('voicepack ' + MissionTeam^.Voicepack^.name, true, true);
ParseCommand('flag ' + MissionTeam^.Flag, true, true);
CurrentTeam^.Binds:= DefaultBinds;
- // push team index
+ // push real team name and team index
+ lua_pushstring(L, str2pchar(CurrentTeam^.TeamName));
lua_pushnumber(L, TeamsCount - 1);
end
else
+ begin
lua_pushnil(L);
- lc_addmissionteam:= 1;
+ lua_pushnil(L);
+ end;
+ lc_addmissionteam:= 2;
end;
function lc_setteamlabel(L : Plua_State) : LongInt; Cdecl;
--- a/share/hedgewars/Data/Missions/Challenge/User_Mission_-_Rope_Knock_Challenge.lua Thu Dec 20 18:23:13 2018 +0100
+++ b/share/hedgewars/Data/Missions/Challenge/User_Mission_-_Rope_Knock_Challenge.lua Thu Dec 20 19:03:34 2018 +0100
@@ -73,7 +73,7 @@
}
-local playerTeam, playerTeamName
+local playerTeamName
function GetKillScore()
return math.ceil((hogsKilled / 16)*6000)
@@ -174,8 +174,7 @@
MinesNum = 0
Explosives = 0
- playerTeam = AddMissionTeam(-1)
- playerTeamName = GetTeamName(playerName)
+ playerTeamName = AddMissionTeam(-1)
hhs[0] = AddMissionHog(1)
SetGearPosition(player, 1380, 1500)
--- a/share/hedgewars/Data/Missions/Challenge/User_Mission_-_That_Sinking_Feeling.lua Thu Dec 20 18:23:13 2018 +0100
+++ b/share/hedgewars/Data/Missions/Challenge/User_Mission_-_That_Sinking_Feeling.lua Thu Dec 20 19:03:34 2018 +0100
@@ -54,8 +54,7 @@
HealthDecrease = 0
WaterRise = 0
- local idx = AddTeam(loc("Hapless Hogs"), -1, "Simple", "Island", "Default")
- haplessTeamName = GetTeamName(idx)
+ haplessTeamName = AddTeam(loc("Hapless Hogs"), -1, "Simple", "Island", "Default")
hh[0] = AddHog(loc("Sinky"), 1, 100, "fr_lemon")
hh[1] = AddHog(loc("Drowner"), 1, 100, "fr_orange")
hh[2] = AddHog(loc("Heavy"), 1, 100, "dish_Teapot")
@@ -65,8 +64,7 @@
hh[6] = AddHog(loc("Sponge"), 1, 100, "sf_chunli")
hh[7] = AddHog(loc("Deadweight"), 1, 100, "dish_Teacup")
- idx = AddMissionTeam(-1)
- playerTeamName = GetTeamName(idx)
+ playerTeamname = AddMissionTeam(-1)
player = AddMissionHog(1)
SetGearPosition(player, 3992, 733)
--- a/share/hedgewars/Data/Scripts/SimpleMission.lua Thu Dec 20 18:23:13 2018 +0100
+++ b/share/hedgewars/Data/Scripts/SimpleMission.lua Thu Dec 20 19:03:34 2018 +0100
@@ -660,9 +660,9 @@
clanID = teamData.clanID
end
- local idx
+ local realName
if teamData.isMissionTeam then
- idx = AddMissionTeam(-(clanID+1))
+ realName = AddMissionTeam(-(clanID+1))
_G.sm.playerClan = clanID
else
grave = def(teamData.grave, defaultGraves[math.min(teamID, 8)])
@@ -670,19 +670,19 @@
voice = def(teamData.voice, "Default")
flag = def(teamData.flag, defaultFlags[math.min(teamID, 8)])
- idx = AddTeam(name, -(clanID+1), grave, fort, voice, flag)
- local realName = GetTeamName(idx)
- -- Update all teamDefeat goals if the real team name differs from the
- -- team configuration.
- -- (AddTeam might change the name due to naming collisions)
- if name ~= realName then
- local checks = { params.customGoals, params.customNonGoals }
- for c=1, 2 do
- if checks[c] then
- for k,goal in pairs(checks[c]) do
- if goal.type == "teamDefeat" and goal.teamName == name then
- goal.teamName = realName
- end
+ realName = AddTeam(name, -(clanID+1), grave, fort, voice, flag)
+ end
+
+ -- Update all teamDefeat goals if the real team name differs from the
+ -- team configuration.
+ -- (AddTeam might change the name due to naming collisions)
+ if name ~= realName then
+ local checks = { params.customGoals, params.customNonGoals }
+ for c=1, 2 do
+ if checks[c] then
+ for k,goal in pairs(checks[c]) do
+ if goal.type == "teamDefeat" and goal.teamName == name then
+ goal.teamName = realName
end
end
end