Urashima09

Villager
Member
Joined
Apr 27, 2017
Messages
29
Reaction score
5
First Language
Portuguese
Primarily Uses
RMXP
Greetings!
I need to check if each of the four actors in the party has State X. If actor X has this State, then the variable X (same State id) increases by 1. Pretty simple, isn't it?

I tried:
JavaScript:
for (i = 0; i <= $gameParty.members().length; i++){
    var id = $gameParty.members()._actorId;
    if ($gameActors.actor(id).isStateAffected(33)){
        $gameVariables.setValue(id, $gameVariables.value(id)+1);
    }
}

Thanks!
 

estriole

Veteran
Veteran
Joined
Jun 27, 2012
Messages
1,483
Reaction score
721
First Language
indonesian
maybe try:
Code:
for (member of $gameParty.members()){
  var id = member._actorId;
  if (member.isStateAffected(33)){
     $gameVariables.setValue(id,$gameVariables.value(id)+1)
  }
};
i did not test that though... hope this help.
 

CHKNRAVE

Surprisingly not sponsored by Yanfly.
Veteran
Joined
May 11, 2020
Messages
216
Reaction score
124
First Language
French
Primarily Uses
RMMV
Your i variable from the for loop isn't changing anything in the loop.
Try this:
JavaScript:
for (i = 0; i <= $gameParty.members().length; i++){
    var id = $gameParty.members()[i]._actorId;
    if ($gameActors.actor(id).isStateAffected(33)){
        $gameVariables.setValue(id, $gameVariables.value(id)+1);
    }
}
Because $gameParty.members() needs a party ID that has to be specified between brackets.
The rest should be working as intended.
 

Urashima09

Villager
Member
Joined
Apr 27, 2017
Messages
29
Reaction score
5
First Language
Portuguese
Primarily Uses
RMXP
@CHKNRAVE @estriole
Thank you two!

So, it's works fine:
JavaScript:
for (i = 0; i < $gameParty.members().length; i++){
    var id = $gameParty.members()[i]._actorId;
    var nome = $gameActors.actor(id).name();
    if ($gameActors.actor(id).isStateAffected(33)){ //Agree
        $gameVariables.setValue(id, $gameVariables.value(id)+1);
        $gameMessage.add(nome + ' approves. \i[84]' + $gameVariables.value(id) + '/10');
    } 
}

But, I'm trying to check if the same actor have the State Y (in case him not have State X). I tried:
JavaScript:
for (i = 0; i < $gameParty.members().length; i++){
    var id = $gameParty.members()[i]._actorId;
    var nome = $gameActors.actor(id).name();
    console.log(id);
    console.log(nome);
    if ($gameActors.actor(id).isStateAffected(33)){ //Agree
        $gameVariables.setValue(id, $gameVariables.value(id)+1);
        $gameMessage.add(nome + ' approves. \i[84]' + $gameVariables.value(id) + '/10');
    } else {
        if ($gameActors.actor(id).isStateAffected(35)){ //Disagree
            $gameVariables.setValue(id, $gameVariables.value(id)+1);
            $gameMessage.add(nome + ' Disapproves. \i[84]' + $gameVariables.value(id) + '/10');
        }
    }
}

and I'm recieving the same error message, below D;

JavaScript:
SCRIPT CALL ERROR
YEP_CoreEngine.js:2810 for (i = 0; i < $gameParty.members().length; i++){
    var id = $gameParty.members()[i]._actorId;
    var nome = $gameActors.actor(id).name();
    console.log(id);
    console.log(nome);
    if ($gameActors.actor(id).isStateAffected(33)){
        $gameVariables.setValue(id, $gameVariables.value(id)+1);
        $gameMessage.add(nome + ' aprova. \i[84]' + $gameVariables.value(id) + '/10');
    } else {
        if ($gameActors.actor(id).isStateAffected(35)){
            $gameVariables.setValue(id, $gameVariables.value(id)+1);
            //$gameMessage.add(nome + ' aprova. \i[84]' + $gameVariables.value(id) + '/10');

YEP_CoreEngine.js:2811 SyntaxError: Unexpected end of input
    at Game_Interpreter.command355 (YEP_CoreEngine.js:1857)
    at Game_Interpreter.executeCommand (rpg_objects.js:8930)
    at Game_Interpreter.update (rpg_objects.js:8838)
    at Game_Interpreter.updateChild (rpg_objects.js:8849)
    at Game_Interpreter.update (rpg_objects.js:8832)
    at Game_Map.updateInterpreter (rpg_objects.js:6115)
    at Game_Map.update (rpg_objects.js:6022)
    at Scene_Map.updateMain (rpg_scenes.js:608)
    at Scene_Map.updateMainMultiply (rpg_scenes.js:600)
    at Scene_Map.update (rpg_scenes.js:589)
Yanfly.Util.displayError @ YEP_CoreEngine.js:2811
Game_Interpreter.command355 @ YEP_CoreEngine.js:1859
Game_Interpreter.executeCommand @ rpg_objects.js:8930
Game_Interpreter.update @ rpg_objects.js:8838
Game_Interpreter.updateChild @ rpg_objects.js:8849
Game_Interpreter.update @ rpg_objects.js:8832
Game_Map.updateInterpreter @ rpg_objects.js:6115
Game_Map.update @ rpg_objects.js:6022
Scene_Map.updateMain @ rpg_scenes.js:608
Scene_Map.updateMainMultiply @ rpg_scenes.js:600
Scene_Map.update @ rpg_scenes.js:589
Scene_Map.update @ YEP_CoreEngine.js:1425
SceneManager.updateScene @ rpg_managers.js:2024
SceneManager.updateMain @ YEP_X_CoreUpdatesOpt.js:7951
SceneManager.update @ YEP_X_CoreUpdatesOpt.js:7930
requestAnimationFrame (async)
SceneManager.requestUpdate @ rpg_managers.js:1896
SceneManager.updateMain @ YEP_X_CoreUpdatesOpt.js:7956
SceneManager.update @ YEP_X_CoreUpdatesOpt.js:7930
requestAnimationFrame (async)
SceneManager.requestUpdate @ rpg_managers.js:1896
SceneManager.updateMain @ YEP_X_CoreUpdatesOpt.js:7956
SceneManager.update @ YEP_X_CoreUpdatesOpt.js:7930
requestAnimationFrame (async)
SceneManager.requestUpdate @ rpg_managers.js:1896
SceneManager.updateMain @ YEP_X_CoreUpdatesOpt.js:7956
SceneManager.update @ YEP_X_CoreUpdatesOpt.js:7930
requestAnimationFrame (async)
SceneManager.requestUpdate @ rpg_managers.js:1896
SceneManager.updateMain @ YEP_X_CoreUpdatesOpt.js:7956
SceneManager.update @ YEP_X_CoreUpdatesOpt.js:7930
requestAnimationFrame (async)
SceneManager.requestUpdate @ rpg_managers.js:1896
SceneManager.updateMain @ YEP_X_CoreUpdatesOpt.js:7956
SceneManager.update @ YEP_X_CoreUpdatesOpt.js:7930
requestAnimationFrame (async)
SceneManager.requestUpdate @ rpg_managers.js:1896
SceneManager.updateMain @ YEP_X_CoreUpdatesOpt.js:7956
SceneManager.update @ YEP_X_CoreUpdatesOpt.js:7930
requestAnimationFrame (async)
SceneManager.requestUpdate @ rpg_managers.js:1896
SceneManager.updateMain @ YEP_X_CoreUpdatesOpt.js:7956
SceneManager.update @ YEP_X_CoreUpdatesOpt.js:7930
requestAnimationFrame (async)
SceneManager.requestUpdate @ rpg_managers.js:1896
SceneManager.updateMain @ YEP_X_CoreUpdatesOpt.js:7956
SceneManager.update @ YEP_X_CoreUpdatesOpt.js:7930
requestAnimationFrame (async)
SceneManager.requestUpdate @ rpg_managers.js:1896
SceneManager.updateMain @ YEP_X_CoreUpdatesOpt.js:7956
SceneManager.update @ YEP_X_CoreUpdatesOpt.js:7930
requestAnimationFrame (async)
SceneManager.requestUpdate @ rpg_managers.js:1896
SceneManager.updateMain @ YEP_X_CoreUpdatesOpt.js:7956
SceneManager.update @ YEP_X_CoreUpdatesOpt.js:7930
requestAnimationFrame (async)
SceneManager.requestUpdate @ rpg_managers.js:1896
SceneManager.updateMain @ YEP_X_CoreUpdatesOpt.js:7956
SceneManager.update @ YEP_X_CoreUpdatesOpt.js:7930
requestAnimationFrame (async)
SceneManager.requestUpdate @ rpg_managers.js:1896
SceneManager.updateMain @ YEP_X_CoreUpdatesOpt.js:7956
SceneManager.update @ YEP_X_CoreUpdatesOpt.js:7930
requestAnimationFrame (async)
SceneManager.requestUpdate @ rpg_managers.js:1896
SceneManager.updateMain @ YEP_X_CoreUpdatesOpt.js:7956
SceneManager.update @ YEP_X_CoreUpdatesOpt.js:7930
requestAnimationFrame (async)
SceneManager.requestUpdate @ rpg_managers.js:1896
SceneManager.updateMain @ YEP_X_CoreUpdatesOpt.js:7956
SceneManager.update @ YEP_X_CoreUpdatesOpt.js:7930
requestAnimationFrame (async)
SceneManager.requestUpdate @ rpg_managers.js:1896
SceneManager.updateMain @ YEP_X_CoreUpdatesOpt.js:7956
SceneManager.update @ YEP_X_CoreUpdatesOpt.js:7930
requestAnimationFrame (async)
SceneManager.requestUpdate @ rpg_managers.js:1896
SceneManager.updateMain @ YEP_X_CoreUpdatesOpt.js:7956
SceneManager.update @ YEP_X_CoreUpdatesOpt.js:7930
requestAnimationFrame (async)
SceneManager.requestUpdate @ rpg_managers.js:1896
SceneManager.updateMain @ YEP_X_CoreUpdatesOpt.js:7956
SceneManager.update @ YEP_X_CoreUpdatesOpt.js:7930
requestAnimationFrame (async)
SceneManager.requestUpdate @ rpg_managers.js:1896
SceneManager.updateMain @ YEP_X_CoreUpdatesOpt.js:7956
SceneManager.update @ YEP_X_CoreUpdatesOpt.js:7930
requestAnimationFrame (async)
SceneManager.requestUpdate @ rpg_managers.js:1896
SceneManager.updateMain @ YEP_X_CoreUpdatesOpt.js:7956
SceneManager.update @ YEP_X_CoreUpdatesOpt.js:7930
requestAnimationFrame (async)
SceneManager.requestUpdate @ rpg_managers.js:1896
SceneManager.updateMain @ YEP_X_CoreUpdatesOpt.js:7956
SceneManager.update @ YEP_X_CoreUpdatesOpt.js:7930
requestAnimationFrame (async)
SceneManager.requestUpdate @ rpg_managers.js:1896
SceneManager.updateMain @ YEP_X_CoreUpdatesOpt.js:7956
SceneManager.update @ YEP_X_CoreUpdatesOpt.js:7930
requestAnimationFrame (async)
SceneManager.requestUpdate @ rpg_managers.js:1896
SceneManager.updateMain @ YEP_X_CoreUpdatesOpt.js:7956
SceneManager.update @ YEP_X_CoreUpdatesOpt.js:7930
requestAnimationFrame (async)
SceneManager.requestUpdate @ rpg_managers.js:1896
SceneManager.updateMain @ YEP_X_CoreUpdatesOpt.js:7956
SceneManager.update @ YEP_X_CoreUpdatesOpt.js:7930
requestAnimationFrame (async)
SceneManager.requestUpdate @ rpg_managers.js:1896
SceneManager.updateMain @ YEP_X_CoreUpdatesOpt.js:7956
SceneManager.update @ YEP_X_CoreUpdatesOpt.js:7930
requestAnimationFrame (async)
SceneManager.requestUpdate @ rpg_managers.js:1896
SceneManager.updateMain @ YEP_X_CoreUpdatesOpt.js:7956
SceneManager.update @ YEP_X_CoreUpdatesOpt.js:7930
requestAnimationFrame (async)
SceneManager.requestUpdate @ rpg_managers.js:1896
SceneManager.updateMain @ YEP_X_CoreUpdatesOpt.js:7956
SceneManager.update @ YEP_X_CoreUpdatesOpt.js:7930
requestAnimationFrame (async)
SceneManager.requestUpdate @ rpg_managers.js:1896
SceneManager.updateMain @ YEP_X_CoreUpdatesOpt.js:7956
SceneManager.update @ YEP_X_CoreUpdatesOpt.js:7930
requestAnimationFrame (async)
SceneManager.requestUpdate @ rpg_managers.js:1896
SceneManager.updateMain @ YEP_X_CoreUpdatesOpt.js:7956
SceneManager.update @ YEP_X_CoreUpdatesOpt.js:7930
requestAnimationFrame (async)
SceneManager.requestUpdate @ rpg_managers.js:1896
SceneManager.updateMain @ YEP_X_CoreUpdatesOpt.js:7956
SceneManager.update @ YEP_X_CoreUpdatesOpt.js:7930
requestAnimationFrame (async)
SceneManager.requestUpdate @ rpg_managers.js:1896
SceneManager.updateMain @ YEP_X_CoreUpdatesOpt.js:7956
SceneManager.update @ YEP_X_CoreUpdatesOpt.js:7930
requestAnimationFrame (async)
SceneManager.requestUpdate @ rpg_managers.js:1896
SceneManager.updateMain @ YEP_X_CoreUpdatesOpt.js:7956
SceneManager.update @ YEP_X_CoreUpdatesOpt.js:7930
requestAnimationFrame (async)
SceneManager.requestUpdate @ rpg_managers.js:1896
SceneManager.updateMain @ YEP_X_CoreUpdatesOpt.js:7956
SceneManager.update @ YEP_X_CoreUpdatesOpt.js:7930
 

estriole

Veteran
Veteran
Joined
Jun 27, 2012
Messages
1,483
Reaction score
721
First Language
indonesian
i'm curious with the error line here:
Code:
//$gameMessage.add(nome + ' aprova. \i[84]' + $gameVariables.value(id) + '/10');
why there's '//' that make the script 'comment' the line there?
and unexpected end of input error means there script is not 'complete' form (lack of closed brackets, etc)

you might want to recheck your script call command...
also the script call box has limit on number of lines you can put. so maybe your script call got
'cut' at the bottom...

try removing some unecessary lines like console.log
or make it one liner as possible. (placing multiple lines in one line)
because script call box have super long width to the right
example in your script above
Code:
for (i = 0; i < $gameParty.members().length; i++){
  var id = $gameParty.members()[i]._actorId; var nome = $gameActors.actor(id).name();
  console.log(id); console.log(nome);
  if ($gameActors.actor(id).isStateAffected(33)){ //Agree
    $gameVariables.setValue(id, $gameVariables.value(id)+1); $gameMessage.add(nome + ' approves. \i[84]' + $gameVariables.value(id) + '/10');
  } else {
    if ($gameActors.actor(id).isStateAffected(35)){ //Disagree
    $gameVariables.setValue(id, $gameVariables.value(id)+1);$gameMessage.add(nome + ' Disapproves. \i[84]' + $gameVariables.value(id) + '/10');
}}}
at the end i put all the '{' in one line to save lines...

if you want to be more extreme:
Code:
for (i = 0; i < $gameParty.members().length; i++){var id = $gameParty.members()[i]._actorId; var nome = $gameActors.actor(id).name(); console.log(id); console.log(nome); if ($gameActors.actor(id).isStateAffected(33)){  $gameVariables.setValue(id, $gameVariables.value(id)+1); $gameMessage.add(nome + ' approves. \i[84]' + $gameVariables.value(id) + '/10');  } else {    if ($gameActors.actor(id).isStateAffected(35)){$gameVariables.setValue(id, $gameVariables.value(id)+1);$gameMessage.add(nome + ' Disapproves. \i[84]' + $gameVariables.value(id) + '/10');}}}
:D... hope this help.
 
Last edited:

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,418
Reaction score
1,827
First Language
EN
Primarily Uses
RMMZ
Note that \backslashes are used for escape notation. If you want to use a literal backslash character, you need to write it as \\, e.g.
JavaScript:
$gameMessage.add(nome + ' approves. \\i[84]' + $gameVariables.value(id) + '/10');


Like estriole says, I suspect you've pasted the code into the Script command box (12 lines max) and it has been cut off after the 12th line, hence the error you're seeing. Here's another shortened example, including escaped backslashes:
JavaScript:
for (i = 0; i < $gameParty.members().length; i++) {
    var id = $gameParty.members()[i].actorId();
    var nome = $gameActors.actor(id).name();
    console.log('id:', id, '\nnome:', nome);
    if ($gameActors.actor(id).isStateAffected(33)) { //Agree
        $gameVariables.setValue(id, $gameVariables.value(id)+1);
        $gameMessage.add(nome + ' approves. \\i[84]' + $gameVariables.value(id) + '/10');
    } else {
        if ($gameActors.actor(id).isStateAffected(35)) { //Disagree
            $gameVariables.setValue(id, $gameVariables.value(id)+1);
            $gameMessage.add(nome + ' Disapproves. \\i[84]' + $gameVariables.value(id) + '/10');
}}};
 

Urashima09

Villager
Member
Joined
Apr 27, 2017
Messages
29
Reaction score
5
First Language
Portuguese
Primarily Uses
RMXP
You guys are the best
I had no ideia about the limit of 12 lines
 

Latest Threads

Latest Posts

Latest Profile Posts

After gathering, sorting out & reconsidering hundreds of enemy battlers over the last two das, finally my favorite part begins: Inventing names and lore for them all :D
I'm running a sale for Learn RPG Maker MV on Itch.io, can I compete with NSFW games earning goals?
Another Friday and another Zoom call that could have been an email. Working from home is awesome.
Finished with the semester; finally have some time to play around with MV :kaopride:
Started work on the fishing Mini-Game

Forum statistics

Threads
111,368
Messages
1,060,525
Members
144,696
Latest member
Asher491351
Top