Page 1 of 1

Gadget -> Widget [SOLVED]

Posted: 04 Feb 2015, 16:45
by TurBoss
Hi

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
is there another way to pass data from a gadget to a widget , ive ear someting with WG but i have no idea how it works :D

thx!

Re: Gadget -> Widget

Posted: 04 Feb 2015, 17:28
by PicassoCT
ah, you miss the function that recives the message and pumps it to the reciving function?

Re: Gadget -> Widget

Posted: 04 Feb 2015, 19:43
by TurBoss
Solved

my game was missing LuaRules/Draw.lua
:oops:

thx all