- Joined
- Apr 15, 2020
- Messages
- 91
- Reaction score
- 36
- First Language
- English
- Primarily Uses
- RMMV
I have some code in a custom plugin where I place a bunch of arrays in $gameVariables but my code seems to replace all of the variables with the last array instead of placing them in sequentially.
Pseudo code:
-make a temp array with a bunch of 0's in it
-make a variable (intVariableID) with the first $gameVariable ID
-change a few items in the temp array
-place the temp array int the first $gameVariable with ID (intVariableID)
-change (intVariableID) to be the 2nd $gameVariable ID
-change a few items in the temp array
-place the temp array in the second $gameVariable with new ID (intVariableID)
I initially did this with a for ... loop, but all the variables were populated with the last array only. So I modified the code as per below, but still only the last array populates in all of the variables.
Any help would be appreciated! Actual code below.
Thanks.
Pseudo code:
-make a temp array with a bunch of 0's in it
-make a variable (intVariableID) with the first $gameVariable ID
-change a few items in the temp array
-place the temp array int the first $gameVariable with ID (intVariableID)
-change (intVariableID) to be the 2nd $gameVariable ID
-change a few items in the temp array
-place the temp array in the second $gameVariable with new ID (intVariableID)
I initially did this with a for ... loop, but all the variables were populated with the last array only. So I modified the code as per below, but still only the last array populates in all of the variables.
Any help would be appreciated! Actual code below.
Thanks.
JavaScript:
funInitializeBookshelf = function(){
var arrTempStorageArray = [];
var intBookShelfStorageVariableID;
/*:
* Array Index
0 = intTargetSkillID
1 = intTargetIntroComplete
2 = intTargetIntermediateComplete
3 = intTargetAdvancedComplete
4 = intTargetIntroSessions
5 = intTargetIntermediateSessions
6 = intTargetAdvancedSessions
7 = intTargetIntroShow
8 = intTargetIntermediateShow
9 = intTargetAdvancedShow
10 = intTargetTopicShow
11 = Reward Screen
*
*/
arrTempStorageArray[0] = 0;
arrTempStorageArray[1] = 0;
arrTempStorageArray[2] = 0;
arrTempStorageArray[3] = 0;
arrTempStorageArray[4] = 0;
arrTempStorageArray[5] = 0;
arrTempStorageArray[6] = 0;
arrTempStorageArray[7] = 0;
arrTempStorageArray[8] = 0;
arrTempStorageArray[9] = 0;
arrTempStorageArray[10] = 0;
arrTempStorageArray[11] = 0;
// "enchantment":
intBookShelfStorageVariableID = 591;
arrTempStorageArray[0] = 28; //intTargetSkillID
arrTempStorageArray[7] = 1;//intro Show
arrTempStorageArray[8] = 1;//intermediate Show
arrTempStorageArray[9] = 1;//advanced Show
$gameVariables.setValue(intBookShelfStorageVariableID,arrTempStorageArray);
// "magic":
intBookShelfStorageVariableID = 592;
arrTempStorageArray[0] = 28; //intTargetSkillID
arrTempStorageArray[7] = 1;//intro Show
arrTempStorageArray[8] = 1;//intermediate Show
arrTempStorageArray[9] = 1;//advanced Show
$gameVariables.setValue(intBookShelfStorageVariableID,arrTempStorageArray);
// "social":
intBookShelfStorageVariableID = 593;
arrTempStorageArray[0] = 20; //intTargetSkillID
arrTempStorageArray[7] = 1;//intro Show
arrTempStorageArray[8] = 1;//intermediate Show
arrTempStorageArray[9] = 1;//advanced Show
$gameVariables.setValue(intBookShelfStorageVariableID,arrTempStorageArray);
// "divination":
intBookShelfStorageVariableID = 594;
arrTempStorageArray[0] = 23; //intTargetSkillID
arrTempStorageArray[7] = 1;//intro Show
arrTempStorageArray[8] = 1;//intermediate Show
arrTempStorageArray[9] = 1;//advanced Show
$gameVariables.setValue(intBookShelfStorageVariableID,arrTempStorageArray);
// "alchemy":
intBookShelfStorageVariableID = 595;
arrTempStorageArray[0] = 21; //intTargetSkillID
arrTempStorageArray[7] = 1;//intro Show
arrTempStorageArray[8] = 1;//intermediate Show
arrTempStorageArray[9] = 1;//advanced Show
$gameVariables.setValue(intBookShelfStorageVariableID,arrTempStorageArray);
};