Using an inventory item on another inventory item?

Started by themaninthehat, Fri 11/07/2014 18:18:12

Previous topic - Next topic

themaninthehat

Hi,

I'm struggling with this, and after reading related threads in forums, manuals, etc, I'm still unsure...althoug I'm pretty sure this must have been covered somewhere...

First of all, I have the option "Override built-in inventory window click handling" set as False in General Settings. I like the way that works and it fits my needs, however, I can't see how to be able to use one inventory item on another. Currently, with that setting set as "False", it seems you are unable to click at all in the Inventory GUI for anything else appart from right-click to look at inventory item, left click to make it the active inventory.

I understand that ProcessClick ignores GUIs, so what kind of script would you need to keep that general setting but still being able to use one inventory item on another one? Do I have to modify the on_mouse_click function in the Global script?

Thank you!

Cassiebsg

I~m no expert, so if my suggestion doesn't work for you, then I'm sure a more experienced member will give you a better solution.

Go to your "inventory items", choose your item you want to interact with, click on the events buttons, then you need the last option called "Use inventory on this item". Click on it, to create an event there, and then script what you want to happen. ;)

Hope it helps.
There are those who believe that life here began out there...

Khris

Exactly; you will not need any additional scripting or settings if you keep the default setting. Everything will work as-is.
All you need is add what happens, like Cassie explained.

The way you phrased your question kinda makes no sense; you said you are able to select an inv item as active one, so how do you figure using one item on another doesn't work in general? I assume your game doesn't respond at all to the click right now, but that's simply because you haven't linked a function to the passive item's "use inv on" event; this is done in the same way as you add every other event.

And just like whenever you're dealing with "use item on x", you need to check player.ActiveInventory to find out which one was used.

themaninthehat

Thanks for your responses guys.

I'm afraid it was a bit of a dumb moment I was having. I had already scripted the event "Use inventory on this item", I should have said that, apologies for explaining my problem so badly.

In fact, it wasn't a problem as such, I had just made a very silly mistake and I couldn't see it. What I was trying to do is to open a bottle of wine. So I had my bottle opener interacting with the closed bottle, and scripted that the closed bottle item disappears and an open bottle appears in the inventory. However, instead I had written to replace the closed bottle...with another closed bottle (I know...I'm ashamed...).

I do have one issue though, which I think it's related to the way my inventory GUI handles mouse cursors. At the moment, the mouse cursor inside the inventory GUI is always stuck in the pointer, arrow mouse cursor. I'd like the active inventory item to appear as the cursor inside the inventory GUI (as it already does outside the GUI).

My best guess at how to do this is with part of the Global Script (yes I'm building on the Default game script):

Code: ags
function show_inventory_window () 
{
  gInventory.Visible = true;
  // switch to the Use cursor (to select items with)
 mouse.Mode = eModeInteract;
  // But, override the appearance to look like the arrow
 mouse.UseModeGraphic(eModePointer);
}


So can I use "mouse.UseModeGraphic" to make the mouse cursor to use the Active inventory mouse cursor whenever there is one, and use eModePointer (or any other mode) the rest of the time? How? Am I even on the right track?

Thanks!

Khris

You need the mode to remain eModeUseinv; changing the cursor graphic alone won't be enough:
Code: ags
function show_inventory_window ()
{
  gInventory.Visible = true;
  // if there's an active item, exit at this point
  if (mouse.Mode == eModeUseinv) return;
  // switch to the Use cursor (to select items with)
  mouse.Mode = eModeInteract;
  // But, override the appearance to look like the arrow
  mouse.UseModeGraphic(eModePointer);
}


Btw, as soon as you want the player to be able to interact with inventory items (for instance to drink from the open bottle), all this goes out the window since at this point you'll have to script it yourself. Unless you implement interacting by using the item on the player character.

SMF spam blocked by CleanTalk