Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Valentine on Sat 05/05/2007 19:21:14

Title: Broken Sword Interface
Post by: Valentine on Sat 05/05/2007 19:21:14
Boy, I'm asking a lot here.

What I'm looking for is a Broken Sword interface (left click interact, right click look at etc etc.) I've had a look around and I've found a couple of interfaces but they're all written for older versions of AGS. The functions don't work now, and I'm not good enough to figure out the replacement code I need despite trying.

Would anybody be able to help with this?

Thanks very much. 
Title: Re: Broken Sword Interface
Post by: Akatosh on Sat 05/05/2007 19:24:18
FSi wrote a mouse script for that once, I think.
Title: Re: Broken Sword Interface
Post by: Valentine on Sun 06/05/2007 17:17:16
I've had a look around, but I can't find the script you're refering to. Could you point me in the right direction?
Title: Re: Broken Sword Interface
Post by: Akatosh on Sun 06/05/2007 17:29:49
Well, you should probably PM him.
Title: Re: Broken Sword Interface
Post by: Dan_N on Sun 06/05/2007 17:57:49
I have the mouse script you need. I used it in Red Dwarf. And yeah, it's made by FSi. Clever bloke, he is.

Here's the script:

#sectionstart on_mouse_click  // DO NOT EDIT OR REMOVE THIS LINE
function on_mouse_click(MouseButton button) // called when a mouse button is clicked. button is either LEFT or RIGHT
{
  // script fixed for non-popup modal inv guis

  int x = mouse.x;
  int y = mouse.y;
  if (button == eMouseLeftInv) {
    if (mouse.Mode == eModeLookat) {
      player.ActiveInventory = InventoryItem.GetAtScreenXY(x, y);
      mouse.Mode = eModeUseinv;
    }
    else if (mouse.Mode == eModeUseinv) {  // tries to combine something
      InventoryItem * item = InventoryItem.GetAtScreenXY(x, y);
      item.RunInteraction(eModeUseinv);
      mouse.Mode = eModeLookat;
    }
  }
  else if (button == eMouseRightInv) {
    InventoryItem * item = InventoryItem.GetAtScreenXY(x, y);
    item.RunInteraction(eModeLookat);
    if(mouse.Mode == eModeUseinv) {
      mouse.Mode = eModeLookat;
    } // re-setting mouse mode if it was useinv
  }
  else if (button == eMouseLeft)
  {
    if(GetLocationType(x, y) == eLocationNothing) {
      ProcessClick(x,y, eModeWalkto);
    }
    else {
      if (mouse.Mode == eModeLookat) {  // look
        ProcessClick(x, y, eModeLookat);
      }
      else if (mouse.Mode == eModeUseinv) {  // tries to useinv
        ProcessClick(x, y, eModeUseinv);
      }
    }
  }
  else if (button == eMouseRight)
  {
    if (mouse.Mode == eModeUseinv) {
      mouse.Mode = eModeLookat; // kick off inventory
    }
    else if(GetLocationType(x, y) != eLocationNothing) {
      ProcessClick(x,y, eModeInteract);
      mouse.Mode = eModeLookat;
    }
  }
}
#sectionend on_mouse_click  // DO NOT EDIT OR REMOVE THIS LINE
Title: Re: Broken Sword Interface
Post by: Valentine on Sun 06/05/2007 18:30:22
Ah perfect! Thankyou very much.

I want the left click/right click effects to be switched round. I've gone through the code and swopped left/right, but when I play the game, right click doesn't get recognised until there has been a left click. Could anybody tell me how to fix this?

Thanks
Title: Re: Broken Sword Interface
Post by: Dan_N on Sun 06/05/2007 18:31:53
I suggest you leave it like the original, frankly :).
Title: Re: Broken Sword Interface
Post by: Valentine on Sun 06/05/2007 18:33:32
Hmm yes. Turns out walking works with right click now too.

This is getting more complicated lol.