Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (TipmyPip, 1 invisible), 18,731 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 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 | 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