Which cursor mode activates inventory items in GUI? *RESOLVED*

Started by poc301, Fri 20/03/2009 15:30:59

Previous topic - Next topic

poc301

I have looked through a LOT of messages on here, trying to find out what my problem is on my custom inventory GUI.

I have a button called "Use".

When clicked, I want this use button to change cursor modes to whatever mode will allow me to Use, Activate, etc, the inventory item's "Interact Inventory Item" code...

Its driving me nuts..  I've tried the interact mode, use inventory mode, etc, etc..  Nothing works..

Any advice?

Thanks,

Bill

magintz

Not sure if it will work but have you made sure that if you're using a custom inventory GUI that you've enabled the option ot handle inventory clicks in script rather than default, and that inventory clicks are processed within the global scripts on_mouse_click section such as:

Code: ags

function on_mouse_click(MouseButton button) // called when a mouse button is clicked. button is either LEFT or RIGHT
{
if(button == eMouseLeftInv) // Left mouse button clicked within inventory
    {
      // Do something
    }
}


I'm a bit rushed for time so can't explain much more but hope this helps.
When I was a little kid we had a sand box. It was a quicksand box. I was an only child... eventually.

OneDollar

Edit:magintz posted while I was typing, but I'll add my answer anyway...

The default handling of the inventory GUI object means that clicking on an inventory item while the mouse is set to the 'Interact' option doesn't call the 'Interact inventory item' event, but just makes the clicked inventory item the active inventory item and changes the mouse cursor mode to eModeUseInv. This is because 99% of the time you don't actually want to use the item, you want to take it out of the inventory to use with something else.

To override this default handling you need to go into the General Settings and set the 'Handle inventory clicks in script' option to true. Then you need to edit the on_mouse_click function in the global script, adding extra conditionals for when button ==  eMouseLeftInv (for left clicking on an inventory item) and button == eMouseRightInv (for right clicking). Then you need to code your own interactions.

An alternative method (without changing the default inventory handling) is to create a new mouse cursor, (or use, say, Usermode1) and make you GUI button change the mouse cursor to this mode. Then in the inventory item events create a function for 'Other click on inventory item' and do something like
Code: ags

function iKey_OtherClick()
{
  if (mouse.Mode == eModeUsermode1) {
    Display("I'm using the object");
  }
}

poc301

Thanks to both of you.

The usermode2 option was perfect for what I am doing (the game is complete and in beta, so this is the less complicated work-in for it). 

It works great!

Thanks again,

Bill

SMF spam blocked by CleanTalk