Help with Array and Inventory

Get help using Construct 2

Post » Sat Mar 02, 2013 11:53 am

I want to make a simple inventory system:

- 3 inventory slots, each slot can have one item.
- if player used item, that slot will be empty.
- next time player acquire a new item, the item will be put into the first empty slot.

I know array will do the job, but it would be so helpful if someone can give me a hint:)
B
14
S
2
G
1
Posts: 94
Reputation: 2,089

Post » Sat Mar 02, 2013 2:59 pm

Go check out the Arrays for beginners tutorial , making this wouldn't be too hard , you just need to check if there is a 0 in the array and remplace the zero by the ID of an item in a for every elements loop ...


I'll make you an example when I get homeWhiteclaws2013-03-02 15:01:39
B
34
S
16
G
16
Posts: 2,222
Reputation: 16,564

Post » Sat Mar 02, 2013 4:26 pm

Thanks Whiteclaws! Won't the loop replace every cell of 0? but I'm looking forward to your example:)
B
14
S
2
G
1
Posts: 94
Reputation: 2,089

Post » Sat Mar 02, 2013 4:39 pm

There's where a variable enters , the loop will only be triggered if a variable is equal to 0 , and the variable will turn 1 when the item is added successfully !
B
34
S
16
G
16
Posts: 2,222
Reputation: 16,564

Post » Sat Mar 02, 2013 5:09 pm

Here We Go !

P.S: That's the first time I do something like this :) . Arrays , I'm starting to love-em !
B
34
S
16
G
16
Posts: 2,222
Reputation: 16,564

Post » Sat Mar 02, 2013 5:21 pm

Wouldn't a simple "Trigger once while true" prevent it from changing every instance?
B
6
S
1
Posts: 67
Reputation: 986

Post » Sat Mar 02, 2013 8:42 pm

Well , Yes , but I just wanted to show that the usage of variable with arrays is possible
(Screw this , I completely forgot the "Trigger once while true" :P )
B
34
S
16
G
16
Posts: 2,222
Reputation: 16,564

Post » Sun Mar 03, 2013 7:08 pm

Thanks for the example and hint!
B
14
S
2
G
1
Posts: 94
Reputation: 2,089


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 15 guests