Gadget -> Widget [SOLVED]

Gadget -> Widget [SOLVED]

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

Moderator: Moderators

Post Reply
User avatar
TurBoss
Jauria RTS Developer
Posts: 89
Joined: 27 Jan 2014, 01:04

Gadget -> Widget [SOLVED]

Post 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!
Last edited by TurBoss on 04 Feb 2015, 19:43, edited 1 time in total.
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10454
Joined: 24 Jan 2006, 21:12

Re: Gadget -> Widget

Post by PicassoCT »

ah, you miss the function that recives the message and pumps it to the reciving function?
User avatar
TurBoss
Jauria RTS Developer
Posts: 89
Joined: 27 Jan 2014, 01:04

Re: Gadget -> Widget

Post by TurBoss »

Solved

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

thx all
Post Reply

Return to “Lua Scripts”