Script Error. Checking player gender.

I try to run the following code but received this error message and was wondering if anybody could spot what is wrong?
Code:
◆Script:if ($gameCharacterCreations.hasInfo(1)) {
:      :if ($gameCharacterCreations.getInfo(1).Body.file == 'Body (1)){
:      :$gameSwitches.setValue(45, true);
:      :}
:      :else if ($gameCharacterCreations.getInfo(1).Body.file == 'Body (2)){
:      :$gameSwitches.setValue(46, true);
:      :}
:      :else{
:      :$gameSwitches.setValue(45, false);
:      :$gameSwitches.setValue(46, false);
:      :}
:      :}
Moderator note: I think this is probably better in the forum looking at Javascript, rather than the general one. So moving this to Javascript/Plugin Support
first thing that stands out to me is you're missing another ' after body in your condition branches...
if ($gameCharacterCreations.getInfo(1).Body.file == 'Body (1))
if ($gameCharacterCreations.getInfo(1).Body.file == 'Body' (1))

try fixing both instances of that and see if that works
first thing that stands out to me is you're missing another ' after body in your condition branches...

if ($gameCharacterCreations.getInfo(1).Body.file == 'Body' (1))

try fixing both instances of that and see if that works
I tried this solution but it came up with the same error message as before. It also added a script call error.
You need to know the value you need to check in the string.
Most likely some of that (1)) behind it is part of the string - but most likely not everything.
So what do you want to check? Where die you get that code, because if you don't know this then most likely you didn't program it yourself.
I tried this solution but it came up with the same error message as before. It also added a script call error.

OK, yeah... I was running on being awake for over 24 hours when I posted that, and while I was maybe right about missing the other ', I should have placed it at the end of the string you were checking. So instead of 'Body' (1)), maybe 'Body (1)'), but that is still a guess without knowing more.

Are you using a plugin that assigns genders and just looking to make a call? If so, what plugin is it?
OK, yeah... I was running on being awake for over 24 hours when I posted that, and while I was maybe right about missing the other ', I should have placed it at the end of the string you were checking. So instead of 'Body' (1)), maybe 'Body (1)'), but that is still a guess without knowing more.

Are you using a plugin that assigns genders and just looking to make a call? If so, what plugin is it?
I am not using a plugin that assigns genders. This is making a call based on the character creation ex plugin.
http://sumrndm.site/character-creator-ex/

You need to know the value you need to check in the string.
Most likely some of that (1)) behind it is part of the string - but most likely not everything.
So what do you want to check? Where die you get that code, because if you don't know this then most likely you didn't program it yourself.
I found this piece of the code
$gameCharacterCreations.getInfo(1).Body.file == 'Body (1) somewhere on this site but cannot remember where.
Edit: I found it https://forums.rpgmakerweb.com/inde...des-character-creator-ex-plugin-f-a-qs.88746/
The code you are using is missing the final ' at the end of it, as I corrected myself earlier. The example you were looking for in the above link is the final question before the Resources section.

from that page:
Code:
$gameCharacterCreations.getInfo(ActorId).Body.file == 'Body (1)'

so yours should look like this:
Code:
if ($gameCharacterCreations.hasInfo(1)) {
    if ($gameCharacterCreations.getInfo(1).Body.file == 'Body (1)') {
        $gameSwitches.setValue(45, true);
    }
    else if ($gameCharacterCreations.getInfo(1).Body.file == 'Body (2)') {
        $gameSwitches.setValue(46, true);
    }
    else {
        $gameSwitches.setValue(45, false);
        $gameSwitches.setValue(46, false);
    }
}

Unless something else is wrong from what I read on that page, then it should be working with that.
The code you are using is missing the final ' at the end of it, as I corrected myself earlier. The example you were looking for in the above link is the final question before the Resources section.

from that page:
Code:
$gameCharacterCreations.getInfo(ActorId).Body.file == 'Body (1)'

so yours should look like this:
Code:
if ($gameCharacterCreations.hasInfo(1)) {
    if ($gameCharacterCreations.getInfo(1).Body.file == 'Body (1)') {
        $gameSwitches.setValue(45, true);
    }
    else if ($gameCharacterCreations.getInfo(1).Body.file == 'Body (2)') {
        $gameSwitches.setValue(46, true);
    }
    else {
        $gameSwitches.setValue(45, false);
        $gameSwitches.setValue(46, false);
    }
}

Unless something else is wrong from what I read on that page, then it should be working with that.
I had already done this correction but it does not work. I pasted this code in and got the same error message as before.
All I know is what I've read and set up, so I don't know how to help further. :/ so good luck to you and hopefully you can solve the problem.
I tested Ahuramazda's code in a base CCEX project (basically, just the plugins required for it to run,) and it worked as intended, so I think your problem is elsewhere.

Try turning off your plugins systematically to see if any of them are causing the conflict.
I tested Ahuramazda's code in a base CCEX project (basically, just the plugins required for it to run,) and it worked as intended, so I think your problem is elsewhere.

Try turning off your plugins systematically to see if any of them are causing the conflict.
Which plugins are required for this script to run? I had to disable some because they were clashing with other plugins I already had installed.
It needs SumRndmDde's SuperToolsEngine and CharacterCreatorEX to run. ☺️

Try disabling every other plugin and testing the event. Assuming it works (which it should, unless something has gone wrong with the event too), you'll need to go through your other plugins turning them on/off until you cause the error to appear again, and then you'll know where the conflict is. It may be caused by a single plugin, or because of a clash in a group of them.

Once you know that, you can decide how important the plugins are, and whether you'd be happy to just cut back on some features, or try posting a request with a demo project of the error to see if someone can help patch the problem.
It seems to have a problem with every one of Yanfly's plugin's.
I think that's unlikely, given the huge range of content that plugins cover. I have another project file which has a lot of Yanfly's core plugins, and the script still works fine. Though, I appreciate it can be hard to narrow down which plugins are involved when so many of them have dependency on one another.

From the original screenshot you posted, one might guess it was YEP_X_ItemRequirements causing the issue, but having tested that, it seems ok. (Sometimes I've noticed error messages just show the first thing that's flagged up as wrong, although it's not specially the cause of the issue. It makes debugging a little bit more troublesome, you might just have to follow instinct instead :hswt:)

Other possible explanations are issues between different versions. I recommend checking out YEP Auto Update and SRD Plugin Updator to keep your plugins up-to-date. Also, what version of MV is your project running?

Another possibility is that your plugins are in the wrong order. Yanfly recommends arranging his plugins as shown on this page, and STE would ideally be at the top. It might help if you share a screenshot of your plugin manager.

You can also PM me a copy of your project if you want. I promise not to repost it anywhere, although I can't promise that I'll find the cause of the problem/solution! I just thought it might be a bit quicker than trying to talk through the list of possibilities, especially when the console errors are being unhelpful(!)
I had also tried disabling YEP_X_ItemRequirements to find the next YEP Plugin above it presenting the same issue. It continued along Yanfly's plugins such as YEP_CommonEventMenu, YEP_HitAccuracy then also noting the core engine.
My project is currently running MV 1.6.1 I should have the plugins in the order described and STE is at the top.

Ok I will PM you a version of it.

Original thread: https://forums.rpgmakerweb.com/threads/script-error-checking-player-gender.96556/