Tutorial Downloads

File Size
algorithm.png384KB
Array based inventory.capx83KB

Translations

Know another language? Translate this tutorial!

Stats

1,557 visitors
44.2K page views
1,140 translation visitors
18.8K translation page views

Array-based inventory

Favourite 59 favourites
Tutorial written by WaltanOriginally published on 7th, July 2013 - 5 revisions

Practice

First of all, create 4 objects:
1. Sprite - slot (invetory slot)
with 3 variables:
id, item, number
It will help us to work with the information.
Add second frame for this sprite to distinguish between the normal and the selected slot:
2. Sprite - item (your items)
with 1 variable:
number
3. Array - inventory (your inventory array)
Set size to (the planned number of slots (we will use 5),2)

Remember, that arrays in Construct 2 is 0-based. So if you have 5 slots width array, it will start from 0 to 4.

4. Mouse - just mouse object, huh

Add varialbles about which I wrote earlier:

Share and Copy this Tutorial

You are free to copy, distribute, transmit and adapt this work with correct attribution. Click for more info.

Comments

2
Robin Sommer 7,391 rep

Hero! I'm gonna make one right now. :D

Sunday, July 07, 2013 at 11:01:37 AM
1
Waltan 7,770 rep
Hero! I'm gonna make one right now. :D
quoted from Robin Sommer

I hope you do not get confused in my bad English %)

Sunday, July 07, 2013 at 11:04:20 AM
1
Lordshiva1948 37.0k rep

Nice one I will start making mine soon

Sunday, July 07, 2013 at 12:06:58 PM
1
Waltan 7,770 rep

I just found a little bug in my algorithm with tx variable. (3rd page)
Check it if you got problems with it.

Sunday, July 07, 2013 at 1:39:38 PM
0
sosensible 9,446 rep

dont need it yet but this will defenetily come in handy

Sunday, July 07, 2013 at 3:22:23 PM
1
SergioRM 6,776 rep

This is really good.
Thank you!

Sunday, July 07, 2013 at 10:25:33 PM
1
AbelaNET 13.6k rep

Thanks for sharing

Monday, July 08, 2013 at 10:27:11 PM
1
Zebra 1,307 rep

Thanks you so much for this!! (and sorry for my englisch)
I followed your tutorial, but I don't know how to add another item in the inventory.
When I try to do your example of "inventory efficiency", new items replace the ones that are already in the inventory, I can't place them in the empty slots.

Friday, July 12, 2013 at 11:26:56 AM
2
Waltan 7,770 rep
Thanks you so much for this!! (and sorry for my englisch)
I followed your tutorial, but I don't know how to add another item in the inventory.
When I try to do your example of "inventory efficiency", new items replace the ones that are already in the inventory, I can't place them in the empty slots.
quoted from Zebra

Here you go. goo.gl/A16f8 Download this .capx of "inventory efficiency". I made comments for you. All you need is in "Control system" group.

Friday, July 12, 2013 at 12:32:35 PM
1
Joannesalfa 24.8k rep

This is really efficient, actually I'm wondering how to substract an item when it's used?

I would like to know if you improve this when an item is used, it should be destroyed when value is 0 or -1

Saturday, July 13, 2013 at 8:36:34 AM
2
Waltan 7,770 rep
This is really efficient, actually I'm wondering how to substract an item when it's used?

I would like to know if you improve this when an item is used, it should be destroyed when value is 0 or -1
quoted from Joannesalfa

As I said in tutorial (end of page 3) it checks if number of this item > 0.
So, for example, if you will subtract 1 every time when you right click on slot, when value in array at this slot will = 0, you also should to erase data about item ID.

Check this .capx: goo.gl/A16f8 ("Tutorial" group)

I also updated "inventory efficiency" example. You can now download .capx through it.

Saturday, July 13, 2013 at 12:28:14 PM
1
Altheon 1,041 rep

Hi Vladoss! your tutorial was great and this is the best inventory implementention we've seen here, but i would like to know how to expand with 5 equipment slots, its the missing piece that i cant wrap my head around on how to do on your inventory.
Can you help me?

Monday, October 14, 2013 at 12:44:22 AM
1
ffman22 4,655 rep

the reload button dont work?

Thursday, April 03, 2014 at 8:22:27 PM
1
Waltan 7,770 rep
Hi Vladoss! your tutorial was great and this is the best inventory implementention we've seen here, but i would like to know how to expand with 5 equipment slots, its the missing piece that i cant wrap my head around on how to do on your inventory.
Can you help me?
quoted from ffman22]
the reload button dont work?
[/quote]

Works for me.

[quote=Altheon

Can you tell me what you want in details?
Sorry for the long aswer.

Friday, April 18, 2014 at 5:49:28 PM
1
RookieDev 6,328 rep

Vladoss, 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?

Tuesday, May 27, 2014 at 10:11:59 AM

Leave a comment

Everyone is welcome to leave their thoughts! Register a new account or login.