PDA

View Full Version : Net Remote Variable Calling Function with VariableWatch



matchew
January 22nd, 2010, 03:48 PM
Hi,
I've been working on a small lua script which will effectively mimic the function of an ipod or iphone slide to unlock, and I can get it to work effectively by using a timer to repeatedly call a function, however I would like it to work with a variable watch, and I'm not quite sure how to make this work. I have searched around to try and find an answer without much luck. The code i have so far is below, any help would be greatly appreciated. Thanks


function slidelock(varname,varvalue)
if (varvalue < 98 ) then
NetRemote.SetVariable("LOCKSLIDE",0);
else if (varvalue > 97 ) then
NetRemote.GoBack ();
NetRemote.SetVariable("LOCKSLIDE",0);
end;
end;
end;

function OnCCFLoad()
RegisterVariableWatch( NetRemote.GetVariable( "LOCKSLIDE" ),slidelock);
end;

Rob H
January 23rd, 2010, 08:39 AM
Two things, the call should be

NetRemote.RegisterVariableWatch("LOCKSLIDE", slidelock) assuming that LOCKSLIDE is the name of the variable.

The other thing is that the values of NetRemote variables are always strings, so when doing the comparisons inside the slidelock function I'd suggest you do something like


local realValue = tonumber(value)
and then use realValue in any comparisons.

matchew
January 26th, 2010, 12:28 AM
Thank you Very Much for the help, I have attached a demo file of what I have made. I hope it can be of use to you all.

5825
5826

pfeifer
January 26th, 2010, 05:54 AM
Spectacular!!!
Thanks
Pfeifer