How do I put a value in a unknow index of an array?

Get help using Construct 2

Post » Sun Sep 27, 2015 1:39 am

"Stop" works perfectly with the System For events. It doesn't work with the Array For events.
ImageImageImage
B
71
S
21
G
221
Posts: 3,649
Reputation: 124,227

Post » Sun Sep 27, 2015 4:02 am

Thanks for that note @blackhornet
B
23
S
4
G
2
Posts: 364
Reputation: 2,392

Post » Sun Sep 27, 2015 10:13 am

pj4ever wrote:.. the inventory could have any width, e.g.: a bag contain 10 spaces but i wanna make it bigger, than i buy a new one with 20 spaces..


I think ....you know how to solve this..but just in case...

..Add Variable "Bag(max_slots)"=10
................and then compare.....if Variable<Array.Width....then.....Push item in the bag

..and when you "buy a new bigger bag"...set Variable to 20...


EDIT:
Sorry guys...my mistake (lapsus clavis :) )
obviously ..should be:

................and then compare.....if Variable>Array.Width....then.....Push item in the bag
Last edited by korbaach on Sun Sep 27, 2015 4:14 pm, edited 1 time in total.
Image
B
64
S
23
G
7
Posts: 1,482
Reputation: 10,825

Post » Sun Sep 27, 2015 10:23 am

PhoenixNightly wrote:You can try this
Image

You a variable to make when it set within the loop so it won't keep setting.


This is a loop breaker! Thank you for the tip! It's actually working but the "insert", as name suggest, still add more rooms in the array. It's possible to delete the last index but is not was i looking for. I think i gonna keep working on your break loop solution! Thanks!


korbaach wrote:
pj4ever wrote:.. the inventory could have any width, e.g.: a bag contain 10 spaces but i wanna make it bigger, than i buy a new one with 20 spaces..


I think ....you know how to solve this..but just in case...

..Add Variable "Bag(max_slots)"=10
................and then compare.....if Variable<Array.Width....then.....Push item in the bag

..and when you "buy a new bigger bag"...set Variable to 20...



I'm afraid you're wrong becouse, i don't really know how to solve this. Anyway, thanks for the tip, i'll give a shoot! :D
B
3
Posts: 7
Reputation: 189

Post » Sun Sep 27, 2015 3:09 pm

Hmm for me it didn't. If you don't mind could I see your eventsheet snapshot for that section? Because it is suppose to only push the value at the current location
B
23
S
4
G
2
Posts: 364
Reputation: 2,392

Post » Sun Sep 27, 2015 3:32 pm

something like this...

ArrayInventory2.capx
Image
B
64
S
23
G
7
Posts: 1,482
Reputation: 10,825

Post » Sun Sep 27, 2015 3:36 pm

korbaach wrote:something like this...

ArrayInventory2.capx


You rock! Absolutely! Thank you soo much! Now it's time to do the visual stuff!
B
3
Posts: 7
Reputation: 189

Previous

Return to How do I....?

Who is online

Users browsing this forum: Held, NN81, TsubaRu and 8 guests