Gadget Unsynced functions
Posted: 12 Feb 2012, 03:51
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?
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?