Bypassing 'Interaction Editor' for clicking on a character(s) [SOLVED]

Started by Ryan Timothy B, Thu 14/08/2008 17:54:55

Previous topic - Next topic

Ryan Timothy B

I'm making an arcade game.
I have made several characters to act as the Tanks.
This interaction editor is proving annoying and I want to bypass it completely within the Room script itself.

When I click on the tanks they are supposed to explode (I've already programmed this successfully.. but with the interaction editor it Really gets annoying with the whole exporting and importing of variables etc).

I'm getting tired of hunting through the manual and the forums.  I'm obviously not searching properly due to not knowing what the code would be called.

Khris

Interaction editor events are triggered by ProcessClick().

To bypass them, replace the code for a left-click inside on_mouse_click().

Alternatively, it should be possible to add an on_mouse_click function to a room script:

Code: ags
function on_mouse_click(MouseButton button) {
  if (button != eMouseLeft) return;

  ClaimEvent(); // prevent global on_mouse_click execution
  if (GetLocation(mouse.x, mouse.y) == eLocationCharacter) {
    Character*c = Character.GetAtScreenXY(mouse.x, mouse.y);
    
    // do whatever's supposed to happen to c
  }
}

Ryan Timothy B

Thanks Khris, and with a speedy response as well!

I copied in the text, tweaked around with it and it's now working beautifully and Without that pesky Interaction Editor.

The only thing wrong with your code was 'GetLocation' should be 'GetLocationType'.  Thanks again.

Also I was kinda wondering what 'Character*c' is doing?  I tried using 'c' or even 'character*c' as an integer but it wouldn't let me.  I figured it was to tell me which character it was (eg:  character[c] )

zabnat

More likely character[c.ID].
Character*c (or Character* c or Character *c) means that c will be a character object. And you would use it then same way as you would with cEgo. Look up pointers from manual for more.

Ryan Timothy B

Well that's quite odd.

I try this and it gives me an error:

Code: ags

if (GetLocationType(mouse.x, mouse.y) == eLocationCharacter) {
   Character*c = Character.GetAtScreenXY(mouse.x, mouse.y);
   delete_tank(c.ID);
}



Then I tried this and it worked:

Code: ags

if (GetLocationType(mouse.x, mouse.y) == eLocationCharacter) {
   Character*c = Character.GetAtScreenXY(mouse.x, mouse.y);
   test=c.ID;  //assigned it to an integer before placing into function
   delete_tank(test);
}



That's alright though, I don't mind assigning it to a variable beforehand... BUT I then noticed if you do this, it still works without assigning it to a variable for the function--just as long as you played with it first?:

Code: ags

if (GetLocationType(mouse.x, mouse.y) == eLocationCharacter) {
   Character*c = Character.GetAtScreenXY(mouse.x, mouse.y);
   test=c.ID;  //assigned it to an integer before just using it anyway?
   delete_tank(c.ID);
}


That's a weird glitch.  I'll just assign it to an integer and pretend this little incident never happened.. lol  :D


Oh, and thanks zabnat for the help also. :P

SMF spam blocked by CleanTalk