TypeError: Cannot read property 'y' of undefined

Poppie360

chocobo wrangler
Veteran
Joined
Feb 28, 2018
Messages
175
Reaction score
52
First Language
English
Primarily Uses
RMMV
Can anyone help me out? I cannot figure out why I am getting this error:
I had made an edit to the windows.js file in order to be able to move the choice box around but I cannot figure out why it is doing this. i can change the X position but i cannot change the Y position.


here is the error that i get when trying to set the Y position of the box (the X position works just fine for whatever reason)
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,065
Reaction score
10,364
First Language
Czech
Primarily Uses
RMMV
X doesn't work either. You're calling Window_ChoiceList.prototype.updatePlacement, which is not a static function. Therefore you can't call it as a prototype function, you have to call it in relation to the particular choice list window. I recommend you to go through a C++ tutorial to learn the basics of object oriented programming.
 

Poppie360

chocobo wrangler
Veteran
Joined
Feb 28, 2018
Messages
175
Reaction score
52
First Language
English
Primarily Uses
RMMV
X doesn't work either. You're calling Window_ChoiceList.prototype.updatePlacement, which is not a static function. Therefore you can't call it as a prototype function, you have to call it in relation to the particular choice list window. I recommend you to go through a C++ tutorial to learn the basics of object oriented programming.
oh wait, i forgot i still had that in, when i DON'T have that bit in it does work for the most part:


As you can see the Y position refuses to change, i have no idea why this is the case and why ony the x position wants to change when i tell it to. do you know why?
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
12,969
Reaction score
13,351
First Language
English
Primarily Uses
RMVXA

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

 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,065
Reaction score
10,364
First Language
Czech
Primarily Uses
RMMV
So now the three functions are the same just without
Window_ChoiceList.prototype.updatePlacement
line?
 

Poppie360

chocobo wrangler
Veteran
Joined
Feb 28, 2018
Messages
175
Reaction score
52
First Language
English
Primarily Uses
RMMV
So now the three functions are the same just without
Window_ChoiceList.prototype.updatePlacement
line?
yep pretty much:
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,065
Reaction score
10,364
First Language
Czech
Primarily Uses
RMMV
So now you are setting the window's X to 155 and Y to 425. That's what is happening.
 

Eliaquim

Raze: The Rakuen Zero's Guardian!
Veteran
Joined
May 22, 2018
Messages
1,291
Reaction score
545
First Language
Portuguese - Br
Primarily Uses
RMMV
Man, i have no idea... I made several snippets in my game with windows. When i have this error, sometimes i have to edit the rpg maker file instead of made a snippet. And then it work.
Watching the code, I see there's something different for other Windows:
Case 0
Case 1
Case 2
I think this has a relation with the position of the message box(center, left, right)
So I guess you have to figure that out.
Maybe the y position is defined through the position of the message box.
Or
You can use SRD super tools.js
And adjust the Windows with that.
 

Poppie360

chocobo wrangler
Veteran
Joined
Feb 28, 2018
Messages
175
Reaction score
52
First Language
English
Primarily Uses
RMMV
So now you are setting the window's X to 155 and Y to 425. That's what is happening.
no, that is a plugin that changes the textbox window to a certain place...although that might conflict with what i am trying to do, let me try to see if it would fix it.

(and the position of the choice box is set relative to variables 19, 20 as indicated in the event i shared a picture of.)

Man, i have no idea... I made several snippets in my game with windows. When i have this error, sometimes i have to edit the rpg maker file instead of made a snippet. And then it work.
Watching the code, I see there's something different for other Windows:
Case 0
Case 1
Case 2
I think this has a relation with the position of the message box(center, left, right)
So I guess you have to figure that out.
Maybe the y position is defined through the position of the message box.
Or
You can use SRD super tools.js
And adjust the Windows with that.
it is set outside of the cases so it would change the positioning regardless of it
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,065
Reaction score
10,364
First Language
Czech
Primarily Uses
RMMV
No, it is not relative to the variables.
You set the variables to certain values and then call a function called Poppie.eleCalc.BattleChoiceOn().
This function sets the X and Y to values defined exactly in that function.

I think you wanted to make the positioning relative by the updatePlacement method, since that contains the two codes that would make the positioning relative to the variables. However, you made a mistake that instead of calling the window's method you called the prototype method, so you naturally got the error.

So if you want, edit the BattleChoiceOn function to this:

black_custom_window.x = $gameVariables.value(19);
black_custom_window.y = $gameVariables.value(20);
and it should work as you intended.
 

Poppie360

chocobo wrangler
Veteran
Joined
Feb 28, 2018
Messages
175
Reaction score
52
First Language
English
Primarily Uses
RMMV
No, it is not relative to the variables.
You set the variables to certain values and then call a function called Poppie.eleCalc.BattleChoiceOn().
This function sets the X and Y to values defined exactly in that function.

I think you wanted to make the positioning relative by the updatePlacement method, since that contains the two codes that would make the positioning relative to the variables. However, you made a mistake that instead of calling the window's method you called the prototype method, so you naturally got the error.

So if you want, edit the BattleChoiceOn function to this:

black_custom_window.x = $gameVariables.value(19);
black_custom_window.y = $gameVariables.value(20);
and it should work as you intended.
no, it doesn't affect the choice window:



the same issue with the Y axis of the box persists without that code, the code is reposnible for moving the message window not the choice window.
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,065
Reaction score
10,364
First Language
Czech
Primarily Uses
RMMV
Oh, I see, so the black_custom_window is that window that says "What will you do?". It makes sense now.

In that case my previous statement is valid. The first code had the right thought, but not the right execution. Instead of Window_Choicelist.prototype you need to know the name of that exact window object. You can find it via the dev tools, should be one of the windows inside the window layer inside SceneManager._scene.
 

Poppie360

chocobo wrangler
Veteran
Joined
Feb 28, 2018
Messages
175
Reaction score
52
First Language
English
Primarily Uses
RMMV
Oh, I see, so the black_custom_window is that window that says "What will you do?". It makes sense now.

In that case my previous statement is valid. The first code had the right thought, but not the right execution. Instead of Window_Choicelist.prototype you need to know the name of that exact window object. You can find it via the dev tools, should be one of the windows inside the window layer inside SceneManager._scene.
no, it isn't that window, but rather a command for the plugin: http://www.gdunlimited.net/scripts/rpg-maker-mv/window-scripts/custom-position-message-box this plugin will move the location of all window boxes created to the point where you define while it is told to do so. i wish to figure out how to do the same thing for the choice boxes.
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,065
Reaction score
10,364
First Language
Czech
Primarily Uses
RMMV
Oh, I see. Nevermind that custom black window then. Revert the game code back to what it was in the first post. Then find the name of that particular choice window and substitute Window_Choicelist.prototype for that name.
Type SceneManager._scene in the console (f8 or f12 in game) and look for something that has Window_ChoiceList next to it in it. It could be _choiceWindow or something, in which case the name would be
SceneManager._scene._choiceWindow
 

Poppie360

chocobo wrangler
Veteran
Joined
Feb 28, 2018
Messages
175
Reaction score
52
First Language
English
Primarily Uses
RMMV
Oh, I see. Nevermind that custom black window then. Revert the game code back to what it was in the first post. Then find the name of that particular choice window and substitute Window_Choicelist.prototype for that name.
Type SceneManager._scene in the console (f8 or f12 in game) and look for something that has Window_ChoiceList next to it in it. It could be _choiceWindow or something, in which case the name would be
SceneManager._scene._choiceWindow

"_choicewindow: window_choicelist" ? is that what you were talking about.
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,065
Reaction score
10,364
First Language
Czech
Primarily Uses
RMMV
Yup.
Try
SceneManager._scene._messageWindow._choiceWindow.updatePlacement();

instead of Window_ChoiceList.prototype.updatePlacement();
in the code in your first post.
 

Poppie360

chocobo wrangler
Veteran
Joined
Feb 28, 2018
Messages
175
Reaction score
52
First Language
English
Primarily Uses
RMMV
Yup.
Try
SceneManager._scene._messageWindow._choiceWindow.updatePlacement();

instead of Window_ChoiceList.prototype.updatePlacement();
in the code in your first post.

So it didn't change anything, but here is something that is very weird:

it works for this event, i have control over the X and Y axis

and here is that event, why does this work but the other doesn't?
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,065
Reaction score
10,364
First Language
Czech
Primarily Uses
RMMV
Have you ever messed around with the first window using the super tools engine? If yes, it might be an option. If not, then maybe it's a different window. It's all so messy that it's stopping to make any sense to me.
 

Poppie360

chocobo wrangler
Veteran
Joined
Feb 28, 2018
Messages
175
Reaction score
52
First Language
English
Primarily Uses
RMMV
Have you ever messed around with the first window using the super tools engine? If yes, it might be an option. If not, then maybe it's a different window. It's all so messy that it's stopping to make any sense to me.
the super tools engine doesn't edit text windows:

so that isn't an option, i could try to mess with common events to see if that works
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,065
Reaction score
10,364
First Language
Czech
Primarily Uses
RMMV
Well, it's officially gotten weird. If I could take a look at the project itself, I could explore. Without it I can only guess. Is the item guard attack skill run window a custom created one or just a default choice window?
 

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

Latest Threads

Latest Profile Posts

Note to self: One lemon is enough to flavor my drink.
'I'm not homophobic, I'm not scared of me house.' - Peter Kay xD
When did anything under your mid-twenties become the new 10 years old? At least try to act like your old enough to sign a lease.
Having someone tell me that "Right clicking to save an image is soooo creepy" has got to be the weirdest thing I've heard this week.
Finally figured out how to make a signature with a pic that leads to a link, it's so cool! Click the image to check out my demo! :kaopride:

Forum statistics

Threads
98,181
Messages
950,174
Members
129,484
Latest member
AegeanCaos
Top