Is secondary inventory easiest way to do this?

Started by Enchart, Mon 06/07/2015 19:10:23

Previous topic - Next topic

Enchart

Thing is that memory circuits are big part of my games theme. The main character stumbles upon them during his jorney. Later on his options and lines depend on what memory circuits are active. I need one extra GUI-window for memory circuits.

So, I have GUI scripting problem that is beoynd my limits for now. I think I need multiple inventories for my main character to make it work. I've dug couple of threads that discussed about the topic and having (invisible) secondary character is the way multiple inventories have been made. Before I venture into world of GUI scripting I'd like to ask couple of things:

Is it possible to make the two inventories graphically different?
Can items be traded between inventories and is there a way to limit which items can be added to secondary inventory?

If these conditions fill up I should try an invisible second character.

Cassiebsg

#1
Yes, you can do all that you are asking for. ;)

EDIT:
I've done something similar to what you wish for one of my games (in production), where the character has his "normal" inventory that are basically 2 pockets and 2 hands, and then he can extend his inventory using a backpack. I've divided my items in 3 categories: small, medium and big. And any object that is big can only be carried on his hands, never on the backpack... and his pockets can only carry small objects.
The "main" inventory is using a blue background and the "secondary" a red one. And then I just added the possibility of "moving" stuff from the main inventory to the backpack and vise-versa (I think).

So yeah, you can pretty much do anything you can set your mind to. :-D
There are those who believe that life here began out there...

Crimson Wizard

#2
Quote from: Enchart on Mon 06/07/2015 19:10:23
Is it possible to make the two inventories graphically different?
Sure, every gui can be customized differently.

Quote from: Enchart on Mon 06/07/2015 19:10:23
Can items be traded between inventories and is there a way to limit which items can be added to secondary inventory?
Trading items in your case would be as simple as removing an item from character A and giving it to character B. Inventory windows should update automatically.

As for dividing items, I think it may have sense to add a custom property to inventory items which define whether its item of type A, or type B. When the item is picked, you check this property value for the new item, and give item to corresponding character.

You may even write a helper function to simplify things for yourself; quick sample follows:
Code: ags

void GiveItemToPlayer(InventoryItem * item)
{
    if (item.GetProperty("InventoryType") == 1)
        cCharacterA.AddInventory(item);
    else
        cCharacterB.AddInventory(item);
}

Enchart

Quote from: Cassiebsg on Mon 06/07/2015 19:15:47
Yes, you can do all that you are asking for. ;)

EDIT:
I've done something similar to what you wish for one of my games (in production), where the character has his "normal" inventory that are basically 2 pockets and 2 hands, and then he can extend his inventory using a backpack. I've divided my items in 3 categories: small, medium and big. And any object that is big can only be carried on his hands, never on the backpack... and his pockets can only carry small objects.

Pretty neat. How does that work? I mean do you have multiple pick up options or do the items go to hands by default?

Quote from: Cassiebsg on Mon 06/07/2015 19:15:47
The "main" inventory is using a blue background and the "secondary" a red one. And then I just added the possibility of "moving" stuff from the main inventory to the backpack and vise-versa (I think).

So yeah, you can pretty much do anything you can set your mind to. :-D

I'm having Iconbar (similiar to one in default game) with icons for both inventories, inventory and memory. When the iconbar appears cursor goes to default pointer mode. I was planning that you could move stuff to appropriate inventory, but I don't know if it's possible because cursor goes to pointer mode. Do you have somekind of button in inventory for "moving" the items or how did you manage to do it?

Thanks for the response, both of you.. I'm starting to have a clue on this :smiley:

Cassiebsg

Hey.

Basically it's a IF/ELSE IF/.../ELSE IF/ELSE type of condition, maybe there's a better way to do it, but I'm new to coding. (roll)

Like CW said, I created a custom property for each inventory item, so when the played picks it up, it checks what it is.
And yes, it goes by default to right hand, then left hand, then right pocket, then left pocket, then backpack (if the player has it, otherwise it'll say it can't carry anything else).
As for moving stuff from one inventory to the other, I just used the backpack icon on the inventory. One just needs to pickup the item from inventory and drop it on the backpack to move it there. To get it from the backpack you open the backpack and just grab it (you need to have 1 free hand to do this).

Hope this is enough to get you on track. :)
There are those who believe that life here began out there...

Enchart

Quick question here:

I'm trying to make this:

Code: ags

function iMemCrct1_OtherClick()
{
if (mouse.Mode == eModeMemorycur)
{
  Display("Memory circuit is plugged");
  cInv.LoseInventory(iMemCrct1);
  cMem.AddInventory(iMemCrct1);
  mouse.Mode = eModeInteract;
	mouse.UseModeGraphic(eModeInteract);
}
}


..into this:

Code: ags

function InventoryItem_OtherClick()
{
  if (mouse.Mode == eModeMemorycur)
  {
    if (InventoryItem == iMemCrct1)
  {
  Display("Memory circuit is plugged");
  cInv.LoseInventory(iMemCrct1);
  cMem.AddInventory(iMemCrct1);
  mouse.Mode = eModeInteract;
	mouse.UseModeGraphic(eModeInteract);
  }
}
}


First code is working but instead of making function for every item I'm trying to make one long function of which items can be moved into memory inventory. cMem is the character whose inventory is the memory inventory and cInv is the character who has the basic inventory. 5th line of second code is the one I'm having problems with.

SMF spam blocked by CleanTalk