Game end help

Game end help

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
code_man
Posts: 260
Joined: 19 Jan 2014, 13:10

Game end help

Post 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
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: Game end help

Post by FLOZi »

Game doesn't end until Spring.GameOver is called, regardless of if all the teams are dead (iirc)
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Game end help

Post 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.
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Game end help

Post 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.
User avatar
code_man
Posts: 260
Joined: 19 Jan 2014, 13:10

Re: Game end help

Post 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.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: Game end help

Post by FLOZi »

Try checking if GetUniTeamCount is 1 :wink:
User avatar
code_man
Posts: 260
Joined: 19 Jan 2014, 13:10

Re: Game end help

Post 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.
Post Reply

Return to “Lua Scripts”