Global variable

Global variable

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

Moderator: Moderators

Post Reply
User avatar
daryl
Posts: 195
Joined: 08 Oct 2006, 10:33

Global variable

Post by daryl »

Hello,
Please can you help me with a global variable? :
I need to send a variable from gadget to widget but some error appear during tests:

code in gadget:

Code: Select all

----
--sync
----
function gadget:GameFrame(n)
[...]
SendToUnsynced("start",1,0)
end
[...]
----
--unsync
----
function gadget:Initialize()
  gadgetHandler:AddSyncAction("start", Start) 
end

local function Start(vala,valb)
[...]
code in widget:

Code: Select all

local function test(vala,valb)
  if (vala == 1) then
        Spring.Echo("test ok") 
         end
end

function widget:Initialize()
	widgetHandler:RegisterGlobal('start',test)
end
what is wrong??
ivand
Posts: 310
Joined: 27 Jun 2007, 17:05

Re: Global variable

Post by ivand »

Have a look here for the concept: viewtopic.php?p=462489#p462489 or check any modern game sources to get working example.
User avatar
daryl
Posts: 195
Joined: 08 Oct 2006, 10:33

Re: Global variable

Post by daryl »

Hi Ivand.. the link was helpful!!! Thank you!!!
Post Reply

Return to “Lua Scripts”