Newbie question but well..(SOLVED)

Started by Dualnames, Thu 29/01/2009 09:08:09

Previous topic - Next topic

Dualnames

Ok, I have this weird thing.. I'm using AGS 3.1.1 stable and I have this inventory GUI with an inventory window.
Normally when you right-click having an inventory item I have it get deselected (player.ActiveInventory=null;)

When I right-click having an inventory as cursor, over the inventory window, the interact/look action occurs, which I don't want it to happen. I have handle_inventory clicks option set to false.. I've tried to put a code on mouse click section but it just won't run.

Any ideas where I should put something like this to have it work? I've placed on a top of a mouse_click section but it refuses to work..

Code: ags

if (button==eMouseRightClick) {
if (gInventory.Visible==true) {
if (player.ActiveInventory!=null) {
InventoryItem*greif=InventoryItem.GetAtScreen(mouse.x,mouse.y);
if (greif!=null) {
Display("Got it");
return;
}
}
}
}
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)

OneDollar

If you right-click on an inventory item I think it calls the event with eMouseRightInvClick, (or equivalent). Sorry, don't have AGS or the manual to check at the moment.

And stop using those returns ;D

Dualnames

#2
Yeah, well, problem is that with emouserightinv it doesn't cause I have handle mouse click as false.

EDIT: I used a workaround..so thanks anyway.
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)

Khris

If you set inv click handling to false (why, if you want to tell AGS what to do after LeftInv/RightInv?), the clicks get sent to the GUI instead (only if the InvWindow is not-clickable).

You can then handle clicks like this:
Code: ags
function gGui1_OnClick(GUI *theGui, MouseButton button) {
  InventoryWindow1.Clickable = true;
  InventoryItem*i = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
  InventoryWindow1.Clickable = false;   // reset to false, so clicks get sent to the GUI!
  if (i == null) return;
  String c;
  if (button == eMouseLeft) c = "Left";
  if (button == eMouseRight) c = "Right";
  Display(String.Format("%s-click on item No. %d.", c, i.ID));
}

But, again: why would you turn that option off?

And using return seems to have become some kind of obsession for you, hasn't it... :=

Dualnames

Yeah, and I'm using it in a wrong way.. I'll try and quit it. ;D

Thanks for answering Khris.. I did a workaround but it's always nice to be aware of more stuff.
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)

SMF spam blocked by CleanTalk