Hi there.
In principle I agree. I didn't do it since the solution is a work around that to me seems quite ugly. Besides, the gadget is based on a script by Alchemist and I didn't want to post it here without checking with him first if he's OK with it (so far, I only used it in private games for testing, learning and playing around).
Nevertheless, here in a more or less short way:
In the synced part in gadget:Initialize() there is (besides some other stuff that works without problems):
Code: Select all
function gadget:Initialize()
goalTime = (Spring.GetModOptions().hilltime) * 30 * 60
SendToUnsynced("initialTimekoth", goalTime / 30 )
...
end
This calls a function (which is hence called once at the beginning) in the unsynced part which should set the hilltime counters list to the initial hill time (they are counting down in the game):
Code: Select all
gadgetHandler:AddSyncAction("initialTimekoth", setTeamTimerskoth)
...
function setTeamTimerskoth(cmd, iTime, ...)
for _, t in ipairs(Spring.GetAllyTeamList()) do
teamTimers[t] = iTime
end
end
The teamTimers list is then updated in the game (via another SendToUnsynced which works without problems) and used for writing the current times in a loop over the teams to the screen via gl.Text().
This works perfectly with spring MT but not with the normal spring. There, teamTimers is just not filled (a temporary Spring.Echo() in the
setTeamTimerskoth function for debugging showed, that it is not called at all).
So, for now as a workaround I added before the output loop a check and repeat the function code:
Code: Select all
if ( #teamTimers == 0 ) then
local starttime = (Spring.GetModOptions().hilltime) * 60
for _, t in ipairs(Spring.GetAllyTeamList()) do
teamTimers[t] = starttime
end
end
As I said at the beginning: this is more a work-around than a solution. But I couldn't think of anything better for now
(1), since I thought if there was a problem with the SendToUnsynced call in Initialize, it should have happened in the MT version and not in the normal one; although I wouldn't expect a problem in MT since AFAIK BA runs in ASIM mode 4 and there it should work... which it does.
So IMHO, there is probably not much to be learned from this work around... except for me if sbd now points out serious errors in my thinking
CU, qray
-----------------
(1) this is my first try to write/modify lua stuff for spring