Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (PeroPero), 860 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
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
P
pjotr987 Offline OP
Junior Member
pjotr987  Offline OP
Junior Member
P

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 Offline
Expert
MasterQ32  Offline
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;
}


Visit my site: www.masterq32.de
Re: is a variable max value in hslider/vslider possible?? [Re: MasterQ32] #406222
08/15/12 12:41
08/15/12 12:41
Joined: Jul 2011
Posts: 69
P
pjotr987 Offline OP
Junior Member
pjotr987  Offline OP
Junior Member
P

Joined: Jul 2011
Posts: 69
WOW, works perfectly !!

thanks man

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 Offline
User
Ruben  Offline
User

Joined: Jun 2010
Posts: 590
California
Originally Posted By: MasterQ32
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?:

Code:
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: Ruben] #447568
12/20/14 11:50
12/20/14 11:50
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
slidmin/slidmax is the minimum/maximum of your hslider, mymin/mymax the real minimum/maximum value you want to have.
you just need to carry a helper variable from the hslider to the slider evaluation


Visit my site: www.masterq32.de
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 Offline
User
Ruben  Offline
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):

Code:
hslider(450, 514, 150, "horizontalSlider.pcx", 0, 1, itm_qnt_ent_from);



...and lets say I also have a function that looks like this:

Code:
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?:

Code:
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 Offline
Expert
MasterQ32  Offline
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);


Visit my site: www.masterq32.de
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 Offline
User
Ruben  Offline
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 Offline
User
Ruben  Offline
User

Joined: Jun 2010
Posts: 590
California
Originally Posted By: MasterQ32
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.
Re: is a variable max value in hslider/vslider possible?? [Re: Ruben] #447577
12/20/14 16:46
12/20/14 16:46
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
yes i know what you want. But i don't think you get what i was writing several times now. Think about the code i've written. It doesn't work if you just plain stupid copy paste it. Code never works if you copy paste it.
Think about it. Think about what i am doing here. Just some hint:
http://en.wikipedia.org/wiki/Cross-multiplication


Visit my site: www.masterq32.de
Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1