Status
Not open for further replies.

applechoirs

Warper
Member
Joined
Sep 11, 2015
Messages
3
Reaction score
2
First Language
Indonesian
Primarily Uses
RMMV
First is an apology if I'm not clear with my problem because English isn't my mother tongue.

So what am I trying to do here is to let players name their own character, but some names aren't allowed because they overlap with NPCs. Then, I want the name input prompt to be looped if players keep entering the same name/other names that aren't allowed.

So I did this:
loops.png
However, no matter what kind of name I input, I kept getting stuck in the loop. I searched and found that I should be putting the things that will break the loop in the If, not Else. If I want to follow that, that means the $gameActors script must be set to detect that the names inputted aren't forbidden names, and I don't know how to do it. In the first place, I'm not sure whether I did the $gameActors part right on the screenshot.

Any help with my problem? Thanks in advance.
 

autodidact

Veteran
Veteran
Joined
Nov 13, 2020
Messages
62
Reaction score
41
First Language
English
Primarily Uses
RMMV
Edit: Sorry, hasty reading. Ignore my post. See those posting below.

Well, it looks like your "if" check isn't actually checking the name that the player inputs.
Instead, it is checking the same $gameActors.actor(1).name every single time.

Try making it check for the variable that you are storing the name that the player inputs.
From your code, it looks like it should be $gameVariables.value(1)
 
Last edited:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
33,872
Reaction score
8,585
First Language
German
Primarily Uses
RMMV
actually that part is correct @autodidact if you read what he wants to do.
The problem is because a comparison is always between two items, not one item and a list of items.

@applechoirs you'll have to rework the entire line, either checking for each name one after another or to check if the result is contained in the elements of an array (which is a different code, but I don't have that ready at the moment)
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
2,220
Reaction score
1,717
First Language
Portuguese - Br
Primarily Uses
RMMZ
Hi there!
Your script to check the value will not work like that, using a comma between each name. You have either do that:
JavaScript:
$gameActors.actor(1).name().toLowerCase() === "alex" || $gameActors.actor(1).name().toLowerCase() === "bob" || $gameActors.actor(1).name().toLowerCase() === "cherry" etc...

The "||" Operator means:
The actor name 1 is equal to alex OR Bob OR cherry...

If I was you, I will just create an array with every actor name on it and put that array into a variable(Before the loop). Put that script command on a script call:

JavaScript:
let usedNames = $gameParty.members().map(member => member.name().toLowerCase())
$gameVariables.setValue(ID, usedNames)

Then put this script on the conditional branch:

$gameVariables.value(ID).includes($gameActors.actor(1).name().toLowerCase())

"Includes" Is an array method to check if already exist an element in the array. In this case, we are checking if the actor name is on the array. If yes, this means that one party member already has this name.

Javascript Array
Javascript OR ||
 

Nolonar

Veteran
Veteran
Joined
Feb 18, 2018
Messages
271
Reaction score
374
First Language
French, German
Primarily Uses
RMMZ
Then put this script on the conditional branch:

$gameVariables.value(ID).includes($gameActors.actor(1).name().toLowerCase())

"Includes" Is an array method to check if already exist an element in the array. In this case, we are checking if the actor name is on the array. If yes, this means that one party member already has this name.

Just in case you (@applechoirs) don't want to compare the name with existing actor names (you did mention you wanted to avoid overlap with NPC names):

JavaScript:
["alex", "bob", "cherry"].includes($gameActors.actor(1).name().toLowerCase())
 
Last edited:

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
9,000
Reaction score
5,888
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

A video update on the progress I've been making on the cutscenes. :kaosalute:

I wonder if color LUTs is possible for RPG Maker. It would be game changer and can replace the not so good looking tint screen
new mechanic in battle where you can mentally erase enemies when you deplete all their MP instead HP. this gives you a special item of their "memory". it's pretty to do in battle so far.
Apparently MZ lets you preview move routes in the move route editor without having to start up test game. That could save a lot of time during development compared to MV, especially for a long game that uses a lot of event movement for cutscenes.
A repost of an old meme I had made, now with music

Forum statistics

Threads
115,865
Messages
1,093,571
Members
151,085
Latest member
GabrielTakahashi16
Top