opening options bug

Blitz3D Forums/Blitz3D Beginners Area/opening options bug

chwaga(Posted 2007) [#1]
I'm trying to add a way to open an options panel from the menu. I can open up the menu in game, and open up the options, the only problem is, though, that once I do that, niether my quit button, or commands from the command panel work (they work if I remove the code for opening the options.)

Here's the code dealing with my problem:

If MouseX() > 465 And MouseX() < 785 And MouseY() > 540 And MouseY() < 580 And menu1=1 And MouseHit(1) Then
quit=1
EndIf

If MouseX() > 540 And MouseX() < 700 And MouseY() > 620 And MouseY() < 660 And menu1=1 And MouseHit(1) Then
If menu12=1
menu12=0
EndIf
EndIf

...

;ui stuff-----------------------------------------------------------
If menu1=1 And menu12=1 Then
DrawImage menu,400,200
EndIf


If MouseX() > 550 And MouseX() < 705 And MouseY() > 350 And MouseY() < 390 And menu1=1 Then
DrawImage menu01,400,200
EndIf

If MouseX() > 550 And MouseX() < 705 And MouseY() > 350 And MouseY() < 390 And menu1=1 And MouseHit(1) Then
optionsopen=true
EndIf

If optionsopen=True And menu12=1 Then
DrawImage options,400,200
EndIf

If MouseX() > 490 And MouseX() < 755 And MouseY() > 435 And MouseY() < 485 And menu1=1 Then
DrawImage menu02,400,200
EndIf

If MouseX() > 465 And MouseX() < 785 And MouseY() > 540 And MouseY() < 580 And menu1=1 Then
DrawImage menu03,400,200
EndIf

If MouseX() > 540 And MouseX() < 700 And MouseY() > 620 And MouseY() < 660 And menu1=1 Then
DrawImage menu04,400,200
EndIf

DrawImage bar,567,940
DrawImage invico,1185,945
DrawImage equipandabils,1010,941
DrawImage notebook,1100,940
If ImagesOverlap (invico,1185,945,mouseplace,MouseX(),MouseY() ) Then
DrawImage highlight,1186,940
EndIf

If ImagesOverlap (equipandabils,1010,941,mouseplace,MouseX(),MouseY() ) Then
DrawImage highlight,1010,941
EndIf

If ImagesOverlap (notebook,1100,940,mouseplace,MouseX(),MouseY() ) Then
DrawImage highlight,1100,940
EndIf

NOTE: If i left out some code, let me know...I've gotta organize it soon lol.


b32(Posted 2007) [#2]
Maybe it is this: after reading MouseHit() it is reset to zero. So if you are using this command more than once each loop, the results become unpredictable: sometimes the first call responds, sometimes another, depending on which line is executes after the mouse is clicked.
To avoid this, store MouseHit() in a variable, and use that variable instead. You can easily replace every MouseHit by using search&replace (ctrl+r).


chwaga(Posted 2007) [#3]
perfect! thanks :D