can I replace the contents of a var array and have it save the new integers?

::No previous coding experience warning:: :slight_smile:

I am trying to write a code that will grant random weapons (like a gungame, but the weapons are random). I can get this much to work with an item granter array and GetRandomInt.

The issue that I currently need help with is that I want to remove previously granted weapons so the player doesnt get the same gun more than once.

I am trying to use an int array of the same length as the item granter array (if the weapon tier = 1 and array[1] = 1 then the gun is available, grant the weapon and change the int of that index to another number so it will fail the next time it comes up.

This all works so far, until the next weapon is granted. The int that was previously changed to cause the grant weapon to fail has reverted back to its original value.

Does this make sense? Can I save the array with the changed index values, or will it always revert to the original values the next time a weapon is granted?

If you want to make your life easy, just use the Shuffle command (using { /Verse.org/Random }) on the array of weapons upon initialization and keep an index counter which you increment upon each weapons issue, then when you reach the end of the array, reset the counter to zero and re-Shuffle() the array.

1 Like