Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: spook1 on Fri 17/03/2006 19:32:11

Title: Can I start a script on "talk to character" locally? [SOLVED]
Post by: spook1 on Fri 17/03/2006 19:32:11
I can define an event to happen when I talk to a character in the character definition window.
Now I need to have a local event (adressing room-variables) and therefore I need an event in a room, on "talk to character".

Is there a standard way to do this?

regards,
Martijn
Title: Re: Can I start a script on "talk to character" locally?
Post by: Wretched on Fri 17/03/2006 19:40:41
You can access the room objects in a global script, by using object[n]. , same with regions etc.

When I want a real room function to run, I usually setup a global variable, and constantly poll it in the rooms repeatedly-execute function.
Title: Re: Can I start a script on "talk to character" locally?
Post by: strazer on Fri 17/03/2006 19:54:20
I think rooms can have their own on_mouse_click function. So you could try something like this:


// room script

int somevar;

function on_mouse_click(MouseButton button) {

  if ((Character.GetAtScreenXY(mouse.x, mouse.y) == cThecharacter) && (button == eMouseLeft) && (mouse.mode == eModeTalkTo /* or whatever you named the mode */)) { // if mouse is over the character and left button is clicked in talk mode

    somevar = 2;

  }

}
// the global on_mouse_click function will automatically be called afterwards


Of course it would be easier if you just used a global variable instead.

Edit:
Added check for left mouse button.
Title: Re: Can I start a script on "talk to character" locally?
Post by: spook1 on Fri 17/03/2006 20:46:27
Thanks a lot!
I'll use the GI polling technique. It seems the easiest for me in my little game here.
The more elaborate answer provides me with new insights! Thnaks for that as well.