1 registered members (PeroPero),
860
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
is a variable max value in hslider/vslider possible??
#406212
08/15/12 11:24
08/15/12 11:24
|
Joined: Jul 2011
Posts: 69
pjotr987
OP
Junior Member
|
OP
Junior Member
Joined: Jul 2011
Posts: 69
|
hi guys, i wounder if htere is a possibility to create a slider with hslider or vslider with variable maximum value.
hslider (x, y, len, bmap, min, max, var); vslider (x, y, len, bmap, min, max, var);
is it possible to replace the max value by a variable?
thanks in advance
Last edited by pjotr987; 08/15/12 11:24.
|
|
|
Re: is a variable max value in hslider/vslider possible??
[Re: pjotr987]
#406213
08/15/12 11:38
08/15/12 11:38
|
Joined: Nov 2007
Posts: 2,568 Germany, BW, Stuttgart
MasterQ32
Expert
|
Expert
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
|
you can just calculate yourself:
function getslider(var value, var slidmin, var slidmax, var mymin, var mymax) { return ((mymax - mymin) * (value - slidmin)) / (slidmax - slidmin) + mymin; }
|
|
|
Re: is a variable max value in hslider/vslider possible??
[Re: MasterQ32]
#447560
12/20/14 09:03
12/20/14 09:03
|
Joined: Jun 2010
Posts: 590 California
Ruben
User
|
User
Joined: Jun 2010
Posts: 590
California
|
you can just calculate yourself:
function getslider(var value, var slidmin, var slidmax, var mymin, var mymax) { return ((mymax - mymin) * (value - slidmin)) / (slidmax - slidmin) + mymin; } How would this work in finding a variable max value for hslider? Would you place this function in the "max" position of hslider, like so?:
hslider (x, y, len, bmap, min, getslider(), var);
??? Also, what is the difference between slidmin and mymin, or slidmax and mymax ?
|
|
|
Re: is a variable max value in hslider/vslider possible??
[Re: MasterQ32]
#447569
12/20/14 12:18
12/20/14 12:18
|
Joined: Jun 2010
Posts: 590 California
Ruben
User
|
User
Joined: Jun 2010
Posts: 590
California
|
So, lets say I have an hslider that looks like this ( itm_qnt_ent_from variable dynamically equals the dynamic max amount that I want for the hslider at any given time):
hslider(450, 514, 150, "horizontalSlider.pcx", 0, 1, itm_qnt_ent_from);
...and lets say I also have a function that looks like this:
function getslider(var value, var slidmin, var slidmax, var mymin, var mymax)
{
return ((mymax - mymin) * (value - slidmin)) / (slidmax - slidmin) + mymin;
}
How would I use the getslider function? Would it be like this?:
int dynamicMaxValue = getslider(itm_qnt_ent_from, 0, 1, 0, itm_qnt_ent_from);
...
hslider(450, 514, 150, "horizontalSlider.pcx", 0, dynamicMaxValue, itm_qnt_ent_from);
Wouldn't the hslider function reject the dynamicMaxValue variable, because it does not accept variables for the max? I guess I am a little confused on how the getslider function would be applied.
Last edited by Ruben; 12/20/14 12:20.
|
|
|
Re: is a variable max value in hslider/vslider possible??
[Re: Ruben]
#447571
12/20/14 12:35
12/20/14 12:35
|
Joined: Nov 2007
Posts: 2,568 Germany, BW, Stuttgart
MasterQ32
Expert
|
Expert
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
|
hslider(450, 514, 150, "horizontalSlider.pcx", 0, 100, helperVar);
var result = getslider(helperVar, 0, 100, 0, dynamicMaxValue);
|
|
|
Re: is a variable max value in hslider/vslider possible??
[Re: MasterQ32]
#447575
12/20/14 15:55
12/20/14 15:55
|
Joined: Jun 2010
Posts: 590 California
Ruben
User
|
User
Joined: Jun 2010
Posts: 590
California
|
So, can helperVar and dynamicMaxValue be the same variable, like for example, itm_qnt_ent_from , or do they have to be different variables?
How would I use the "result" variable? Do I just let it sit there?
Last edited by Ruben; 12/20/14 15:58.
|
|
|
Re: is a variable max value in hslider/vslider possible??
[Re: MasterQ32]
#447576
12/20/14 16:04
12/20/14 16:04
|
Joined: Jun 2010
Posts: 590 California
Ruben
User
|
User
Joined: Jun 2010
Posts: 590
California
|
hslider(450, 514, 150, "horizontalSlider.pcx", 0, 100, helperVar);
var result = getslider(helperVar, 0, 100, 0, dynamicMaxValue); I tried this, but I get the same result. The horizontal slider shows up, but it is allowing the range for the horizontal slider button to go from 0 all the way to 100, when the itm_qnt_ent_from variable only equals 4, which should be the current max value. If itm_qnt_ent_from ends up equaling 4, I only want the horizontal slider to go up to 4, and no higher. However, with the above configuration, the lowest amount at the far left will be 0, and the slider button will start off at 4, but the player is capable of moving the horizontal button all the way to 100, by moving the button to the far right. In the above scenario, if the player moves the button to the far right, I only want the amount to be 4, and no higher. If the player moves the button to the far left, I want the amount to be 0, and no less. If the itm_qnt_ent_from value changes, to lets say 7, then I want the horizontal slider to change when it is brought up, to being able to move the horizontal button to the far right making the amount equal 7, and no higher. And if the player moves the horizontal button to the far left, it should equal 0, and no less. In other words, I want the hslider to have a dynamic max value, based on the value of the itm_qnt_ent_from variable.
Last edited by Ruben; 12/20/14 16:09.
|
|
|
|