Using two inventories in a puzzle

Started by rongel, Wed 27/08/2014 11:09:42

Previous topic - Next topic

rongel

Hi!

So my situation is this: I have a puzzle room that uses two inventories. First is the normal one, and the second is room specific (it shows only in this puzzle room). Both appear in the same view at the same time. I read upon the subject and managed to create a dummy character (cDummy) and I made a new inventory for him. I can make items appear in the new inventory by giving them to my dummy character, but I can't select or use them! So what is the best way to proceed? I read that it shouldn't be necessary to switch player character, that you could switch inventory with a script.

I found this piece of script that should help, but I cant seem to get it working:

Code: ags
// eMouseLeftInv
 
  if (GUIControl.GetAtScreenXY(mouse.x, mouse.y) == invSecondaryInv) {
    ActiveItem = inventory[game.inv_activated];
    mouse.Mode = eModeUsermode1;
    mouse.ChangeModeGraphic(eModeUsermode1, ActiveItem.Graphic);
  }


Is "invSecondaryInv" the name of my secondary Inventory Window? And what "ActiveItem" means? I seem to get an error code always there... This might be a bit too advanced for a beginner like me, but I must know if it's possible or not before I continue. Thanks!


Dreams in the Witch House on Steam & GOG

Khris

It is possible in principle, but you can't set an item as active that isn't in the current player character's possession.
There are two basic workarounds:
-before the 2nd inventory's item is set active, the player character is changed.
-having the item active is only simulated by the cursor graphic (this is what the code does)

ActiveItem is an InventoryItem* pointer used to store the item selected from the 2nd inventory. You have to add this line above on_mouse_click:
Code: ags
InventoryItem *ActiveItem;

Yes, invSecondaryInv is the name of the InventoryWindow.

Slasher

#2
Hi,

Basically a player can only have 1 set of inventory items but can have mutiple Inv windows to display them.

You could do a number of options (something like this question was answered a few topics before yours).

1} Change main character (cDummy set as player)
2) Use a gui with buttons that act like inv items.

cDummy can't use default players inventory items and vice versa normally.

* Plus what others come up with for a solution.

The new inventory window can be named as you want as long as its name is referred to by that name in scripts. 

Someone named the new inv window invSecondaryInv, this would have to be the name referred to in scripts.

Active Inv means the mouse cursor has an inventory item as an image.

EDIT:  Khris jumped over me (laugh)



rongel

#3
Thanks for the replies!

Well still didn't get it working. I'm using the "Lightweight BASS Template", so if I'm right, I need to add this
Code: ags
InventoryItem *ActiveItem;
to TwoClickHandler script? The basic GlobalScript tells that all mouse clicks are handled there. I tried it but it still gave me the same error.

Other thing is that where do I need to write the actual code for the second inventory? In the puzzle room's script, Global script, or to the TwoClickHandler?

EDIT: I put both codes to the TwoClickHandler script, and I don't get the error anymore, I still can't move my second inventory object (or get the mouse cursor to change).
Dreams in the Witch House on Steam & GOG

Khris

on_mouse_click will only be called with button == eMouseLeftInv if you activate custom inventory handling in the General settings. Which means you also have to script standard inventory handling yourself.

Stupot

I know it's possible to send items to a specific slot number in your inventory. But is it possible to tell a GUI to only display specific slots?  If so, would it not be possible to have two GUIs displaying different slots of one inventory, giving the effect of two inventories, so on the one side you have slots 0-10 or whatever for normal items, and then, when needed, the other GUI pops up but only displaying room specific items which you would store in slots 90-99, for example. If that would work then you would never need to swap characters.

Crimson Wizard

Quote from: Stupot+ on Sun 07/09/2014 15:12:41
I know it's possible to send items to a specific slot number in your inventory. But is it possible to tell a GUI to only display specific slots?  If so, would it not be possible to have two GUIs displaying different slots of one inventory, giving the effect of two inventories, so on the one side you have slots 0-10 or whatever for normal items, and then, when needed, the other GUI pops up but only displaying room specific items which you would store in slots 90-99, for example. If that would work then you would never need to swap characters.

I think you may do this with InventoryWindow.TopItem. The row count and items per row is calculated automatically though, so only adjusting inventory window will change these properties.

SMF spam blocked by CleanTalk