[FIXED] this.clearCommandList is not a function

Discussion in 'Javascript/Plugin Support' started by Beebanew, Dec 3, 2018.

Thread Status:
Not open for further replies.
  1. Beebanew

    Beebanew Villager Member

    Messages:
    7
    Likes Received:
    0
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    I'm trying to create a window in a new scene but it is throwing an error when calling HorzCommand (Window_Command)'s initialize.

    The error log
    Code:
    Window_Command.prototype.initialize@file:///C:/Users/kawthar/Desktop/Forge/js/rpg_windows.js:1300:5
    Window_HorzCommand.prototype.initialize@file:///C:/Users/kawthar/Desktop/Forge/js/rpg_windows.js:1454:5
    Window_ForgeCommand.prototype.initialize@file:///C:/Users/kawthar/Desktop/Forge/js/plugins/Forge.js:111:2
    Window_ForgeCommand@file:///C:/Users/kawthar/Desktop/Forge/js/plugins/Forge.js:101:2
    Scene_Forge.prototype.createForgeCommandWindow@file:///C:/Users/kawthar/Desktop/Forge/js/plugins/Forge.js:72:23
    Scene_Forge.prototype.create@file:///C:/Users/kawthar/Desktop/Forge/js/plugins/Forge.js:65:2
    SceneManager.changeScene@file:///C:/Users/kawthar/Desktop/Forge/js/rpg_managers.js:2005:13
    SceneManager.updateMain@file:///C:/Users/kawthar/Desktop/Forge/js/rpg_managers.js:1982:13
    SceneManager.update@file:///C:/Users/kawthar/Desktop/Forge/js/rpg_managers.js:1907:9
    
    My window's class
    Code:
    function Window_ForgeCommand() {
    	this.initialize.apply(this, arguments);
    }
    
    Window_ForgeCommand.prototype = Object.create(Window_HorzCommand.prototype);
    Window_ForgeCommand.prototype.constructor = Window_ForgeCommand;
    
    Window_ForgeCommand.prototype.initialize = (width, cantForge, cantDismantle) => {	
    	this.windowWidth = width;
    	this.cantForge = cantForge;
    	this.cantDismantle = cantDismantle;
    	Window_HorzCommand.prototype.initialize.call(this, 0, 0);
    }
    
    Window_ForgeCommand.prototype.windowWidth = () => this.windowWidth ;
    Window_ForgeCommand.prototype.maxCols = () => 3;
    Window_ForgeCommand.prototype.makeCommandList = () => {
    	this.addCommand(Forge.forgeWindowName, 'forge', !this.cantForge);
    	this.addCommand(Forge.dismantleWindowName, 'dismantle', !this.cantDismantle);
    	this.addCommand(TextManager.cancel, 'cancel');
    }
    I'm new to scripting in RPGMMV, sorry if it's a dumb problem.
     
    #1
  2. Poryg

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

    Messages:
    3,425
    Likes Received:
    8,380
    Location:
    Czech Republic
    First Language:
    Czech
    Primarily Uses:
    RMMV
    It would be much more convenient to see the full error log, because from what you sent I can't see the exception that got fired.

    edit: Nevermind, the title says it. Nevertheless, the error looks weird, have you done something to the horzcommand window itself or command window?
     
    #2
  3. Beebanew

    Beebanew Villager Member

    Messages:
    7
    Likes Received:
    0
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    Old answer:
    As the title says, the error is that this.clearCommandList isn't a function.

    [​IMG]

    // Edit
    And, yes, it is there in rpg_windows.js

    [​IMG]

    Didn't see your edit.
    I didn't change anything in HorzCommand nor Window_Command.
     
    #3
  4. Poryg

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

    Messages:
    3,425
    Likes Received:
    8,380
    Location:
    Czech Republic
    First Language:
    Czech
    Primarily Uses:
    RMMV
    Ouch, microsoft edge!
    Is there a specofic reason behind the fact that there's that invalid state error? What if you launch it in the default exe?
     
    #4
  5. Beebanew

    Beebanew Villager Member

    Messages:
    7
    Likes Received:
    0
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    I'm running it with Firefox.
    About the invalid state error, I don't know too. Even with every plugin disabled it is still there.
    And I get the same error running from inside the engine, I prefer running in the browser 'cause of documentation access. Personal workflow I'd say.

    // Edit:
    The state error is thrown when the game starts so I guessed it was "normal" or at least nothing that I need to worry about.
     
    #5
  6. Poryg

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

    Messages:
    3,425
    Likes Received:
    8,380
    Location:
    Czech Republic
    First Language:
    Czech
    Primarily Uses:
    RMMV
    What if you launch it from the normal exe (or normally through rpg maker)? Does it work?
     
    #6
  7. Beebanew

    Beebanew Villager Member

    Messages:
    7
    Likes Received:
    0
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    Nope, exactly same error, including the invalid state error.

    // Edit
    Printing the Window_Command class I can see the clearCommandList function
    [​IMG]
    Any clues?
     
    #7
  8. Poryg

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

    Messages:
    3,425
    Likes Received:
    8,380
    Location:
    Czech Republic
    First Language:
    Czech
    Primarily Uses:
    RMMV
    Looks like something is interfering with the way default horzcommand works.
    What if you just define the function manually imside your window via copy pasting?
     
    #8
  9. Beebanew

    Beebanew Villager Member

    Messages:
    7
    Likes Received:
    0
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    Nope.
    Tried defining the clearCommandList function both for the Window_Command and for my window's class and through the console, neither worked.
    Can you test my code there to see if it's something with the base RMMV's files?
     
    #9
  10. Poryg

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

    Messages:
    3,425
    Likes Received:
    8,380
    Location:
    Czech Republic
    First Language:
    Czech
    Primarily Uses:
    RMMV
    I am currently en route to a 12 hours long work shift. That means about 13 hours until I can look. But if it doesn't get solved by then, I will see
     
    #10
    Beebanew likes this.
  11. Beebanew

    Beebanew Villager Member

    Messages:
    7
    Likes Received:
    0
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    Sure, thank you o/
     
    #11
  12. Beebanew

    Beebanew Villager Member

    Messages:
    7
    Likes Received:
    0
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    FIXED.
    To be honest it was a really dumb problem, I was just tilted.
    You can't use arrow functions for those object functions because arrow function doesn't have it's own this.
    Anyway, thank you @Poryg.
     
    #12
  13. Poryg

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

    Messages:
    3,425
    Likes Received:
    8,380
    Location:
    Czech Republic
    First Language:
    Czech
    Primarily Uses:
    RMMV
    Haha, didn't know :D

    Anyway, now that we know, you can always rewrite it to proper ES6 class syntax :p
     
    #13
    Beebanew likes this.
  14. slimmmeiske2

    slimmmeiske2 Little Red Riding Hood Moderator

    Messages:
    4,834
    Likes Received:
    3,840
    Location:
    Belgium
    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.

     
    #14
Thread Status:
Not open for further replies.

Share This Page