How do I move data from one index in an array to another?

Get help using Construct 2

Post » Thu Dec 10, 2015 3:08 pm

Hi,
I made an inventory for my game and I just tried to make it possible to move objects from one slot in an array to another by clicking on the slots. I tried to let the game put the coordinates of the first click on a slot in a global variable and then do the same with the second one. After the two clicks are done, the game sets two booleans to true (first one set = true, second one set = true). Then when these are true the game sets the value on the index of the second click to the value from the index of the the first click and then deletes the values from the first click. The array is 3 dimensional and one the X axis it stores the item ID, on the Y axis it stores the item count and on the Z axis it can store even more items (every index on the Z axis is the storage of another inventory or chest).
I can't find a way to get this working and also I think that there could be an easier way. Does anyone have an idea of doing that?
Thanks! :)
Image
B
5
S
3
Posts: 193
Reputation: 1,063

Post » Thu Dec 10, 2015 9:48 pm

Anyone?
Image
B
5
S
3
Posts: 193
Reputation: 1,063

Post » Fri Dec 11, 2015 2:52 pm

:(
Image
B
5
S
3
Posts: 193
Reputation: 1,063

Post » Fri Dec 11, 2015 5:11 pm

B
66
S
24
G
7
Posts: 1,514
Reputation: 11,039

Post » Fri Dec 11, 2015 6:39 pm

@korbaach

ahh that's a nice file. I feel like I already know more about arrays. +1
B
46
S
16
G
77
Posts: 2,155
Reputation: 45,823

Post » Fri Dec 11, 2015 10:02 pm

Thank you @korbaach,
I'll try that right now! :)
Thanks again
Image
B
5
S
3
Posts: 193
Reputation: 1,063

Post » Sat Dec 12, 2015 11:47 am

@korbaach,
Does your method also work with 3 dimensional arrays? Because as I said I want to be able to move an object from for example 2,0,0 (From inventory because Z is 0) to 5,0,1 (From the first chest because Z is 1). But I think the Array.IndexOf expression doesn't work with 3 dimensional arrays.
Thanks!
Image
B
5
S
3
Posts: 193
Reputation: 1,063

Post » Sat Dec 12, 2015 2:15 pm

@aquadijoib you can always find IndexOf "#"

ArraySwap3D.capx
B
66
S
24
G
7
Posts: 1,514
Reputation: 11,039

Post » Sat Dec 12, 2015 5:00 pm

@korbaach,
Thank you so much for all your examples. But I don't know how to move an item from one chest to another or from the inventory to a chest.
Thanks again!!! :D
Image
B
5
S
3
Posts: 193
Reputation: 1,063

Post » Tue Dec 15, 2015 5:18 pm

@korbaach,
Can you help me one more time please? :)
I'm still not able to make it possible to move from chest to chest or from chest to inventory. I mean from one Z index (Storage) to another.
Thanks again!
Image
B
5
S
3
Posts: 193
Reputation: 1,063

Next

Return to How do I....?

Who is online

Users browsing this forum: batto, bclikesyou, Lancifer, R0J0hound and 21 guests