Page 1 of 1

Gadget Unsynced functions

Posted: 12 Feb 2012, 03:51
by super_g
my gadget unsyced code does not seem to run at all. I have tried many different functions in the unsynced portion, such as:

function gadget:Update()
function gadget:Initialize()

I can not even get the below posted example to run the unsynced portion.

if (gadgetHandler:IsSyncedCode()) then
--SYNCED CODE
local number = 10 -- declaring local variable 'number'
function gadget:SomeSyncedCallin(...)
number=number+1 -- increment variable's value by one
_G.number=number -- save the new value into a global variable
end
else
--UNSYNCED CODE
function gadget:SomeUnsyncedCallin(...)
Spring.Echo(SYNCED.number) -- print the global variable's value on screen
end
end

Is there a special way to register the unsynced functions?

Re: Gadget Unsynced functions

Posted: 12 Feb 2012, 10:36
by FLOZi
Does your game have a LuaRules/draw.lua which includes the gadgethandler?

Re: Gadget Unsynced functions

Posted: 12 Feb 2012, 15:51
by knorke
super_g wrote: --UNSYNCED CODE
function gadget:SomeUnsyncedCallin(...)
Some callins do not get called in unsynced.
eg function gadget:GameFrame (f)

http://answers.springlobby.info/questio ... d-luarules

http://answers.springlobby.info/questio ... ced-gadget

Re: Gadget Unsynced functions

Posted: 12 Feb 2012, 17:01
by FLOZi
Update and Initialize are certainly called in unsynced; I suspect this is the issue:

http://answers.springlobby.info/questio ... nitialized

Re: Gadget Unsynced functions

Posted: 12 Feb 2012, 18:26
by Nerris
THANK YOU!

I'm currently working with Super_G on this project, and this solved the issue beautifully. We were missing draw.lua