RPG Maker MV Invalid or Unexpected token.

sotomisis

Warper
Member
Joined
Sep 5, 2014
Messages
2
Reaction score
0
First Language
Spanish
Primarily Uses
Hello,

I just found a script online for a Party renaming from a party list, and when I use it shows the Invalid token error, this is the script I am using:

Script: var findId = $gameParty._actors; var idLen = findId.length; var findId2 = []; for (e = 0; e < idLen; e++) {findId2[e] = findId[e];} var ee = 0; choices = []; params = []; $gameMessage.setChoices(choices, 0, -1) for (e = 0; e < idLen; e++) {choices.push(String($gameParty.members()[ee]._name)); ee++;} params.push() $gameMessage.setChoiceCallback(function(responseIndex) {SceneManager.push(Scene_Name); SceneManager.prepareNextScene(findId2[responseIndex], 8)})

Can someone help me, please? (I know very little about JS)
 

mlogan

Global Moderators
Global Mod
Joined
Mar 18, 2012
Messages
15,370
Reaction score
8,536
First Language
English
Primarily Uses
RMMV

I've moved this thread to Plugin Support. Please be sure to post your threads in the correct forum next time. Thank you.

 

Hyouryuu-Na

Sapphire Sodium
Veteran
Joined
Jun 15, 2017
Messages
960
Reaction score
2,245
First Language
Not English
Primarily Uses
RMMV
There were some syntax errors.
Try this:
Code:
var findId = $gameParty._actors;
var idLen = findId.length;
var findId2 = [];
for (e = 0; e < idLen; e++) {
  findId2[e] = findId[e];
}
var ee = 0;
choices = [];
params = [];
$gameMessage.setChoices(choices, 0, -1);
for (e = 0; e < idLen; e++) {
  choices.push(String($gameParty.members()[ee]._name));
  ee++;
}
params.push();
$gameMessage.setChoiceCallback(function(responseIndex) {
  SceneManager.push(Scene_Name);
  SceneManager.prepareNextScene(findId2[responseIndex], 8);
})
And a tip: When you see unexpected token, quickly paste that code into https://esprima.org/demo/validate.html
It checks for syntax errors and tells you which part to fix.

Edit: Since script calls can't be more than 12 lines, here's a minified version:
Code:
var findId=$gameParty._actors;var idLen=findId.length;var findId2=[];for(e=0;e<idLen;e++){findId2[e]=findId[e];}
var ee=0;choices=[];params=[];$gameMessage.setChoices(choices,0,-1);for(e=0;e<idLen;e++){choices.push(String($gameParty.members()[ee]._name));ee++;}
params.push();$gameMessage.setChoiceCallback(function(responseIndex){SceneManager.push(Scene_Name);SceneManager.prepareNextScene(findId2[responseIndex],8);})
 
Last edited:

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,113
Reaction score
1,524
First Language
EN
Primarily Uses
RMMZ
Try adding a semi-colon immediately after each of these parts:
Code:
$gameMessage.setChoices(choices, 0, -1)
Code:
params.push()
(@Hyouryuu-Na did you miss the first one?) [Edit: never mind, didn't see the edit. :kaoslp:]

You need a semi-colon at the end of each "line" of JS if you want to pack it all into one line. I pasted it into Visual Studio Code (free code editor) and the code "spell-checker" picked up on the missing semi-colons right away~ :kaothx:
 
Last edited:

Hyouryuu-Na

Sapphire Sodium
Veteran
Joined
Jun 15, 2017
Messages
960
Reaction score
2,245
First Language
Not English
Primarily Uses
RMMV
Which one? I didn't even look at the code XD Just saw where there weren't any semi colons and added them there XD
 

sotomisis

Warper
Member
Joined
Sep 5, 2014
Messages
2
Reaction score
0
First Language
Spanish
Primarily Uses
There were some syntax errors.
Try this:
Code:
var findId = $gameParty._actors;
var idLen = findId.length;
var findId2 = [];
for (e = 0; e < idLen; e++) {
  findId2[e] = findId[e];
}
var ee = 0;
choices = [];
params = [];
$gameMessage.setChoices(choices, 0, -1);
for (e = 0; e < idLen; e++) {
  choices.push(String($gameParty.members()[ee]._name));
  ee++;
}
params.push();
$gameMessage.setChoiceCallback(function(responseIndex) {
  SceneManager.push(Scene_Name);
  SceneManager.prepareNextScene(findId2[responseIndex], 8);
})
And a tip: When you see unexpected token, quickly paste that code into https://esprima.org/demo/validate.html
It checks for syntax errors and tells you which part to fix.

Edit: Since script calls can't be more than 12 lines, here's a minified version:
Code:
var findId=$gameParty._actors;var idLen=findId.length;var findId2=[];for(e=0;e<idLen;e++){findId2[e]=findId[e];}
var ee=0;choices=[];params=[];$gameMessage.setChoices(choices,0,-1);for(e=0;e<idLen;e++){choices.push(String($gameParty.members()[ee]._name));ee++;}
params.push();$gameMessage.setChoiceCallback(function(responseIndex){SceneManager.push(Scene_Name);SceneManager.prepareNextScene(findId2[responseIndex],8);})
Thanks a lot, it worked like a charm! I'll make sure to credit you. :smile:
 

Hyouryuu-Na

Sapphire Sodium
Veteran
Joined
Jun 15, 2017
Messages
960
Reaction score
2,245
First Language
Not English
Primarily Uses
RMMV
No no you don't need to credit me! I just put in two semi colons XD
But good to know it works for you now.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.
time for a new avatar :)

Forum statistics

Threads
106,018
Messages
1,018,357
Members
137,803
Latest member
andrewcole
Top