Setup of 2-click interface. Left and Right mouse button.. How? [SOLVED]

Started by poc301, Thu 08/09/2011 19:57:21

Previous topic - Next topic

poc301

So I am just beginning to learn AGS 3.2 after many many many years of using 2.7.  I like the new setup, it seams much easier to use.

My problem is figuring out how to do some basic stuff, since the Forum Search function is broken.

I began a new game using the "Verb Coin" template.

I want to setup my game to allow the hotspots and objects to have a single cursor.  When the target is left-clicked, I want one set of code to run (walk to).  When the right button is clicked on the mouse, I want another set of code to run (use, look at, etc).

I figure I need to use standard code like :

if (button == eMouseLeft) {
// Walk-to script
 }

else if (button == eMouseRight) {
// Activate script
}


But I have no idea in this new version where to put it.  When I go into the properties of the hotspots/objects in AGS 3.2, there is a line for descriptions in the @OVERHOTSPOT@ line for the various things, but I am not sure how to set this up.

Thanks,

Bill


pcj

This code will need to be in on_mouse_click(MouseButton button) in the global script, then you can use ProcessClick(mouse.x, mouse.y, CursorMode) to process the left/right click as a different mode on the individual hotspot/object depending on the click.

Code: ags

function on_mouse_click(MouseButton button) {
  if (button == eMouseLeft) {
  // Walk-to script
     ProcessClick(mouse.x,mouse.y,eModeWalkTo);
  }
  else if (button == eMouseRight) {
  // Activate script
     ProcessClick(mouse.x,mouse.y,eModeInteract);
  }
}
Space Quest: Vohaul Strikes Back is now available to download!

poc301

Thanks so much Pcj!  I'll give that a try when I get home!

-Bill

Grim

Actually, I personally think we could do with a game template for this left/right click interface. Searching the forums (when the search function isn't broken... :P) only gets you a very old Broken Sword template, which I used for Downfall but found it extremely old and buggy and it didn't really work well with different game resolutions.

   I'm guessing the reason for there not being one is that most AGSers who are better at scripting can whip one out in five minutes... but it just would be so nice to have it handy, or rather- to have an ultimate version that works 100% bug free, with a proper inventory and hotspot labels displayed. I, personally, would make more short games if it didn't mean starting everything from scratch...

  Verbcoin is all right... but I'm not a great fan of it. And the Sierra-based one hasn't aged well at all, what with all the cursors changing and fiddling around...

  I apologize for mentioning it in this specific topic- I hope you don't mind poc301. I just needed to get this off my chest;)

poc301

Quote from: Grim on Sat 10/09/2011 04:23:12
Actually, I personally think we could do with a game template for this left/right click interface. Searching the forums (when the search function isn't broken... :P) only gets you a very old Broken Sword template, which I used for Downfall but found it extremely old and buggy and it didn't really work well with different game resolutions.

   I'm guessing the reason for there not being one is that most AGSers who are better at scripting can whip one out in five minutes... but it just would be so nice to have it handy, or rather- to have an ultimate version that works 100% bug free, with a proper inventory and hotspot labels displayed. I, personally, would make more short games if it didn't mean starting everything from scratch...

  Verbcoin is all right... but I'm not a great fan of it. And the Sierra-based one hasn't aged well at all, what with all the cursors changing and fiddling around...

  I apologize for mentioning it in this specific topic- I hope you don't mind poc301. I just needed to get this off my chest;)

No problem whatsoever.  I'd be glad to help out.  I literally began a new game (sierra-style original interface), and did NOTHING but the Left/Right interface code.  When I get to my other computer, I will box it up as a template and make it available.  I'll post a link to it so people can grab it.  Won't be until Monday though :(

-Bill

hedgefield

I could take a stab at it, although my own single-cursor script is set up a little differently. For me LMB is walk/talk/interact, and RMB is look. I suppose it would be pretty easy to flip them though. Then I have an additional clause that handles custom inventory stuff, like LMB is select/combine, RMB is deselect/examine.

DangerDinosaur

Poc301 - re: a left/right click interface template - I would really appreciate seeing that as well. I've been going through some tutorials and I think I've got something working but it would be really useful to see a proper version.

Cheers.


poc301

Thanks for putting it together.  Your script was much more advanced than mine was :)

Well done!

-Bill

SMF spam blocked by CleanTalk