JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 142 of 171 View original ↗
  1. Mac15001900 said:
    Sure, you'd just need to do that with a script. Use the script command and do
    AudioManager.playSe({ name: 'foldername/filename', volume: 100, pitch: 100});

    There's more details in this spreadsheet, row 935 and 967 are particularly relevant here.
    I'm just getting an error message that it is failing to load. This is in a clean project, too. No plugins enabled.
    1708769613307.png
    It seems like it is treating test/Absorb1 in this scenario as its own entire file within the SE folder, rather than searching for Absorb1 in the test subfolder.
  2. Prescott said:
    I'm just getting an error message that it is failing to load. This is in a clean project, too. No plugins enabled.
    View attachment 296320
    It seems like it is treating test/Absorb1 in this scenario as its own entire file within the SE folder, rather than searching for Absorb1 in the test subfolder.
    RPG Maker, why are you doing this? I have this kind of thing with images in my game, and I assumed that surely audio files are loaded in a similar way. Apparently they're not xD

    Looks like we'll need a simple plugin to make sure it deals with compound paths correctly. Try this:
    JavaScript:
    AudioManager.createBuffer = function (folder, name) {
        var ext = this.audioFileExt();
        var encodedName = name.split('/').map(encodeURIComponent).join('/');
        var url = this._path + folder + '/' + encodedName + ext;
        if (this.shouldUseHtml5Audio() && folder === 'bgm') {
            if (this._blobUrl) Html5Audio.setup(this._blobUrl);
            else Html5Audio.setup(url);
            return Html5Audio;
        } else {
            return new WebAudio(url);
        }
    };
  3. Mac15001900 said:
    RPG Maker, why are you doing this? I have this kind of thing with images in my game, and I assumed that surely audio files are loaded in a similar way. Apparently they're not xD

    Looks like we'll need a simple plugin to make sure it deals with compound paths correctly. Try this:
    JavaScript:
    AudioManager.createBuffer = function (folder, name) {
        var ext = this.audioFileExt();
        var encodedName = name.split('/').map(encodeURIComponent).join('/');
        var url = this._path + folder + '/' + encodedName + ext;
        if (this.shouldUseHtml5Audio() && folder === 'bgm') {
            if (this._blobUrl) Html5Audio.setup(this._blobUrl);
            else Html5Audio.setup(url);
            return Html5Audio;
        } else {
            return new WebAudio(url);
        }
    };
    That did the trick! Thank you so much! You saved a lot of headache for me scrolling through a massive list of SE files lol. I like the amount of granularity this provides me with the volume control as well, so I can fine-tune it here instead of having to open up the audio file.
  4. Prescott said:
    I like the amount of granularity this provides me with the volume control as well, so I can fine-tune it here instead of having to open up the audio file.
    You always had that control. The number you're passing in for "volume" in this script call is the same number you'd type into the event command to play an SE.

    1708783607305.png
  5. ATT_Turan said:
    You always had that control. The number you're passing in for "volume" in this script call is the same number you'd type into the event command to play an SE.

    View attachment 296329
    Oh duh lol. I honestly don't know why I didn't think of that xD You get so used to using the slider. With the script you can make it louder than 100% though, so that's nice :)
    That's some information that requires the "with great power comes great responsibility" disclaimer lol.
  6. In MZ, Is there a script call to check the current scope of a skill?

    I want to create a passive that deals bonus damage only to skills that have target the entire troop.

    If there’s a code that can determine that, it would make things a lot easier.
  7. Lonewulf123 said:
    If there’s a code that can determine that, it would make things a lot easier.
    Game_Actions have a few functions to get the scope (isForOne(), isForAll(), isForUser(), etc.).
    if youre using a visustella passive for it, then you can do something like "this.isForAll() && this.isForOpponenet()" as your condition if you use the right notetag
  8. Robro33 said:
    Game_Actions have a few functions to get the scope (isForOne(), isForAll(), isForUser(), etc.).
    if youre using a visustella passive for it, then you can do something like "this.isForAll() && this.isForOpponenet()" as your condition if you use the right notetag
    Perfect, thank you.
  9. Hello all!

    Most of my characters in the project I'm planning use 'ammo' as a non-traditional form of MP in a sci-fi setting. But I want another character later on to use MP/TP traditionally. The change is entirely cosmetic as they're mechanically similar, and any sort of mechanical differences I can make work through other means.

    But, I still need a way to change the names/cosmetics of HP/MP/TP on a per character basis. I'm guessing this requires javascript based on what I've heard elsewhere, but need help either figuring out how this might look or being pointed in the direction of a plugin that could help. Thank you!
  10. Does anyone know what the js functions are for

    -displaying a message in a battle? Such as the top messages when someone recovers from a state

    -changing an actor's face mid-combat

    It's tied to something I'm doing with a plugin so I don't think the default engine routes are viable here
  11. @Zodai, please avoid double posting, as it is against the forum rules. You can use the "Edit" function on your posts to add additional information you've forgotten or respond to multiple people. You can review our forum rules here. Thank you.

    I assume you're using MZ. If you need help with a plugin, start a new thread in Plugin Support.
    Zodai said:
    But, I still need a way to change the names/cosmetics of HP/MP/TP on a per character basis.
    I think that will need a plugin.

    Without plugins, the others can be done with script calls from the MV / MZ Script Call List. These options might not work depending on the plugins you're using.
    Zodai said:
    displaying a message in a battle
    Show Battle Log Text:
    JavaScript:
    BattleManager._logWindow.addText("Hello!");

    Zodai said:
    changing an actor's face mid-combat
    Set Actor Face Image + Refresh Battle Status:
    JavaScript:
    const actor = $gameParty.members()[0];  // leader
    actor.setFaceImage("Actor1", 0);  // Actor1.png, index 0 (first face)
    $gamePlayer.refresh();
    SceneManager._scene._statusWindow.preparePartyRefresh();  // MZ
  12. caethyril said:
    [dpost]@Zodai[/dpost] I assume you're using MZ. If you need help with a plugin, start a new thread in Plugin Support.

    That will need a plugin.

    Without plugins, the others can be done with script calls from the MV / MZ Script Call List. These options might not work depending on the plugins you're using.

    Show Battle Log Text:
    JavaScript:
    BattleManager._logWindow.addText("Hello!");


    Set Actor Face Image + Refresh Battle Status:
    JavaScript:
    const actor = $gameParty.members()[0];  // leader
    actor.setFaceImage("Actor1", 0);  // Actor1.png, index 0 (first face)
    $gamePlayer.refresh();
    SceneManager._scene._statusWindow.preparePartyRefresh();  // MZ
    whoops, thank you. Since it had been a few days I thought there was an expiration on it, my apologies!

    And thank you for the information!
  13. I’m using Visuatellas battlecore with side view battlers, and I want to disable the animation that has characters walk in at the beginning of a battle, but I can’t seem to find what does that.

    Can someone point me in the right direction?
  14. Scoates said:
    Can someone point me in the right direction?
    Welcome!

    Your question is not asking anything about JavaScript; and, per the first post in the thread, if you're asking about plugins, you should make a new thread in the Plugin Support section.

    When you make that thread, please be detailed in describing what you're asking about, and provide screenshots if possible.

    I just checked out my MZ test project, and I didn't see any different animation at the beginning when I enabled the Battle Core. So make sure that you know how RPG Maker MZ works normally and that your question actually has to do with a plugin.

    Good luck!
  15. Is there anyway to comment out a part of a function through a patch? I find myself overwriting entire functions just to comment out one line and cannot help but feel there has to be a better way...
  16. werzaque said:
    Is there anyway to comment out a part of a function through a patch? I find myself overwriting entire functions just to comment out one line and cannot help but feel there has to be a better way...
    Unfortunately there isn't. Sometimes you can do that by making an alias that undoes whatever that line was doing, e.g. if it changes some value your alias can change it back. But there's nothing that will work for every case.

    This is also why some very simple plugins can look really complicated - they're just overwriting some very long functions :p
  17. werzaque said:
    Is there anyway to comment out a part of a function through a patch? I find myself overwriting entire functions just to comment out one line and cannot help but feel there has to be a better way...
    As Mac15001900 said, you can't exactly comment things out, but you can sometimes find workarounds to achieve a similar effect. For example, say that you want this function to *not* create a 'Save' command:
    JavaScript:
    Window_MenuCommand.prototype.makeCommandList = function() {
        this.addMainCommands();
        this.addFormationCommand();
        this.addOriginalCommands();
        this.addOptionsCommand();
        this.addSaveCommand();
        this.addGameEndCommand();
    };

    Rather than overwriting it and removing the this.addSaveCommand(); line, you could simply leave that line in, and overwrite the Window_MenuCommand.prototype.makeCommandList function so that it's an empty function that does nothing:
    JavaScript:
    Window_MenuCommand.prototype.addSaveCommand = function() { };

    You wind up overwriting a function either way, but this way is less likely to lead to compatibility issues with other plugins.

    For another example, take a look at this function:
    JavaScript:
    Game_CharacterBase.prototype.setPosition = function(x, y) {
        this._x = Math.round(x);
        this._y = Math.round(y);
        this._realX = x;
        this._realY = y;
    };

    Suppose that, for whatever reason, you want it to *not* change the value of this._realX. Instead of overwriting that function and commenting the line out, you could just patch the function and undo the effects of that line afterward:
    JavaScript:
    const _Game_CharacterBase_setPosition = Game_CharacterBase.prototype.setPosition;
    Game_CharacterBase.prototype.setPosition = function(x, y) {
        const tempRealX = this._realX;
        _Game_CharacterBase_setPosition.apply(this, arguments);
        if (this._realX !== tempRealX) {
            this._realX = tempRealX;
        }
    };

    It's not any less work, but it has the potential to play nicer with other plugins. Pretty frequently, you can find workarounds such as these. But sometimes you just can't avoid overwriting a function. It's something that can only be determined on a case by case basis.
  18. Thank you both! Very clear!
  19. I need any easy way to count the number of states a target has within a certain state category (using Visustella skill and state core)

    Is there any code that’s like user.state_category(“buffs”).length?
  20. @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.