Issue Summary — In my first game jam right now and trying to do a small little game with MZ, that mimics the old MasterMind tabletop game from ~1980. What I'm trying to do is via script in an event (instead of doing oodles of nested if statements in the event) is to, for two different sets of 4 variables, cycle through and record how many of each color code I've got. One set for the player colors & one for the hidden, goal colors. Then compare those two sets and see how many matches I've got for each color pair.
Details — I have 4 crystals that successfully cycle through 5 colors (each w/ their own variable with color codes 0-4) and switches that keep the crystals from moving whenever the room re-draws. There's also the hidden (to the player) goal series of 4 variables w/ their own randomly generated color sequence. The point of the game is to, through logic, get your color sequence to match the hidden one. This part all works, including tracking & reporting perfect matches. For testing, the goal colors are at the top.
I tried setting up the first part of the script (testing via interaction w/ the pig-butt instead of auto cycling w/ the room) but it's throwing a "SyntaxError, Unexpected token ')'" message. I hadn't written the second part, the comparing yet to test. I did check and there's no floating brackets or () so thinking it may be something not-obvious in the syntax.
Here's what I have so far, that's breaking:
var bookmark = 0;
for (var g = 5; g <=8; g++) {
bookmark = $gameVariables.value(g);
for (var i = 0; i<=4; i++) {
if (bookmark === i) {
$gameVariables.setValue(30+i,++);
$gameMessage.add($gameVariables(30+i));
}
}
}
The goal colors are stored in variables 5-8, player colors in 10-13.
I've got the counter variables for recording # of each color in 24-28 for the goal, and 30-34 for the player. Trying for each color for goal & player, to count how many of each color there are. So far the above is only testing the player bit, if I get it working I'd add a second identical bit for the goal series variables #'s 24-28.
Also have a counter to track #'s of colors matching (what I'll increment in the later compare bit).
Here's what I was going to try for the compare & count colors in both part, will this work right or am I messing up the syntax somewhere? Basically for each previously added up color tracker variable in the previous section, I want to increment the global color counter variable (#3) for each matching set. So example, if goal has 2 blues and player has 3 blues, it'll add 2 to the color counter. If goal has 2 yellows, player 1 yellow, then 1 gets added to the counter.
for (var c = 0; c <= 4; c++) {
if ($gameVariables.value(24+c) > 0 && $gameVariables.value(30+c) > 0) {
$gameVariables.setValue(3,++);
$gameVariables.setValue(24+c,--);
$gameVariables.setValue(30+c,--);
}
}
What tutorials or previous support threads have you referenced? — Tried hunting the forums but didn't quite find anything like this. I've been searching through the MV/MZ Script Calls google doc sheet (which is awesome)! which is where I found all the commands and syntax I thought I was using right. Though those two lines in the if(...) loop I'm guessing on how those commands might work in the .setValue(,) and .add()
Got the compare bit inspiration from this one, but that was switches and these are variables so hope I've altered them right. Check switches post
Are you using any plugins? — None, just base MZ
Attach any illustrative screenshots, full event pages with no cropping, mock ups, etc. — See attached, hope these are sufficient.
Thanks for all your help!
Details — I have 4 crystals that successfully cycle through 5 colors (each w/ their own variable with color codes 0-4) and switches that keep the crystals from moving whenever the room re-draws. There's also the hidden (to the player) goal series of 4 variables w/ their own randomly generated color sequence. The point of the game is to, through logic, get your color sequence to match the hidden one. This part all works, including tracking & reporting perfect matches. For testing, the goal colors are at the top.
I tried setting up the first part of the script (testing via interaction w/ the pig-butt instead of auto cycling w/ the room) but it's throwing a "SyntaxError, Unexpected token ')'" message. I hadn't written the second part, the comparing yet to test. I did check and there's no floating brackets or () so thinking it may be something not-obvious in the syntax.
Here's what I have so far, that's breaking:
var bookmark = 0;
for (var g = 5; g <=8; g++) {
bookmark = $gameVariables.value(g);
for (var i = 0; i<=4; i++) {
if (bookmark === i) {
$gameVariables.setValue(30+i,++);
$gameMessage.add($gameVariables(30+i));
}
}
}
The goal colors are stored in variables 5-8, player colors in 10-13.
I've got the counter variables for recording # of each color in 24-28 for the goal, and 30-34 for the player. Trying for each color for goal & player, to count how many of each color there are. So far the above is only testing the player bit, if I get it working I'd add a second identical bit for the goal series variables #'s 24-28.
Also have a counter to track #'s of colors matching (what I'll increment in the later compare bit).
Here's what I was going to try for the compare & count colors in both part, will this work right or am I messing up the syntax somewhere? Basically for each previously added up color tracker variable in the previous section, I want to increment the global color counter variable (#3) for each matching set. So example, if goal has 2 blues and player has 3 blues, it'll add 2 to the color counter. If goal has 2 yellows, player 1 yellow, then 1 gets added to the counter.
for (var c = 0; c <= 4; c++) {
if ($gameVariables.value(24+c) > 0 && $gameVariables.value(30+c) > 0) {
$gameVariables.setValue(3,++);
$gameVariables.setValue(24+c,--);
$gameVariables.setValue(30+c,--);
}
}
What tutorials or previous support threads have you referenced? — Tried hunting the forums but didn't quite find anything like this. I've been searching through the MV/MZ Script Calls google doc sheet (which is awesome)! which is where I found all the commands and syntax I thought I was using right. Though those two lines in the if(...) loop I'm guessing on how those commands might work in the .setValue(,) and .add()
Got the compare bit inspiration from this one, but that was switches and these are variables so hope I've altered them right. Check switches post
Are you using any plugins? — None, just base MZ
Attach any illustrative screenshots, full event pages with no cropping, mock ups, etc. — See attached, hope these are sufficient.
Thanks for all your help!