Click on Entity.[CLOSED]

Posted By: Hirogens

Click on Entity.[CLOSED] - 09/20/09 22:20

Hi,

How to intercept a click on Entity ?

regards
Posted By: garv3

Re: Click on Entity. - 09/20/09 22:32

In the entity's function set "my.emask |= ENABLE_CLICK;" and for example "my.event = mouse_event;"
The function might look like:
Code:
function mouse_event() 
{
  if (event_type == EVENT_CLICK) 
  {
    //entity has been clicked! do whatever you want to do!
  }
}


Posted By: Hirogens

Re: Click on Entity. - 09/20/09 22:44

thanks,

but have you an explicite example...

regards
Posted By: garv3

Re: Click on Entity. - 09/20/09 22:54

I'll write an example down:
Code:
function entity_event()
{
  if (event_type == EVENT_CLICK) 
  {
    ent_remove(me);
  }
}

action entity_action()
{
  my.emask |= ENABLE_CLICK;
  my.event = entity_event;
}



If you assign the action "entity_action" to an entity it will be removed if you click it.
But be sure that:
1st: mouse_range is at least the distance between camera and entity
2nd: mouse_mode = 1 or 2

derGarv
Posted By: Hirogens

Re: Click on Entity. - 09/20/09 22:57

thanks,

My error was : mouse_mode missing


regards...
Posted By: garv3

Re: Click on Entity. - 09/20/09 22:58

You're welcome!
© 2023 lite-C Forums