i'm trying to send some data to a widget from a gadget
i'm trying with SendToUnsynced then Script.LuaUI
but the handler event is never executed
Code: Select all
function gadget:GetInfo()
return {
name = "Unit death",
desc = "counts dead units.",
author = "TurBoss",
date = "3/2/2015",
license = "GNU GPL V2 or Later",
layer = 5,
enabled = true -- loaded by default?
}
end
if (gadgetHandler:IsSyncedCode()) then
function gadget:UnitDestroyed(unitID, unitDefID, unitTeam, attackerID, attackerDefID, attackerTeam)
SendToUnsynced("DeathEvent", unitID, unitDefID, unitTeam, attackerID, attackerDefID, attackerTeam)
end
else
function WrapToLuaUI(_, unitID, unitDefID, unitTeam, attackerID, attackerDefID, attackerTeam)
Spring.Echo("ITWORKS")
--if (Script.LuaUI('DeathEvent')) then
-- Script.LuaUI.DeathEvent(unitID, unitDefID, unitTeam, attackerID, attackerDefID, attackerTeam)
--end
end
function gadget:Initialize()
gadgetHandler:AddSyncAction('DeathEvent', WrapToLuaUI)
end
function gadget:ShutDown()
gadgetHandler:RemoveSyncAction('DeathEvent')
end
end
thx!