Problem with mouse. Mode [SOLVED]

Started by Shaden, Wed 07/11/2007 19:49:47

Previous topic - Next topic

Shaden

Hi, I'm new to this, but I'm doing great except for this.

The other day I ended making the inventory. It's part of a onYposition GUI. Left click selects item, right looks. The issue is that when i left click on an item, it turns the cursor to the item just for a second, and then turns to walkto.

if (EventType==eEventGUIMouseDown)
  {
    if ((data == 0) && (Mouse.IsButtonDown(eMouseLeft)))
      {
        InventoryItem *item = InventoryItem.GetAtscreenXY(mouse.x, Mouse.y);
        Character[PC].ActiveInventory=item;
        Mouse. Mode=eModeUseinv;
      }
  }

The item is selected, and I used displays on different parts, and no problem appeared.The right click script is in another function, and works fine, so it has nothing to do with this problem

Candall

Quote from: Shaden on Wed 07/11/2007 19:49:47

    if ((data == 0) && (Mouse.IsButtonDown(eMouseLeft)))


That's the problem.  You're telling the game to only use the inventory cursor while the button is down.  You may want to consult the documentation and move your inventory handling code to the function on_mouse_click.

Khris

#2
Edit:
Candall: I don't think so. The code below that line is executed and changes the active item permanently, not just while the button's down. Unless of course there's more code that cancels it in eEventMouseUp or something like that.


1. You can handle clicks on inventory items in on_mouse_click, using eMouseLeftInv and eMouseRightInv. You have to active it in General settings (check "Handle inventory clicks in script").

2. Setting player.ActiveInventory to an InvItem automatically sets the mouse.Mode to eModeUseinv.

3. With your code, if you click the mouse above GUI 0 but outside an InvItem, the ActiveInventory will get set to null. And I believe setting the mouse.Mode to eModeUseinv is futile in this case, i.e. it won't do anything.

4. Mind the capitalization. Its mouse.Mode and character[].

5. Instead of using character[PC], you can simply use player.

Points 3&4 probably contain the solution to your problem.
Anyway, I'd use
Code: ags
// on_mouse_click
  ...
  else if (button==eModeLeftInv) {
    player.ActiveInventory=inventory[game.inv_activated];
  }
  else if (button==eModeRightInv) {
    inventory[game.inv_activated].RunInteraction(eModeLook);
  }
  ...

Shaden


monkey0506

Quote from: KhrisMUC on Wed 07/11/2007 20:34:59Its mouse.Mode

Actually everything except mouse.x and mouse.y are technically implemented as static so the Mouse.Mode syntax is technically correct. AFAIK the only reason the x/y properties are implemented as non-static members is due to backward compatibility (also the reason why they are lowercase properties).

However, since the x/y properties aren't available statically, it probably is best to get in the habit of just using the instance mouse instead of accessing the struct directly. ;)

Dualnames

Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Shaden

It worked, so now I have no problems at all with the GUIs and the cursors.
I didn't posted before cause usually I can't use internet everyday. Thanks again.

SMF spam blocked by CleanTalk