How to change/access the value of an array variable on a specific index?

Hello,

I have an array variable which is integer type. In it i have 5 index stats range from index 0 to index 4. Index 0 for example has a value of 600. I want to be able to change specific values lets say i want to change only index 1 with value 700 to 500 and the rest should stay the same. How can i achieve this ? thx

Here is how i try to do it but im not sure if this changes all the different index values as well:

When i print string this i get one 500 value out of this. So it seems it works but idk is this awso index 0 that i want to change @500 or did it change some other ones as well or maybe even all?

Hey @catz111!

You should be able to use the “Set Array Elem” node for this!

You pass in the array and an index, along with the new element for that index, and it will overwrite the previous entry without affecting the rest of the array! :slight_smile:

As far as simply acquiring the element from a specified index, what you did here is exactly correct! :slight_smile:
image

2 Likes

Hi,

Yep i found the problem. It took me 2 days till i now finally manage to understand how this works and i fixed the whole thing. As i awso now see i was really close.

Here now how i managed to get the info from each index so my crafting system can work properly:

So i had to use for each index this “get” nodes 5 of them or else some code elsewhere break apart and this didn’t work. I cannot change only 1 node with 1 GET node and move on but i awso had to fill the rest 4 with default values else it wouldn’t work. Anyway now it does and i can craft/ slam some artefacts on my traps and values change accordingly. :grinning:

Here is the end result

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.