PDA

View Full Version : Changing Button image from lua script



danward79
September 11th, 2004, 09:35 AM
Hi

Does anyone know how to change the image in a button from the lua script file? What I need is to change the image between the active and inactive images.

I have been trying to do it using the State:Zone, in the ID Tag box, but it does not work.

Below is my LUA, it is the last bit with MP.Zone I need to get working to change the button state.


function OnVariableChange(varname,varvalue)

if (varname=="Marcel.WiFi.SignalStrength") then
marcel_setwifiimg();
elseif (varname=="weatherrefresh") then
NetRemote.SetVariable('weatherrefresh', '0');
NetRemote.ExecuteAction(-1,0,1,"NR.Checkweather");
elseif (varname == "cc.icon") then
iconnumber = tonumber(NetRemote.GetVariable("cc.icon"));
setweatherimg();
elseif (varname == "MP.Zone") then
MYZone = NetRemote.GetVariable("MP.Zone");
if (MYZone == "Main") then Zone = 1 else Zone = 0 end;
NetRemote.SetVariable('Zone', Zone);
end;

end;

If someone could shed somelight on this it would be great.

Thanks

Dan

Ben S
September 11th, 2004, 10:20 AM
The only thing I can think of is that SetVariable expects a string for the variable value.

Try changing it to


if (MYZone == "Main") then Zone = "1" else Zone = "0" end;


Note the include of quotes around "1" and "0".

danward79
September 11th, 2004, 10:50 AM
Thanks Ben, But that did not work... :cry:

Do you have any other suggestions?

How would you do it?

Thanks

Dan

Ben S
September 11th, 2004, 10:53 AM
Sure. Can you shoot me your ccf and lua and I'll see what's going on?

danward79
September 11th, 2004, 11:06 AM
Hi,

Here thay are, thanks Ben, I had to slim it down to reduce the size.

Thanks

Dan

danward79
September 12th, 2004, 09:40 AM
Hi Again.....,

Sorry to be real pushy here, but I am going up north all this week to a Place called Wakefield, near leeds, and was wondering if you had had a chance to look at this!

It is just that I will be away from my machines all week, and not able to do anything till probably Sunday :cry: :evil: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry:

So I will be dead frustrated sitting in some poxy hotel.......

Sorry Again and thanks

Dan :oops:

danward79
September 12th, 2004, 10:49 AM
Ok Don't worry!

I solved the mistery, in Tonto, when I set up the state, I put




State:Zone

It should have been


STATE:Zone

Thanks for all the help.

Dan

Ben S
September 12th, 2004, 12:59 PM
Hi Dan - Sorry I wasn't able to help out in time. Glad you found the problem!

Thanks Dan!

danward79
September 12th, 2004, 09:03 PM
No Worries, At least I can go away this moring knowing it is sorted!

Dan :wink:

Jlee
September 12th, 2004, 11:02 PM
That's about 5 miles from me. I think you'll need to set up your ccf to get a weather feed for this part of the country and then give it to me :wink: