Mouse wheel selector

Blitz3D Forums/Blitz3D Beginners Area/Mouse wheel selector

fox95871(Posted 2008) [#1]
http://h1.ripway.com/fox95871/index.html

Could someone please show me how I can make this stop going passed the low and high variable limits I've set for the mouse wheel? What I would normally do, If variable>5 variable=5, doesn't seem to work with the mouse wheel. The varaible for the images stops, but the mouse wheel variable just keeps going, so if you scroll passed the limit a lot, you then have to scroll all the way back in order for the images variable to catch up. This is more understandable in the code, and I've put some readouts on the screen to make things easier too. Thanks in advance, I'm sure as usual someone will know the answer.


Pongo(Posted 2008) [#2]
create a function to cap the values.

Function minmax# (value#,minval#,Maxval#)
	If value > maxval value = maxval
	If value < minval value = minval
	Return value
End Function


To use this, simply call minmax with the appropriate minimum and Max values.

example,...
print minmax (5,0,10) ; will return 5
print minmax (50,0,10) ;will return 10
print minmax (-10,0,10) ; will return 0

in your own code, you can use:
mousewheelposition=minmax(MouseZ(), minimum,maximum)

Edit: ahhh I see the problem you are having,... You will need to use this instead:
mousewheelposition=minmax(mousewheelposition + MouseZSpeed(), -5 ,-1)

now you are using the speed of the wheel to move rather than the absolute position.


fox95871(Posted 2008) [#3]
Okay thanks, I'll try that.


fox95871(Posted 2008) [#4]
http://h1.ripway.com/fox95871/index.html

Perfect. Thanks Pongo. Here's the working code in case anyone ever has the same problem.