Page 1 of 1

Game end help

Posted: 25 Mar 2014, 12:08
by code_man
Need help here.

My script here is not working and i simply have no idea why.
Nothing about it shows up in the infolog either.
And it should execute since all units of a team get killed.

Code: Select all

-- game_end.lua

-- Provides game end conditions

function gadget:GetInfo()
    return {
        name = "Game End",
        desc = "Provides game end conditions",
        author = "Code_Man",
        date = "2013-10-30",
        license = "Public domain",
        layer = 1,
        enabled = true
    }
end

if (not gadgetHandler:IsSyncedCode()) then
  return false
end

function gadget:UnitDestroyed(unit, unitDef, team)
    if (Spring.GetTeamUnitCount(team) == 0) then
        Spring.KillTeam(team)
        --Spring.GameOver()
    end
end

function gadget:TeamKilled(team)
    Spring.Echo("Player Was Terminated")
end

Re: Game end help

Posted: 25 Mar 2014, 17:05
by FLOZi
Game doesn't end until Spring.GameOver is called, regardless of if all the teams are dead (iirc)

Re: Game end help

Posted: 25 Mar 2014, 17:15
by gajop
FLOZi wrote:Game doesn't end until Spring.GameOver is called, regardless of if all the teams are dead (iirc)
No, but it should trigger when a specific team dies, which is what he's trying to do from what I can see.

@OP:
Spring itself should also send a message if teams die, are you seeing that? It's possible that you've specified certain team-death conditions that cause teams to live even if all units are dead, check that out.

Re: Game end help

Posted: 25 Mar 2014, 17:31
by Silentwings
Spring itself should also send a message if teams die, are you seeing that?
Not anymore - team death messages rely on lua now afaik. I guess his complaint is that he is expecting to see the result of Spring.Echo("Player Was Terminated") and isn't.

Re: Game end help

Posted: 29 Mar 2014, 10:06
by code_man
Sorry for late reply.

Yes the message is supposed to be triggered but never gets.
There are no hidden units or alternative conditions.

Re: Game end help

Posted: 29 Mar 2014, 10:49
by FLOZi
Try checking if GetUniTeamCount is 1 :wink:

Re: Game end help

Posted: 29 Mar 2014, 12:10
by code_man
Well it seems to work now.
However the death message from the callin is still not echoed, tough it doesnt really matter.