about Mouse.ButtonWait 
	 
	
		| Author | 
		Message | 
	 
		 
		manDEE
 
 
 
    
		 | 
		
		
			
				  Posted: Sat Jun 11, 2011 11:09 pm    Post subject: about Mouse.ButtonWait  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				What is it you are trying to achieve?
 
<Replace all the <> with your answers/code and remove the <>>
 
 
 
What is the problem you are having?
 
I am doing a school project. One part of my program is to search in a area to get different tools.
 
I use Mouse.Where for it.
 
The problem is that the word won't show up because I press my mouse before Mouse.ButtonWait.
 
I don't know how to explain my problem and I know what I just typed in is really confusing.    
 
I am sorry about that.
 
 
Describe what you have tried to solve this problem
 
I try putting more Mouse.ButtonWait but it didn't work.
 
 
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
 
Part of my program:
 
 
	  | Turing: | 	 		  
    delay (800)
    cls
    Pic.Draw (garden1,  1,  1,  picMerge)
    Mouse.ButtonWait ("down", x, y, btnNumber, btnUpDown )
    Font.Draw ("I have 5 chances to search.", 180,  110, font2,  white)
    Mouse.ButtonWait ("down", x, y, btnNumber, btnUpDown )
    loop
        cls
        Pic.Draw (garden,  1,  1,  picMerge)
        Mouse.ButtonWait ("down", x, y, btnNumber, btnUpDown )
        loop
            Pic.Draw (garden,  1,  1,  picMerge)
            Mouse.Where (x, y, button )
            if button  = 1 and x >=  10 and x <=  280 and y >=  40 and y <=  160 or button  = 1 and x >=  130 and x <=  280 and y >=  210 and y <=  300 or button  = 1 and x >=  500 and x <=  1 and y >=
                     660 and y <=  130 or button  = 1 and x >=  550 and x <=  660 and y >=  210 and y <=  300 then             %%%%%%roses
                delay (500)
                Pic.Draw (garden1,  1,  1,  picMerge)
                Mouse.ButtonWait ("down", x, y, btnNumber, btnUpDown )
                Font.Draw ("There is roses everywhere.", 180,  110, font2,  white)
                Mouse.ButtonWait ("down", x, y, btnNumber, btnUpDown )
                counts  := counts +  1
                if scissors  = 0 then             %%%no scissors
                    cls
                    Pic.Draw (garden1,  1,  1,  picMerge)
                    Mouse.ButtonWait ("down", x, y, btnNumber, btnUpDown )
                    Font.Draw ("I can get some if I have scissors.", 180,  110, font2,  white)
                    Mouse.ButtonWait ("down", x, y, btnNumber, btnUpDown )
                elsif scissors  = 1 then             %%% have scissors
                    roses  := roses +  1
                    Pic.Draw (garden1,  1,  1,  picMerge)
                    Mouse.ButtonWait ("down", x, y, btnNumber, btnUpDown )
                    Font.Draw ("Let me get one.", 180,  110, font2,  white)
                    Mouse.ButtonWait ("down", x, y, btnNumber, btnUpDown )
                end if
            elsif button  = 1 and x >=  400 and x <=  530 and y >=  130 and y <=  210 then
                delay (500)
                Pic.Draw (garden1,  1,  1,  picMerge)
                Mouse.ButtonWait ("down", x, y, btnNumber, btnUpDown )
                Font.Draw ("Nothing special, just water.", 180,  110, font2,  white)
                Mouse.ButtonWait ("down", x, y, btnNumber, btnUpDown )
                counts  := counts +  1
                exit
            elsif button  = 1 and x >=  465 and x <=  490 and y >=  350 and y <=  378 then
                if silverkey  = 0 then
                    delay (500)
                    Pic.Draw (garden1,  1,  1,  picMerge)
                    Mouse.ButtonWait ("down", x, y, btnNumber, btnUpDown )
                    Font.Draw ("What is that shinny thing?", 180,  110, font2,  white)
                    Mouse.ButtonWait ("down", x, y, btnNumber, btnUpDown )
                    Font.Draw ("I walk closer and I find a silver key.", 180,  80, font2,  white)
                    Mouse.ButtonWait ("down", x, y, btnNumber, btnUpDown )
                    silverkey  := silverkey +  1
                    counts  := counts +  1
                    exit
                else
                    delay (500)
                    Pic.Draw (garden1,  1,  1,  picMerge)
                    Mouse.ButtonWait ("down", x, y, btnNumber, btnUpDown )
                    Font.Draw ("Nothing special here.", 180,  110, font2,  white)
                    Mouse.ButtonWait ("down", x, y, btnNumber, btnUpDown )
                    counts  := counts +  1
                    exit
                end if
                drawbox (550,  210,  660,  300,  black)
            elsif button  = 1 and x >=  340 and x <=  460 and y >=  295 and y <=  360 then
                delay (500)
                Pic.Draw (garden1,  1,  1,  picMerge)
                Mouse.ButtonWait ("down", x, y, btnNumber, btnUpDown )
                Font.Draw ("Ewwww, there is a giant spider.", 180,  110, font2,  white)
                counts  := counts +  1
                exit
            else
                delay (500)
                Pic.Draw (garden1,  1,  1,  picMerge)
                Mouse.ButtonWait ("down", x, y, btnNumber, btnUpDown )
                Font.Draw ("Nothing special here.", 180,  110, font2,  white)
                counts  := counts +  1
                exit
            end if
        end loop
        exit when counts  = 5
    end loop
  | 	  
 
 
Please specify what version of Turing you are using
 
turing 4.1.1 | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
		 
		Sponsor Sponsor 
		 
  
		 | 
		
 | 
	 
	 
		  | 
	 
				 
		Tony
 
  
 
    
		 | 
		
		
			
				  Posted: Sat Jun 11, 2011 11:25 pm    Post subject: RE:about Mouse.ButtonWait  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				this could be tricky, read the documentation for details -- Mouse.ButtonWait. The first bit is important
 
Quote: 
 
The Mouse.ButtonWait procedure gets information about a mouse event and removes it from the queue.
 
 
 
Adding more instances of waiting for something to appear in a queue will not help if the event queue is empty. | 
			 
			
				 
Tony's programming blog. DWITE - a programming contest. | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		manDEE
 
 
 
    
		 | 
		
		
			
				  Posted: Sat Jun 11, 2011 11:36 pm    Post subject: RE:about Mouse.ButtonWait  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				| I think I am going to try using left and right button instead of only using left button. Don't know if it will work or not though. | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		2F_Zelda
 
 
 
    
		 | 
		
		
			
				  Posted: Sat Jun 11, 2011 11:40 pm    Post subject: Re: about Mouse.ButtonWait  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				| You said this was only a part of your program, so do you have a  anywhere? If so, then you're missing a View.Update in this loop. | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		manDEE
 
 
 
    
		 | 
		
		
			
				  Posted: Sun Jun 12, 2011 1:55 pm    Post subject: Re: about Mouse.ButtonWait  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				I didn't have any 
 
 
 
 
before, so I tried input it and it kind of work, kind of doesn't. Probably because I don't really know how to input 
 
 
in the right spot.
 
 
The one bellow is after I edited it.
 
 
	  | Turing: | 	 		  
View.Set ("offscreenonly")
loop
    var count, counts  : int
    count  := 0
    counts  := 0
    loop
        cls
        Pic.Draw (map,  1,  1,  picMerge)
        energy  (en )
        Mouse.Where (x, y, button )
        if button  = 1 and x >=  280 and x <=  480 and y >=  295 and y <=  460 then         %%%%%%%%%%%%%%%%%%%%garden
            count  := count +  1
            en  := en +  20
            cls
            Pic.Draw (garden,  1,  1,  picMerge)
            energy  (en )
            Mouse.ButtonWait ("down", x, y, btnNumber, btnUpDown )
            Pic.Draw (garden1,  1,  1,  picMerge)
            Font.Draw ("Oh, I get to see the sun, finally.", 180,  110, font2,  white)
            Mouse.ButtonWait ("down", x, y, btnNumber, btnUpDown )
            View.Update
            cls
            Pic.Draw (garden1,  1,  1,  picMerge)
            Mouse.ButtonWait ("down", x, y, btnNumber, btnUpDown )
            Font.Draw ("No one's here. What should I do?", 180,  110, font2,  white)
            View.Update
            drawfillbox (150,  220,  550,  400,  black)
            drawbox (170,  330,  530,  380,  white)
            drawbox (170,  240,  530,  290,  white)
            Font.Draw ("Search", 300,  345, font2,  white)
            Font.Draw ("Exit", 290,  255, font2,  white)
            View.Update
            loop
                Mouse.Where (x, y, button )
                if button  = 0 and x >=  190 and x <=  510 and y >=  330 and y <=  380 then
                    Font.Draw ("Search", 300,  345, font2,  yellow)
                    View.Update
                elsif button  = 0 and x >=  190 and x <=  510 and y >=  240 and y <=  290 then
                    Font.Draw ("Exit", 290,  255, font2,  yellow)
                    View.Update
                elsif button  = 1 and x >=  190 and x <=  510 and y >=  330 and y <=  380 then         %%%%%%%%%%%%%%%%%serch
                    cls
                    Pic.Draw (garden1,  1,  1,  picMerge)
                    Font.Draw ("I have 5 chances to search.", 180,  110, font2,  white)
                    Mouse.ButtonWait ("down", x, y, btnNumber, btnUpDown )
                    View.Update
                    loop
                        cls
                        Pic.Draw (garden,  1,  1,  picMerge)
                        Mouse.ButtonWait ("down", x, y, btnNumber, btnUpDown )
                        View.Update
                        loop
                            cls
                            Pic.Draw (garden,  1,  1,  picMerge)
                            Mouse.Where (x, y, button )
                            if button  = 1 and x >=  10 and x <=  280 and y >=  40 and y <=  160 or button  = 1 and x >=  130 and x <=  280 and y >=  210 and y <=  300 or button  = 1 and x >=  500 and x
 
                                    <=  1 and y >=
                                     660 and y <=  130 or button  = 1 and x >=  550 and x <=  660 and y >=  210 and y <=  300 then         %%%%%%roses
                                cls
                                Pic.Draw (garden1,  1,  1,  picMerge)
                                Font.Draw ("There is roses everywhere.", 180,  110, font2,  white)
                                Mouse.ButtonWait ("down", x, y, btnNumber, btnUpDown )
                                counts  := counts +  1
                                View.Update
                                if scissors  = 0 then         %%%no scissors
                                    cls
                                    Pic.Draw (garden1,  1,  1,  picMerge)
                                    Font.Draw ("I can get some if I have scissors.", 180,  110, font2,  white)
                                    Mouse.ButtonWait ("down", x, y, btnNumber, btnUpDown )
                                    View.Update
                                elsif scissors  = 1 then         %%% have scissors
                                    roses  := roses +  1
                                    cls
                                    Pic.Draw (garden1,  1,  1,  picMerge)
                                    Font.Draw ("Let me get one.", 180,  110, font2,  white)
                                    Mouse.ButtonWait ("down", x, y, btnNumber, btnUpDown )
                                    View.Update
                                end if
                            elsif button  = 1 and x >=  400 and x <=  530 and y >=  130 and y <=  210 then
                                cls
                                Pic.Draw (garden1,  1,  1,  picMerge)
                                Font.Draw ("Nothing special, just water.", 180,  110, font2,  white)
                                Mouse.ButtonWait ("down", x, y, btnNumber, btnUpDown )
                                counts  := counts +  1
                                View.Update
                                exit
                            elsif button  = 1 and x >=  455 and x <=  500 and y >=  340 and y <=  388 then
                                if silverkey  = 0 then
                                    cls
                                    Pic.Draw (garden1,  1,  1,  picMerge)
                                    Font.Draw ("What is that shinny thing?", 180,  110, font2,  white)
                                    Mouse.ButtonWait ("down", x, y, btnNumber, btnUpDown )
                                    Font.Draw ("I walk closer and I find a silver key.", 180,  80, font2,  white)
                                    Mouse.ButtonWait ("down", x, y, btnNumber, btnUpDown )
                                    silverkey  := silverkey +  1
                                    counts  := counts +  1
                                    View.Update
                                    exit
                                else
                                    cls
                                    View.Update
                                    Pic.Draw (garden1,  1,  1,  picMerge)
                                    Font.Draw ("Nothing special here.", 180,  110, font2,  white)
                                    Mouse.ButtonWait ("down", x, y, btnNumber, btnUpDown )
                                    counts  := counts +  1
                                    View.Update
                                    exit
                                end if
                                drawbox (550,  210,  660,  300,  black)
                            elsif button  = 1 and x >=  340 and x <=  460 and y >=  295 and y <=  360 then
                                cls
                                Pic.Draw (garden1,  1,  1,  picMerge)
                                Font.Draw ("Ewwww, there is a giant spider.", 180,  110, font2,  white)
                                counts  := counts +  1
                                exit
                            else
                                delay (200)
                                cls
                                Pic.Draw (garden1,  1,  1,  picMerge)
                                Font.Draw ("Nothing special here.", 180,  110, font2,  white)
                                counts  := counts +  1
                                exit
                            end if
                            View.Update
                        end loop
                        exit when counts  = 5
                        View.Update
                    end loop
                elsif button  = 1 and x >=  190 and x <=  510 and y >=  240 and y <=  290 then
                    delay (800)
                    cls
                    Pic.Draw (garden1,  1,  1,  picMerge)
                    Mouse.ButtonWait ("down", x, y, btnNumber, btnUpDown )
                    Font.Draw ("Let's go back.", 180,  110, font2,  white)
                    Mouse.ButtonWait ("down", x, y, btnNumber, btnUpDown )
                    exit
                else
                    Font.Draw ("Search", 300,  345, font2,  white)
                    Font.Draw ("Exit", 290,  255, font2,  white)
                    View.Update
                end if
                exit when counts  = 5
                View.Update
            end loop
        end if
        View.Update
    end loop
    View.Update
end loop
  | 	  
 
 
I hope I can figure out how to do it today     But if not, I can still ask my teacher tmr.
 
Thanks![/code] | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		 | 
	 
 
	
	
	 
	
	 |