Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----==== [gadget] game_team_com_ends.lua
- if (gadgetHandler:IsSyncedCode()) then
- ---- SYNCED
- function gadget:UnitCreated(u, ud, team)
- isAlive[u] = true
- if UnitDefs[ud].customParams.iscommander then
- local allyTeam = GetUnitAllyTeam(u)
- aliveCount[allyTeam] = aliveCount[allyTeam] + 1
- SendToUnsynced("CommCountEvent", allyTeam, aliveCount[allyTeam])
- end
- end
- else
- ------------------------------------------
- --UNSYNCED
- ------------------------------------------
- --Makes an unsynced gadget call a function that is in one or more widgets.
- local function HandleCommCountEvent(cmd, allyTeam, aliveCount)
- if Script.LuaUI('CommCountUIEvent') then
- Script.LuaUI.CommCountUIEvent(allyTeam, aliveCount)
- end
- end
- -- In unsynced/init, we need to wire up a function to fire any time the comm count changes (event)
- function gadget:Initialize()
- gadgetHandler:AddSyncAction("CommCountEvent", HandleCommCountEvent)
- end
- function gadget:Shutdown()
- gadgetHandler:RemoveSyncAction("CommCountEvent")
- end
- ------------------------------------------
- ------------------------------------------
- -----===== [gadget] gui_comcounter.lua:
- local function CommCountChanged(allyTeam, aliveCount)
- -- Sets up local variables, does what it has to do
- end
- --Sets up to receive CommCountChanged event from game_team_comm_ends
- function widget:Initialize()
- widgetHandler:RegisterGlobal('CommCountUIEvent', CommCountChanged)
- end
- function widget:Shutdown()
- widgetHandler:DeregisterGlobal('CommCountUIEvent')
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement