Can I start a script on "talk to character" locally? [SOLVED]

Started by spook1, Fri 17/03/2006 19:32:11

Previous topic - Next topic

spook1

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

Wretched

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.

strazer

I think rooms can have their own on_mouse_click function. So you could try something like this:

Code: ags

// 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.

spook1

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.

SMF spam blocked by CleanTalk