PDA

View Full Version : slider and variable



mpg732
October 22nd, 2009, 04:15 PM
Im using a slider to scroll through my dvd collection. What I want to do it when the slider is at variable 1, I can display the letter A. When the slider variable is changed to 2, then the letter B will be displayed. So on and so on... How can this be done. Im sure it will be through LUA. but some help would be great.

Rob H
October 22nd, 2009, 09:18 PM
You'll need to use NetRemote.RegisterVariableWatch() on the slider variable let's say it's called slider

So something like


NetRemote.RegisterVariableWatch("slider",
function(var, value)
local char = string.tochar(tonumber(value) -1 + string.byte('A'))
-- here you call a function that displays DVDs starting with the appropriate letter
end)

mpg732
February 5th, 2010, 07:37 PM
Rob, im just getting back to this, could use some more help in getting this to work, I have added your example to my LUNA file, and created a slider with variables 0 to 26. First, how do you get the apprperate leter to disply in the slider button. Second, I do believe the sample luna scrip is incomplete. Please help

Mike

Rob H
February 6th, 2010, 09:16 AM
For a start you could add the following before the comment


NetRemote.SetVariable('SliderLabel', char)

And change the name of the button to {SliderLabel}

mpg732
February 8th, 2010, 05:46 PM
Ok, this is what I have for my luna code,

NetRemote.SetVariable('SliderLabel', char)
NetRemote.RegisterVariableWatch("slider",
function(var, value)
local char = string.tochar(tonumber(value) -1 + string.byte('A'))
-- here you call a function that displays DVDs starting with the appropriate letter
end)

Still doesn't work, any help would be great,

Mike

Rob H
February 9th, 2010, 03:43 AM
Try this instead

mpg732
February 10th, 2010, 01:49 PM
Ok, I think we are getting closer, now at least get a value of 0 to display as the slider label, were before I got nothing. Is there a simple way of doing this, were I can manualy assign, when the varable of the slider is = to 1, display "A". when = to 2 display "B". So on and so on.

Rob H
February 10th, 2010, 04:04 PM
Hmm... that's what that code was intended to do!

Ah, I see what's wrong.

That should be string.char not string.tochar - sorry about that.

mpg732
February 12th, 2010, 11:48 AM
That worked,
Thanks for your help.....

jwilson56
February 12th, 2010, 12:33 PM
What would be nice is if a small example CCF could be created and uploaded to an example place so that others could benefit from this.

Rob could you discuss this with Ron and maybe make a place to upload small examples in the forum.

mpg732
February 15th, 2010, 01:58 PM
Rob, I can send you a sample if you wish to post it some place fore people to down load.

Just let me know were to send it too.

Mike