PDA

View Full Version : Which UI element changed?



maxim capra
05-27-2010, 01:53 AM
Maybe a simple question, but i can't find a solution:

Here's the case: I've got generated buttons, sliders and stuff:

for(i=1;i<=500;i++) {
s`i = ctlslider("slider", 0, 0, 100);
ctlrefresh(s`i,string("slider",i));
b`i = ctlbutton("button",15,"buttonUDF",string(i));
st`i = ctlstate("sbutton",0,15,string("keybutton",i));
}

First annoying thing: I have to manually set global variables for each s'i and b'i and so on? Like s1;s2;s3;s4;s5 .... 500? Can i define global variables inside a function? I could use s1..500; then....

Second thing: I want to call a UDF, when something changes. And I want to have the information inside my UDF, WHICH slider or button has been changed. There's no problem with buttons, because i can send the variable "i" to the UDF. But there's a problem with state buttons and sliders, as you may can see. I just managed to call a different UDF for every slider, but that's not very practicable for 500 sliders....

Did i overlook something? Someone a solution for this?

Thanks,
Philipp

Matt
05-27-2010, 02:25 AM
Can i define global variables inside a function?

I'm pretty sure the answer is no to that one, as defining them in a function makes them local to that function.

Unless there is a 'Global' statement that can make them global, but I'm not aware of one.

As far as I know there is also no way to get the ID of the gadget that sent a value to a UDF, unless it allows custom passing of variables as with the button.

Lightwolf
05-27-2010, 02:37 AM
First annoying thing: I have to manually set global variables for each s'i and b'i and so on? Like s1;s2;s3;s4;s5 .... 500? Can i define global variables inside a function? I could use s1..500; then....

I'm pretty sure that you could store them in a global array.

Cheers,
Mike

Matt
05-27-2010, 02:41 AM
I'm pretty sure that you could store them in a global array.

Cheers,
Mike

Ahhhh, yes, define a global array and just assign them to it as you go. Too early on a morning for me!

maxim capra
05-27-2010, 02:47 AM
thanks matt for the reply,

yes, i meant something like a "global" statement. because outside the functions, the only way i know of how to declare global variables, i'm just able to write them down, one by the other. same with an array i think (i can't reserve an empty global array with 500 elements and fill them later, can i? without writing @nil,nil,nil,nil,nil,nil,nil.....*500 @ :) )

maxim capra
05-27-2010, 02:49 AM
you're to fast for me :) 2 answers while i wrote :) ok, so i have to dig deeper into arrays, i'm just not used to lscript syntax i think ....

Matt
05-27-2010, 02:54 AM
i'm just not used to lscript syntax i think ....

The LScript Bible, so to speak:

http://www.mikegreen.name/Lscript/Lscript%20Index.html

maxim capra
05-27-2010, 04:17 AM
yes, i've already found this "bible" :) it's so important ... the docu is so bad .. it seems there are a lot of secrets in lscript and you have to find them the hard way (other peoples code, sdk, commander, mike's bible, try, try, try....)

i've managed the "first problem" with arrays, thanks to all!

but the second problem still exists, i can't find anything on this

maxim capra
05-27-2010, 09:37 AM
solved so far (workaraound)

as a present, here's the basic script i was working on. i needed something like sliderbox for a custom UI i'm building for a character rig. but sliderbox is broken under lightwave 9.x and not open source and i couldn't find another solution than to write it myself. it's currently just the skeleton script, if you want to change the number of sliders or the labels, you have to do it in the script (just change the global variables). this works for me. if someone builds a better UI around it, please let me know. if you find it useful please let me know.

thanks for the help again