Widget/Gadget interaction

Widget/Gadget interaction

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

Moderator: Moderators

Post Reply
User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Widget/Gadget interaction

Post by Anarchid »

I know it's possible to send synced-context data from a gadget's sync part to its unsynced code.

But is it possible to somehow tip off a widget script of a change in our synced variables? Will the same thing work as within a gadget?
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Widget/Gadget interaction

Post by lurker »

Did you look in the wiki? I know you didn't look in CA. For shame.

In the unsynced part of your gadget:
if (Script.LuaUI('functionname')) then
Script.LuaUI['functionname'](...)
end

In the widget:
local function functiontogetdata(stuff)
init: widgetHandler:RegisterGlobal('functionname', functiontogetdata)
shutdown: widgetHandler:DeregisterGlobal('functionname')
User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Re: Widget/Gadget interaction

Post by Anarchid »

Excellent! *does moar of his mr.Burns impression* :P

Now i can have all the ugly non-canon gui additions to Metropolis Spring as widgets :P
Post Reply

Return to “Lua Scripts”