PDA

View Full Version : Help Using RegisterVariableWatch Please



zones
August 3rd, 2008, 12:00 PM
I am trying to use RegisterVariableWatch and my lua fails when it calls the RegisterVariableWatch. I get the first messagebox but not the second, anyone see what my rookie mistake is.



function OnCCFLoad()

NetRemote.MessageBox('Load');

NetRemote.RegisterVariableWatch('MP.LinkActive',Ch eckState);
NetRemote.RegisterVariableWatch('Girder.LinkActive ',CheckState);

NetRemote.MessageBox('Load2');

end


local function CheckState(var, value, handle)
NetRemote.MessageBox('CheckState');

end;

Rob H
August 9th, 2008, 08:07 AM
You've defined CheckState after the OnCCFLoad - move it before and it should work

zones
August 15th, 2008, 02:51 PM
Thanks Rob, I have been away will give it a try.

zones
August 16th, 2008, 03:24 PM
Rob,

That works thanks.

Does this mean I need to put all functions above the place where they are called or is this just a OnCCFLoad quirk.

Cheers

Rob H
August 17th, 2008, 12:49 AM
If the function being called is a local one then yes you need to define it before it can be called. If it's global or stored in a table then it doesn't matter.

It is, however, good practice to use local functions.