How Do I Manipulate Item Storage/Inventory System?

Get help using Construct 2

Post » Mon May 26, 2014 6:03 pm

Whatsup everyone,

Im looking for any examples of some kind of Item Chests used for storing in-game items.

What im trying to do is simple in terms,but is rather difficult for me to fathom.Ive gotten help in the past with this but alot of what i gotten in return from others just didnt fit what i was aiming to do.

Im trying to create a simple inventory system that allows me to drag and drop items from my Inventory Array,To my Item treasure chest for storage purposes.
My game is made for mobile so everything is going to be done using touch screens.
Im not asking anyone to make an example for me,i do understand the time it takes to mess around with Data Storage,I just need guided in the right direction,truthfully i dont understand arrays for inventory as much as i understand them for terrain generation.
Last edited by RookieDev on Wed May 28, 2014 6:52 am, edited 2 times in total.
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Post » Mon May 26, 2014 7:06 pm

Basically, what it boils down to is how to represent your items. Usually, items are a collection of values look like this {ItemID: 1, ItemName: "Small life potion", ItemPower: 25...}. Once you have your "database" of item, you can then create lists of item IDs, that could represent your inventory or chests content.
B
71
S
30
G
25
Posts: 984
Reputation: 19,503

Post » Mon May 26, 2014 8:55 pm

I used this to create my inventory. Works great now.

https://www.scirra.com/tutorials/614/ar ... -inventory
B
56
S
15
G
13
Posts: 826
Reputation: 17,645

Post » Tue May 27, 2014 7:39 pm

@Magistross @Tekniko If i wanted to use this method to make my Hotbar it would work fine.
What i dont understand is could i be able to move slots wherever i want?

I have a backpack that the player will keep all of his ingame items and it will not always be visible to the player and i would love to know if i can create slots where they are needed and if so how would i do that?
Or am i limited to how the array is drawn? I would love to have my main slots seperate from my hotbar slots.
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Post » Wed May 28, 2014 4:50 am

Anyone know how i can make my inventory appear where i want it too? Any info regarding this would help me alot
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Post » Wed May 28, 2014 6:07 pm

bump Im really trying to figure out how to move my inventory slots around.
I am not understanding how to make my slots appear where i want them to.
Im understanding everything else in the tutorial but i dont see any explanation on how to move the slots from one place to another.
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Post » Wed May 28, 2014 6:18 pm

Just add some sort of ID to where the items are, and show accordingly.

Like, if you have a list somewhere of items in possession, add:
backpack = ID 1
hotslots = ID 2
chest = ID 3

pick objects with certain ID when you need to fetch them to show them somewhere.
You could even do it with textual location IDs, such as backpack, hotslots etc
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,572

Post » Thu May 29, 2014 1:00 am

@lennaert I understand the concept behind what you are saying but its not adding up completely to me.
Is there any example that show how to show your slots where needed?

From my understanding of how the example is made,i see no real way to dictate the position of the slots.
Everything makes sense to me but this.

I really hoped to find some help within some older posts in the forums but it seems that alot of the example capX files are lacking information regarding how to put the inventory together.

I know that there aare multiple ways to make an inventory but i wish we could have a Universal Solution to making inventory systems.
Ive spent months trying to figure out how to make it work,im not a stupid individual but this definitley makes me feel like i am.
I really wish it was alot easier to make happen.
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Post » Thu May 29, 2014 7:31 am

Imagine having 2 arrays.

1 array defines the items, values, worths, extras, like:

existing_items_array (static array of items, predefined during development)

itemID (Y0) | name(X0) | color (X1)

0 | sword1 | blue
1 | sword2 | red
2 | potionheal | green
3 | gold | yellow



Then you have a dynamic array for your users inventory:

InventoryID (Y0) | ItemID (X0) | amount(X1) | location (X2)

0 | 1 | 2 | chest
1 | 2 | 5 | belt
2 | 2 | 15 | chest
3 | 3 | 100 | backpack
4 | 3 | 1000 | chest
5 | 0 | 1 | equipped


2 red swords in the chest, 5 heal potions on his belt and 15 more in the chest, 100 gold in the backpack, and 1000 more in the chest. Also carries 1 blue sword which is equipped.

Say you pick up some gold, you add it to player inventory array where X0 = 3 (gold id) and X2 = backpack (location).


Imagine opening your inventory screen, select all items from array where X2 = backpack.
Say you open a chest next to it, show all items from user inventory array where X2 = chest.

You will need a method to move objects from one location to another, this is done with a temp variable.
Like moving your gold from your backpack to your chest.

Upon selecting the gold in the backpack, store the Y0 (inventory id) after clicking it.
Then if you place it in another position, update Y0 it's X2 (location).
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,572

Post » Tue Jun 03, 2014 6:31 pm

https://www.scirra.com/tutorials/614/ar ... -inventory

@lennaert
This isnt adding up to me.I feel like im missing information.
I am using this method to create my inventory.
What im not seeing is what you are talking about within this tutorisl or any ca px ive seen.
it really shouldnt be this hard to create inventory systems.People who know nothing about coding are left
in the dark when it comes to arrays.I just need to figure out how to make my slots appear where I want them to.This Is maddness that I have spent over 2 months trying to get it down and I can honestly say that this is the only thing that stand between me and actually selling this game to the public.Could someone please try and break this down for me.Thanks guys and im sorry for being frustrated. Its not your guys fault.
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Next

Return to How do I....?

Who is online

Users browsing this forum: divsyntax, volumetv and 8 guests