Gamestudio Links
Zorro Links
Newest Posts
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (EternallyCurious, AndrewAMD, TipmyPip, Quad), 902 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Mouse Check #138789
06/29/07 11:40
06/29/07 11:40
Joined: Jun 2007
Posts: 8
H
hammeraxe Offline OP
Newbie
hammeraxe  Offline OP
Newbie
H

Joined: Jun 2007
Posts: 8
Hi!

My problem is that I cant create a well-working code to check if the mouse has clicked a building and if it is to show its menu. The properties of all buildings are stored in an array buildings[400]. My function first checks the location of the mouse (works good) and then tries to find it in the building array. Then it recrods the number of the building and calls another function to display the menu.

The problem is that it works only sometimes...

Code:

function check
{
var a=0;
var found=0;
if((mouse_ent!=0)&&(mouse_ent!=MainObject)&&(mouse_ent!=PointerSquare))
{
NodeDetect();//returns x= the location of object
temp=x;
a=0;
found=0;
while(a<=99)&&(found==0)
{

if(temp==buildings[a])//buildings[a] stores the position of every building
{
found=1;
found_no=a;

}

if(a<99)&&(found==0)
{
a+=1;
}

wait(1);
}
}
if(found==1)&&(buildings[found_no+100]==0){ show_menu();} //checks if the building is still under construction
if(found==1)&&(buildings[found_no+100]>0){ show_constr();}
}

Re: Mouse Check [Re: hammeraxe] #138790
06/29/07 13:03
06/29/07 13:03
Joined: Mar 2006
Posts: 752
Portugal
demiGod Offline
User
demiGod  Offline
User

Joined: Mar 2006
Posts: 752
Portugal
With a brief view of your code (no time for more) i can thing about two things:

1) check your mouse_range maybe needs to be increased

2) where did you get the temp=x ? "x" its reserved for the engine, change it with other name, and i advice you to give meaning names to the variables and functions


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