TypeError: Cannot read property 'y' of undefined

Discussion in 'Javascript/Plugin Support' started by Poppie360, Dec 6, 2018.

  1. Poppie360

    Poppie360 chocobo wrangler Veteran

    Messages:
    120
    Likes Received:
    32
    Location:
    NH, USA
    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.
    [​IMG]
    [​IMG]
    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)
    [​IMG]
     
    #1
  2. Poryg

    Poryg Pixie of the Emvee kingdom, Ham of a Hamster Veteran

    Messages:
    3,651
    Likes Received:
    9,172
    Location:
    Czech Republic
    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.
     
    #2
  3. Poppie360

    Poppie360 chocobo wrangler Veteran

    Messages:
    120
    Likes Received:
    32
    Location:
    NH, USA
    First Language:
    English
    Primarily Uses:
    RMMV
    oh wait, i forgot i still had that in, when i DON'T have that bit in it does work for the most part:
    [​IMG]
    [​IMG]
    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?
     
    #3
  4. bgillisp

    bgillisp Global Moderators Global Mod

    Messages:
    11,594
    Likes Received:
    11,587
    Location:
    USA
    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.

     
    #4
  5. Poryg

    Poryg Pixie of the Emvee kingdom, Ham of a Hamster Veteran

    Messages:
    3,651
    Likes Received:
    9,172
    Location:
    Czech Republic
    First Language:
    Czech
    Primarily Uses:
    RMMV
    So now the three functions are the same just without
    Window_ChoiceList.prototype.updatePlacement
    line?
     
    #5
  6. Poppie360

    Poppie360 chocobo wrangler Veteran

    Messages:
    120
    Likes Received:
    32
    Location:
    NH, USA
    First Language:
    English
    Primarily Uses:
    RMMV
    yep pretty much:
    [​IMG]
     
    #6
  7. Poryg

    Poryg Pixie of the Emvee kingdom, Ham of a Hamster Veteran

    Messages:
    3,651
    Likes Received:
    9,172
    Location:
    Czech Republic
    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.
     
    #7
  8. Eliaquim

    Eliaquim Raze: The Rakuen Zero's Guardian! Veteran

    Messages:
    563
    Likes Received:
    166
    Location:
    Brazil - Rio de Janeiro
    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.
     
    #8
  9. Poppie360

    Poppie360 chocobo wrangler Veteran

    Messages:
    120
    Likes Received:
    32
    Location:
    NH, USA
    First Language:
    English
    Primarily Uses:
    RMMV
    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.)

    it is set outside of the cases so it would change the positioning regardless of it
     
    #9
  10. Poryg

    Poryg Pixie of the Emvee kingdom, Ham of a Hamster Veteran

    Messages:
    3,651
    Likes Received:
    9,172
    Location:
    Czech Republic
    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.
     
    #10
  11. Poppie360

    Poppie360 chocobo wrangler Veteran

    Messages:
    120
    Likes Received:
    32
    Location:
    NH, USA
    First Language:
    English
    Primarily Uses:
    RMMV
    no, it doesn't affect the choice window:
    [​IMG]
    [​IMG]
    [​IMG]
    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.
     
    #11
  12. Poryg

    Poryg Pixie of the Emvee kingdom, Ham of a Hamster Veteran

    Messages:
    3,651
    Likes Received:
    9,172
    Location:
    Czech Republic
    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.
     
    #12
  13. Poppie360

    Poppie360 chocobo wrangler Veteran

    Messages:
    120
    Likes Received:
    32
    Location:
    NH, USA
    First Language:
    English
    Primarily Uses:
    RMMV
    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.
     
    #13
  14. Poryg

    Poryg Pixie of the Emvee kingdom, Ham of a Hamster Veteran

    Messages:
    3,651
    Likes Received:
    9,172
    Location:
    Czech Republic
    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
     
    #14
  15. Poppie360

    Poppie360 chocobo wrangler Veteran

    Messages:
    120
    Likes Received:
    32
    Location:
    NH, USA
    First Language:
    English
    Primarily Uses:
    RMMV
    [​IMG]
    "_choicewindow: window_choicelist" ? is that what you were talking about.
     
    #15
  16. Poryg

    Poryg Pixie of the Emvee kingdom, Ham of a Hamster Veteran

    Messages:
    3,651
    Likes Received:
    9,172
    Location:
    Czech Republic
    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.
     
    #16
  17. Poppie360

    Poppie360 chocobo wrangler Veteran

    Messages:
    120
    Likes Received:
    32
    Location:
    NH, USA
    First Language:
    English
    Primarily Uses:
    RMMV
    [​IMG]
    So it didn't change anything, but here is something that is very weird:
    [​IMG]
    it works for this event, i have control over the X and Y axis
    [​IMG]
    and here is that event, why does this work but the other doesn't?
     
    #17
  18. Poryg

    Poryg Pixie of the Emvee kingdom, Ham of a Hamster Veteran

    Messages:
    3,651
    Likes Received:
    9,172
    Location:
    Czech Republic
    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.
     
    #18
  19. Poppie360

    Poppie360 chocobo wrangler Veteran

    Messages:
    120
    Likes Received:
    32
    Location:
    NH, USA
    First Language:
    English
    Primarily Uses:
    RMMV
    the super tools engine doesn't edit text windows:
    [​IMG]
    so that isn't an option, i could try to mess with common events to see if that works
     
    #19
  20. Poryg

    Poryg Pixie of the Emvee kingdom, Ham of a Hamster Veteran

    Messages:
    3,651
    Likes Received:
    9,172
    Location:
    Czech Republic
    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?
     
    #20

Share This Page