- Joined
- Jun 16, 2014
- Messages
- 260
- Reaction score
- 71
- Primarily Uses
I'm using arrays to create a random chest generation system. The idea is that the base array looks like this:
So, this is called first, and sets whether or not they've been opened, and their location. Each chest has 5 possible spawn points. Then, each zone is assigned a copy of this array, so that each one has its own.. treasure map, so to speak. This is the blank map. After this, we generate the map further:

Here, we set a trash variable to 0, and 5 important variables to a random number 1-5. Then, we check what number the trash variable is at. For 0, we do this:
So, this assigns the zone attached to variable 46 a set of locations for its chests, and ensures that the switches are off for it. Then, we add 1 to the trash var, and repeat this loop for the other zones. But, there's an issue.
For whatever reason, the above snippet is completely and utterly assigning itself overtime duty and attaching itself to everything in sight.

The first image is a check done right after the first bit, zeroing-out the arrays, making them blank.
The second image is after the code snippet above. I've tried removing any references to other variables in that event, but regardless it just.. does this. I can't for the life of me fathom why it's assigning itself to these variables.
Code:
// Create Array
tmpArr = [false, 6, false, 6, false, 6, false, 6, false, 6, false, 6, false, 6];
// chest 1, loc, 2, loc, 3, loc, 4, loc, 5, loc, Ext1, loc, Ext2, loc
// Save Array to Game Variables
$gameVariables.setValue(46, tmpArr);
$gameVariables.setValue(47, tmpArr);
$gameVariables.setValue(48, tmpArr);
$gameVariables.setValue(49, tmpArr);
$gameVariables.setValue(50, tmpArr);
// what in the hell is this wizardry

Here, we set a trash variable to 0, and 5 important variables to a random number 1-5. Then, we check what number the trash variable is at. For 0, we do this:
Code:
array = $gameVariables.value(46);
array[0] = $gameSwitches.value(56);
array[2] = $gameSwitches.value(57);
array[4] = $gameSwitches.value(58);
array[6] = $gameSwitches.value(59);
array[8] = $gameSwitches.value(60);
array[10] = $gameSwitches.value(61);
array[12] = $gameSwitches.value(62);
// this is black magic
// this is called to save to array
array = $gameVariables.value(46);
array[1] = $gameVariables.value(51);
array[3] = $gameVariables.value(52);
array[5] = $gameVariables.value(53);
array[7] = $gameVariables.value(54);
array[9] = $gameVariables.value(55);
array[11] = $gameVariables.value(56);
array[13] = $gameVariables.value(57);
// saves loc, split because limited
// length allowed in this window
For whatever reason, the above snippet is completely and utterly assigning itself overtime duty and attaching itself to everything in sight.

The first image is a check done right after the first bit, zeroing-out the arrays, making them blank.
The second image is after the code snippet above. I've tried removing any references to other variables in that event, but regardless it just.. does this. I can't for the life of me fathom why it's assigning itself to these variables.




