Mouse Check

Posted By: hammeraxe

Mouse Check - 06/29/07 11:40

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();}
}
Posted By: demiGod

Re: Mouse Check - 06/29/07 13:03

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
© 2024 lite-C Forums