Hi all,
I made a mini-game involving a slider that needs to be held at a certain value to complete it. It works great but currently you can exploit this by simply setting the cursor to the correct value and waiting it out.
Is it possible to prevent the player from setting the cursor? Or better yet, can I somehow tie the movement of the slider to the movement of the mouse (like moving the mouse up will move the slider at the same time)?
I hope that describes my problem clear enough...
You can just set your slider and make it's GUI not clickable.
function repeatedly_execute(){
if(GUI_With_Slider.Visible=true){
slider.Value = (mouse.y*(slider.Max-slider.Min))/System.ViewportHeight;
}
}
Could you show the code of what you have?
Wow that is quite the trick! Thanks a lot man!
It works well to control the slider, only it comes with two problems:
1. I cannot select the highest value, as my mouse doesn't seem to go all the way to the screen edge.
2. It moves in reverse. As my mouse goes lower, the number increases, thus making the slider go up.
Any way to fix these problems?
Oh and I used your code exactly like you mentioned:
function room_RepExec()
{
if (gSSD.Visible == true) {
sldSSD.Value = (mouse.y*(sldSSD.Max-sldSSD.Min))/System.ViewportHeight;
}
}
It's a linear function: sldSSD.Value = m * mouse.y + t
I) sldSSD.Max = m * 0 + t
II) sldSSD.Min = m * (System.ViewportHeight - 1) + t
t = sldSSD.Max
sldSSD.Min - sldSSD.Max = m * (System.ViewportHeight - 1)
m = (sldSSD.Min - sldSSD.Max) / (System.ViewportHeight - 1)
function room_RepExec() {
if (gSSD.Visible == true) {
sldSSD.Value = mouse.y * (sldSSD.Min - sldSSD.Max) / (System.ViewportHeight - 1) + sldSSD.Max;
}
}
OMG this works just perfectly!
Thanks a lot guys! :-D