inventory problem

Started by Mordalles, Sat 14/01/2006 22:37:18

Previous topic - Next topic

Mordalles

hi. im having problems with an inventory problem.

in my game i use a single cursor. right click is for USE and left click is for LOOK.
this works fine in the game area, but doesnt do anything in the inventory itself.

my inventory is at the bottom of the screen (always visible.)

the "handle inventory clicks in scipt" is enabled, and i have the following code:

Code: ags

function on_mouse_click(MouseButton button) {
  // called when a mouse button is clicked. button is either LEFT or RIGHT
  if (IsGamePaused() == 1) 
  {
    // Game is paused, so do nothing (ie. don't allow mouse click)
  }
  else if (button == eMouseLeftInv)
  {
    ProcessClick(mouse.x,mouse.y, eModeLookat);
  }
  else if (button == eMouseRightInv) 
  {
    ProcessClick(mouse.x,mouse.y, eModeInteract);
  } 
  else if (button ==  eMouseLeft) 
    {
      if (GetLocationType(mouse.x,mouse.y) != eLocationNothing)
      {
        ProcessClick(mouse.x,mouse.y, eModeLookat);
      }
      else
      {
        ProcessClick(mouse.x, mouse.y, eModeWalkto);
      }  
    }
  else // right-click, so cycle cursor
    {   
				if (GetLocationType(mouse.x,mouse.y) != eLocationNothing)
				{
					ProcessClick(mouse.x,mouse.y, eModeInteract);
				}
				else
				{
					ProcessClick(mouse.x, mouse.y, eModeWalkto);
				} 
			
    }


ive searched for help here, and somebody had the same problem, and radiant told that person to do something in the on_event(). however, i have no idea what to put in there.

also, now that i am on the topic, how would i deselect an item. say my char clicks on the inventory item and it becomes active, how do i go back to normal state where item is not selected anymore.

i really need help with this, since im using this in the mags, and theres only a few days left. haha.

creator of Duty and Beyond

Ashen

I think the problem lies here:
Quote from: The Manual: ProcessClickNOTE: This function ignores all interfaces and acts as though the point is directly visible. In other words, if the co-ordinates you pass happen to lie on a button on an interface, what actually happens will be as if the user clicked behind the interface onto the actual screen.

So, rather than using ProcessClick, you need to get the Inventory Item under the mouse (if there is one), then run the interaction, like this:
Code: ags

 else if (button == eMouseLeftInv)
  {
    InventoryItem *theItem = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
    if (theItem!= null) theItem.RunInteraction(eModeLookat);
  }
  else if (button == eMouseRightInv)
  {
    InventoryItem *theItem = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
    if (theItem!= null) theItem.RunInteraction(eModeInteract);
  } 
I know what you're thinking ... Don't think that.

Mordalles

thx, ashen, im going to do that right now!

creator of Duty and Beyond

SMF spam blocked by CleanTalk