Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Slasher on Sun 13/12/2015 08:53:12

Title: Object string display function
Post by: Slasher on Sun 13/12/2015 08:53:12
Hi

how can I change this to display what ever object the mouse clicks on within one function:

Code (ags) Select

function  object_click()
{
 
c009.Phylactere(String.Format("That %s does not seem to harbor anything about the plans by Skull.",object[19].Name)); // any object not just object 19?
}


I could do them individually and just change the object number but looking for a more simpler way ;)

cheers


Title: Re: Object string display function
Post by: Snarky on Sun 13/12/2015 10:28:54
You'll need something like:

Code (ags) Select

function  object_click()
{
  Object* clickedObject = Object.GetAtScreenXY(mouse.x, mouse.y);
  if(object != null)
    c009.Phylactere(String.Format("That %s does not seem to harbor anything about the plans by Skull.",clickedObject.Name));
  else // shouldn't happen!
  {
    // ...
  }
}
Title: Re: Object string display function
Post by: Slasher on Sun 13/12/2015 10:51:38
Cheers Snarky,

i should have known had to reference object first :-[