Cannot read property 'battleMembers' of null

Eilios

Veteran
Veteran
Joined
Nov 13, 2015
Messages
58
Reaction score
2
First Language
English
I opened a new topic because this is a completely different question/problem.

I can't understand, or find, for the life of me why this is undefined. Can anyone help please? What is the proper way to call these variables/functions/arrays?

I'm getting the error:

Cannot read property 'battleMembers' of null

(function() { Eilios.Parameters = PluginManager.parameters('Eilios_Movement'); Eilios.Param = Eilios.Param || {}; Eilios.Param.CriticalMultiplier = Number(Eilios.Parameters['Critical Multiplier']); Eilios.Param.MaxInitialTP = Number(Eilios.Parameters['Max Initial TP']); Eilios.Param.MinInitialTP = Number(Eilios.Parameters['Min Initial TP']); // set up vars to store the old x,y var originPartyXY = {}; var tempArray = {}; // set the initial offset Game_Party.prototype.setXYOffset = function() { // loop through each party member var pCount = 0; for (pCount = 0; pCount < $gameParty.battleMembers().length - 1; pCount++) { // save the original xy into main array, reset temp array each time tempArray = {}; tempArray.push($gameParty.battleMembers()[pCount].x); tempArray.push($gameParty.battleMembers()[pCount].y); originPartyXY.push(tempArray); if (pCount % 2) { // set the new xy $gameParty.battleMembers()[pCount].x += -2; $gameParty.battleMembers()[pCount].y += $gameParty.battleMembers()[pCount - 1].y + 2; }else{ // set the new xy $gameParty.battleMembers()[pCount].x += 2; $gameParty.battleMembers()[pCount].y += $gameParty.battleMembers()[pCount - 1].y + 2; } } // show results console.log("made it to the function!"); }; Game_Party.prototype.setXYOffset();})();Looking through other plugins it seems people can just use this:

// Local Functions - Get Action Skills function ActionSkill_GetActionSkills() { var ActiveMembersArr = $gameParty.battleMembers(); var ActiveMembersSkills = []; for (i = 0; i < ActiveMembersArr.length; i++) { // Check all Active Party Members for (j = 0; j < ActiveMembersArr._skills.length; j++) { var skill = $dataSkills[ActiveMembersArr._skills[j]]; // Tag Check for any usable Skills if (TagCheck(skill, ActionSkillTag)) { if (!ActiveMembersSkills.contains(ActiveMembersArr._skills[j])) ActiveMembersSkills.push(ActiveMembersArr._skills[j]); } } } // Return the Skills found return ActiveMembersSkills; }So I'm pretty lost. I'm new to rmmv, not new to programming. Not an expert with javascript but this seems it just isn't accessing the variable/array at all....................
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,108
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
It is saying $gameParty is not defined.  Looks like it's trying to run the command before the DataManager has set up the game objects.


This:


Game_Party.prototype.setXYOffset();


is not how you apply the command.  This is:


$gameParty.setXYOffset();


and needs to be done within a method that's called at some point after DataManager has set up the game objects.
 

Mellye

Veteran
Veteran
Joined
Oct 24, 2015
Messages
347
Reaction score
279
First Language
Portuguese
and needs to be done within a method that's called at some point after DataManager has set up the game objects.
This indeed.

You're calling your method as soon as your plugin is loaded. There's no $gameParty yet at that point.

You'll want to call it, for example, inside something like Scene_Battle.prototype.start.
 
Last edited by a moderator:

Eilios

Veteran
Veteran
Joined
Nov 13, 2015
Messages
58
Reaction score
2
First Language
English
It is saying $gameParty is not defined.  Looks like it's trying to run the command before the DataManager has set up the game objects.

This:

Game_Party.prototype.setXYOffset();

is not how you apply the command.  This is:

$gameParty.setXYOffset();

and needs to be done within a method that's called at some point after DataManager has set up the game objects.
This indeed.

You're calling your method as soon as your plugin is loaded. There's no $gameParty yet at that point.

You'll want to call it, for example, inside something like Scene_Battle.prototype.start.
I see what you mean, I just don't know how to do it. What can I throw this stuff in that I want to start off the bat after the game objects have loaded? This is, eventually, my attempt to change the follow path of the party members, so it would have to do be done right after load.

Edit:

I put it in Scene_Battle.prototype.start {}, but that's when it switches to a battle scene yes? I need it to be when the game turns on, after selecting new game or continuing a game. I wish there was API. :(

Edit 2:

I tried:

Scene_Map.prototype.onMapLoaded = function() { $gameParty.setXYOffset();};but I immediately get an error, obviously, right before loading the game, that says:

TypeError

undefined is not a function
 
Last edited by a moderator:

Mellye

Veteran
Veteran
Joined
Oct 24, 2015
Messages
347
Reaction score
279
First Language
Portuguese
Edit 2:
I tried:

Scene_Map.prototype.onMapLoaded = function() { $gameParty.setXYOffset();};but I immediately get an error, obviously, right before loading the game, that says:

TypeError

undefined is not a function
What lines are you getting this error? You can check that by pressing F8 to open the console.

I imagine you're getting them in those lines:

tempArray.push($gameParty.battleMembers()[pCount].x);tempArray.push($gameParty.battleMembers()[pCount].y);originPartyXY.push(tempArray);You're using ".push" in variables that you defined as objects, by initializing them as {}. You'd want them to be arrays, [].

Change those:

var originPartyXY = {};var tempArray = {};// (...)tempArray = {};To

var originPartyXY = [];var tempArray = [];// (...)tempArray = [];You'll also get another error later on, because you're trying to check the .y property of $gameParty.battleMembers()[-1] when you first run through that loop.
 
Last edited by a moderator:

Eilios

Veteran
Veteran
Joined
Nov 13, 2015
Messages
58
Reaction score
2
First Language
English
What lines are you getting this error? You can check that by pressing F8 to open the console.

I imagine you're getting them in those lines:

tempArray.push($gameParty.battleMembers()[pCount].x);tempArray.push($gameParty.battleMembers()[pCount].y);originPartyXY.push(tempArray);You're using ".push" in variables that you defined as objects, by initializing them as {}. You'd want them to be arrays, [].

Change those:

var originPartyXY = {};var tempArray = {};// (...)tempArray = {};To

var originPartyXY = [];var tempArray = [];// (...)tempArray = [];You'll also get another error later on, because you're trying to check the .y property of $gameParty.battleMembers()[-1] when you first run through that loop.
PHP mixes oppppsss. :)

The error is before the map even loads. It's just a black screen.

Edit: That did fix it though, now I'm getting other errors about:

'TypeError: Cannot read property 'y' of undefined

    at Game_Party.setXYOffset (/C:/x/x/x/x/x/js/plugins/Eilios_Movement.js:63)'

 

but it's because $gameParty.battleMembers()[1].x is undefined, can't get the x that way in this scenario, so you still helped immensely, plus I learned I can scan through like everything in the console, so thank you!!!!!! Hopefully this is the end of my problems.

 

:)
 
Last edited by a moderator:

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