Sorry for the nub question, I am a nub, ha ha, oh dear, what ever will I do with myself.
Now that that's over with, I'm wondering if it's possible for one widget to communicate with another widget. For instance, make a widget enable/disable another widget or change another widget's parameters.
Widgets communicating with each other?
Moderator: Moderators
Re: Widgets communicating with each other?
Yes.
The easy way is to have them share a variable in WG, like one widget do WG.CaydrStuff=x, and another can read WG.CaydrStuff and even re-write it.
The recommended way is to use:
http://springrts.com/wiki/Lua_UnsyncedC ... LuaMessage
and
The easy way is to have them share a variable in WG, like one widget do WG.CaydrStuff=x, and another can read WG.CaydrStuff and even re-write it.
The recommended way is to use:
http://springrts.com/wiki/Lua_UnsyncedC ... LuaMessage
and
Re: Widgets communicating with each other?
Interesting. What's this mean: (needs ModUICtrl)
I am nub at writing original lua but hardcore pro at hacking pre-existing lua... are there any widgets you can point me to that use this method of communication?
I am nub at writing original lua but hardcore pro at hacking pre-existing lua... are there any widgets you can point me to that use this method of communication?
Re: Widgets communicating with each other?
It means that if someone is both pro enough and stupid enough to manually edit his springsettings.cfg to have LuaModUICtrl=0 then tons of gadgets and widgets will break.Caydr wrote:Interesting. What's this mean: (needs ModUICtrl)
Re: Widgets communicating with each other?
RedUI uses it to create a table of functions for other widgets to include.Caydr wrote:I am nub at writing original lua but hardcore pro at hacking pre-existing lua... are there any widgets you can point me to that use this method of communication?
Just imagine WG as a table that can be accessed from every widget (after initialize).
Re: Widgets communicating with each other?
Kernel Panic 3.6, use WG for communication between kp_midknight_bg.lua and kp_tooltip.lua (and also kp_onshelp.lua).
You can also see an exemple of communcation by SendMessage between synced gadget <-> unsynced gadget <-> widget in \LuaRules\Gadgets\spawn_units.lua and \LuaUI\Widgets\dump_units.lua
You can also see an exemple of communcation by SendMessage between synced gadget <-> unsynced gadget <-> widget in \LuaRules\Gadgets\spawn_units.lua and \LuaUI\Widgets\dump_units.lua
Re: Widgets communicating with each other?
To be clear, you only use messages if you want to send it to other computers. Otherwise WG (though disabling a widget doesn't take any communication at all). You can also talk between widgets and unsynced gadgets with a helper function.