JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 143 of 171 View original ↗
  1. ATT_Turan said:
    @Lonewulf123 That question is better for a Plugin Support post - or, really, sent to the VisuStella team.

    Their plugins are obfuscated, which means we can't just open them up and read the code. If they don't tell you about the format of a script call in the plugin instructions, we can't look up the answer.
    Yes, I know. I already asked there, but figured I would ask here just in case someone had any experience.
  2. How can I disable the use of a specific item by a javascript condition?
  3. Fionn23 said:
    How can I disable the use of a specific item by a javascript condition?
    Alias the use item function to check for the item Id
  4. If I had a plugin add a menu item and I wanted to hide it, how do I do that?
    The plugin in question is in Japanese but I can provide a link or the JS file itself.
  5. @herpinderpinlol That would depend on the plugin - many of them include plugin commands to show and hide their menu options.

    Per the first post in this thread, it's not for asking for help with plugins. You should make a new thread in Plugin Support and provide the name of the plugin and a link to where it can be downloaded (don't redistribute plugins in your posts unless it was made just for you).
  6. Hi everyone, sort of new here and I have a question that is probably not worth it's own thread.
    I'm working on a MZ plugin to add some windows and scenes, I had everything on a big JS file for the plugin and it works great. However, I would like to have the new classes I added on separate files so this file stops being so big.
    inside plugins/ I have lets say myPlugin.js, and in there I have import statements for all my classes:
    Code:
    import './classFolder/class1.js';
    import './classFolder/class2.js';
    import './classFolder/class3.js';
    import './classFolder/class4.js';
    
    (() => {
        const pluginName = "myPlugin";
    // plugin implementation
    When I try to run it I get an error 'Cannot use import statement outside a module'.

    I havent been able to find a solution for this, anyone here has encountered this issue before? Does MZ not support modules?
  7. Does buffRate have a coded value of 1? I'm using YEP_BaseParamControl. This is the MHP formula:

    (base + plus) + buffRate + flat

    An actor has a MHP of 3 and an enemy has a MHP of 15, but in-game, their respective MHP values are of 4 and 16, respectively. By removing buffRate from the formula, their in-game MHP values are as stated in the database.

    Since I'm already asking about buffRate, if I'm using states as buffs, is there a point of leaving it in the formula?
  8. DrBuni said:
    Does buffRate have a coded value of 1? I'm using YEP_BaseParamControl. This is the MHP formula:
    pretty sure the buff rate is 1+(buff stacks * stack value). its supposed to be a multiplicative factor.
    the default given by the plugin's help file is (base + plus) * paramRate * buffRate + flat
  9. Robro33 said:
    pretty sure the buff rate is 1+(buff stacks * stack value). its supposed to be a multiplicative factor.
    the default given by the plugin's help file is (base + plus) * paramRate * buffRate + flat
    Thanks. I was just trying to understand why it's adding 1 to MHP value of the battlers. I'm aware of what the base formula is, I changed it on purpose.
  10. @AldoJV That shouldn't be necessary. Everything you have included as a plugin will be loaded into the game in its order in the plugin manager, so it's all accessible across files (unless you've specifically encapsulated it in which case you can choose not to do that or you can look up how to code around it )

    Take a look at how the default code is created and organized in rmmz_scenes and rmmz_windows - is your custom code taking up more space than everything created for the default engine?

    To answer your question, from the documentation for import:
    1713123422918.png
  11. @ATT_Turan thanks for replying!
    Its not a lot of code, I'm just trying to have one file per class for easier understanding.
    I ended up looking at how main.js loads the scripts and did something similar to have my classes defined.
  12. @AldoJV Something like that can make sense if you're creating your own program entirely. If you're making a plugin, that's generally harder to use - it probably makes more sense to put everything related to the plugin into one file.

    Regardless, there should be no need for special syntax or commands to access things from other files. They're all a part of the same project.
  13. How do I check if the player is inside a world map?
  14. Fionn23 said:
    How do I check if the player is inside a world map?
    define "world map". thats not a distinction within the engine. Forgot thats a tileset property and not a map property

    if you have a map that youve designated as your world map, you can use "$gameMap._mapId == x" to check if the player is currently on it
  15. If you have multiple world maps, $gameMap.isOverworld() might also work. Provided you are using "World Type" tile sets for your world maps, of course.
  16. Hi,

    I'm using this little scriptlet to increase the size of the Damage popups in my MZ game.

    JavaScript:
    Sprite_Damage.prototype.fontSize = function() {
      return $gameSystem.mainFontSize() + 20; 
    };

    However, it effects both the damage popup numbers and the state popups.

    Is there a way to make it so it only effects the damage number popups?
  17. Lonewulf123 said:
    I'm using this little scriptlet to increase the size of the Damage popups in my MZ game.
    However, it effects both the damage popup numbers and the state popups.
    What are "state popups"?
  18. I am trying to write a plugin to rewind time (make events and the player move back a position every time you run the rewind function)
    1. How do I log the player's "event id" or make it return 0 or -1 because right now it logs the player as undefined.
    2. How do I call the function to rewind time from the Game Interpreter (or an event page or common event page)?

    JavaScript:
    var AquaEcho = AquaEcho || {};
    AquaEcho.Rewind = AquaEcho.Rewind || {};
    var AErewindLog=[];
    
    AquaEcho.Rewind.setMovementSuccess = Game_CharacterBase.prototype.setMovementSuccess;
    Game_CharacterBase.prototype.setMovementSuccess= function(success) {
      AErewindLog.unshift([this._eventId, this.x, this.y]); 
    };
    
    AquaEcho.Rewind.reserveTransfer = Game_Player.prototype.reserveTransfer;
      Game_Player.prototype.reserveTransfer = function(mapId, x, y, d, fadeType) {
          AquaEcho.Rewind.reserveTransfer.apply(this, arguments);
          AErewindLog=[];
        };
    
    Game_Interpreter.prototype.rewind() = function(){
      if([AErewindLog[0][0]]<0){
        $gamePlayer.setPosition(AErewindLog[0][1],AErewindLog[0][2]);
      } else {
        this.character[AErewindLog[0][0]].setPosition(AErewindLog[0][1],AErewindLog[0][2]);
      }
      AErewindLog.pop(); 
    }
    1714448996366.png
  19. AquaEcho said:
    1. How do I log the player's "event id"
    You can't because it doesn't have one - the player isn't an event. You could do something someplace to check whether this == $gamePlayer and supply a special value there.

    AquaEcho said:
    2. How do I call the function to rewind time from the Game Interpreter (or an event page or common event page)?
    You have the wrong syntax for your function declaration. Just like the other functions above it, you don't put the parentheses after the function's name (rewind) - they go after the word function.
    Code:
    Game_Interpreter.prototype.rewind = function()
  20. AquaEcho said:
    1. How do I log the player's "event id" or make it return 0 or -1 because right now it logs the player as undefined.
    Since the player isn't an event, it doesn't have an event ID. A quick and dirty solution would be to modify your function like this:
    JavaScript:
    Game_CharacterBase.prototype.setMovementSuccess = function(success) {
      AErewindLog.unshift([this._eventId || 0, this.x, this.y]);
    };

    However, it's really considered to be poor programming practice to be referencing a potentially non-existent descendant property from within the ancestor class like that. Supposing that you want anything that's not an event (i.e. player, followers, and vehicles) to use an ID of 0, and you want events to use their actual event ID, then the most proper solution would be something like this:
    JavaScript:
    AquaEcho.Rewind.Game_CharacterBase_setMovementSuccess = Game_CharacterBase.prototype.setMovementSuccess;
    Game_CharacterBase.prototype.setMovementSuccess = function(success) {
        AErewindLog.unshift([0, this.x, this.y]);
        AquaEcho.Rewind.Game_CharacterBase_setMovementSuccess.call(this, success);
    };
    
    Game_Event.prototype.setMovementSuccess = function(success) {
        AErewindLog.unshift([this._eventId, this.x, this.y]);
        AquaEcho.Rewind.Game_CharacterBase_setMovementSuccess.call(this, success);
    };
    (In your script, you're aliasing the function, but you never actually call the alias. I'm assuming that you intended to call it, so I went ahead and added that in.)

    AquaEcho said:
    2. How do I call the function to rewind time from the Game Interpreter (or an event page or common event page)?
    Does ATT_Turan's syntax correction resolve this question for you, or do need further assistance with it?

    *edit* Corrected an issue with my script.