Script snippet please help .
Javascript/Plugin SupportOh thank you for pointing that out. I didn't even notice that, not sure how the f### i did that... :aswt2:
I went ahead and corrected the mistake and tested it, for some reason it still returns undesired values to NID.
Results:
Now it only dumps value of 95 into 96. Instead of just "95" the actual ID. I'm trying to get it to report back the actual ID of the said lowest value.
In this case "Joe's Score" or variable 101 with 1 point
EDIT:
The mind is very good at discarding relevant information it thinks is irrelevant to you. It is the same when you read regular text, the brain scans, assumes, and discards to speed things up. The same techniques for defeating this work with programs.
1) Read the lines from right to left.
2) Read the lines from bottom to top.
3) Do something else for 20 minutes, come back, then read the thing once your brain has cleared its mental cache.
Although they use the term variableId, they really are all just indexes. This was a little confusing to read because checkVar uses i to index into it. But then again all of RPG Maker's code is a little confusing at the best of times.
Code:
const checkVar = [100, 101, 102];
let min = $gameVariables.value(checkVar[0]);
let vid = 95;
let nid = 96;
for (let i = 0; i < checkVar.length; i++) {
let va = $gameVariables.value(checkVar[i]);
if(va < min && va >= 0) {
min = va;
// vid = $gameVariables.value(checkVar[i]); // Store current value of $gameVariables.value()
vid = checkVar[i]; // Store current Index (ID) of $gameVariables.value()
// vid = i; // Store current Index (ID) of checkVar[]
}
}
$gameVariables.setValue(nid, vid);
This is my understanding of what you are asking for.
Thanks for the fast reply, I'm gonna run to the store and see if this will give the desired results once i get back
Original thread: https://forums.rpgmakerweb.com/threads/script-snippet-please-help.115201/