JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 141 of 171 View original ↗
  1. werzaque said:
    it really wasn't obvious to me that it assumes "a" or "actor" or whatever you decide to call it as a return value. That part still feels like magic to me.
    Okay...that's why I linked you to the documentation that explicitly explains that's how it works. I don't know why you'd Sad the response with the correct, technical information. There's no assumption, no magic, just the expected syntax.
  2. ATT_Turan said:
    Okay...that's why I linked you to the documentation that explicitly explains that's how it works.
    The sad face was because I had already read through those exact pages before posting and (apparently) didn't get it. I guess I'll just have to let it sink in... the concept of a function running a function it is fed and somehow understanding that one of the arguments (the index of the array) comes from "upstream"...
  3. Admittedly programming documentation can be difficult for us normies to parse sometimes. I tried reading the Unity and C# documentation and after reading "the..." my head was already about to explode.

    RTFM is great and all, but sometimes people's brains aren't wired very well for understanding some of the concepts. I suppose to use a pretentious teacher term; some people are more kinesthetic learners.
  4. werzaque said:
    The sad face was because I had already read through those exact pages before posting and (apparently) didn't get it. I guess I'll just have to let it sink in... the concept of a function running a function it is fed and somehow understanding that one of the arguments (the index of the array) comes from "upstream"...
    It might help to picture how some() might be implemented (this is a simplified version that doesn't account for optional parameters):
    JavaScript:
    Array.prototype.some = function(testElementFunction) {
        for (let i = 0; i < this.length; i++) {
            if (testElementFunction(this[i])) {
                return true;
            }
        }
        return false;
    };

    Since I'm typing this on my phone, at bed time, it might contain errors. But as you can maybe see, the some() method doesn't know or care what you name the element parameter in your callback function--it simply calls the function, using each element as an argument. Whatever you choose to name the parameter is just for your own convenience.
  5. TheAM-Dol said:
    but sometimes people's brains aren't wired very well for understanding some of the concepts.
    To add a bit to it: functional programming is hard y'all. The concept of functions being used as arguments for other function is fairly intuitive once you're used to it, but it can be really tricky to wrap your head around the first time you encounter it (and especially if your source is just documentation which assumes you're already familiar with the concept).

    @werzaque please don't get discouraged if you find this confusing, that's just because it is ;)
  6. Arthran said:
    Since I'm typing this on my phone, at bed time, it might contain errors.
    Mac15001900 said:
    @werzaque please don't get discouraged if you find this confusing, that's just because it is ;)

    Thanks both, I'm feeling I'm closing in on where the problem in my brain wiring lies. :kaohi:Rereading all this I also realized that my understanding of the this keyword is not solid. Hence I can't picture in my head how the "passing on" is happening with a function in a function and with this referencing the initial "invoker" of the function. I'll just munch on it for some time and hope it sinks in at some point.
    Mac15001900 said:
    functional programming is hard y'all.
    It is...
  7. Edited: I found this feature in the core engine.

    Previously, I tried to find this feature in the Skill States Core and from the first layer, but I never considered the possibility that it existed in the core engine.

    Deeply sorry for my such careless mistake.


    The mistaken question.
    Spoiler
    Can the functionality provided by the Visu Skill States Core be used to create states that change character attributes based on the duration of the state? For example, I'm interested in increasing the attack power by 50% multiplied by the number of turns the state lasts, and removing these effects when the state is erased or expires.

    If this is feasible, how can it be scripted?

    Additionally, I've noticed a potential issue. Suppose a state A adds 50% to a character's attack power using this method, and before state A is removed, the character is affected by a new state B that doubles the attack power. Can the removal of state A correctly handle the changes brought by state B when it eliminates its own effects?

    Quoted from Visu Skill States Core:


    JavaScript Notetags: On Add/Erase/Expire​

    Using JavaScript code, you can use create custom effects that occur when a state has bee added, erased, or expired.

    ---

    <JS On Add State>
    code
    code
    </JS On Add State>

    - Used for: State Notetags
    - When a state is added, run the code added by this notetag.
    - The 'user' variable refers to the current active battler.
    - The 'target' variable refers to the battler affected by this state.
    - The 'origin' variable refers to the one who applied this state.
    - The 'state' variable refers to the current state being affected.

    ---

    <JS On Erase State>
    code
    code
    </JS On Erase State>

    - Used for: State Notetags
    - When a state is erased, run the code added by this notetag.
    - The 'user' variable refers to the current active battler.
    - The 'target' variable refers to the battler affected by this state.
    - The 'origin' variable refers to the one who applied this state.
    - The 'state' variable refers to the current state being affected.

    ---

    <JS On Expire State>
    code
    code
    </JS On Expire State>

    - Used for: State Notetags
    - When a state has expired, run the code added by this notetag.
    - The 'user' variable refers to the current active battler.
    - The 'target' variable refers to the battler affected by this state.
    - The 'origin' variable refers to the one who applied this state.
    - The 'state' variable refers to the current state being affected.
  8. @catxiaolang per the first post of this thread, it's not really for getting help with plugins; as your answer may be more about the notetags offered by those plugins rather than any JavaScript.

    You might be better off asking in:
    The official VisuStella notetag help thread
    catxiaolang said:
    Additionally, I've noticed a potential issue. Suppose a state A adds 50% to a character's attack power using this method, and before state A is removed, the character is affected by a new state B that doubles the attack power.
    This is exactly why the notetags you list aren't going to be solutions for you. The On Add code will be run one time, when the state is first applied.

    The VisuStella Core Engine can change how parameters are calculated, as can Hakuen Studio Dynamic Parameters.
  9. ATT_Turan said:
    @catxiaolang per the first post of this thread, it's not really for getting help with plugins; as your answer may be more about the notetags offered by those plugins rather than any JavaScript.

    You might be better off asking in:
    The official VisuStella notetag help thread

    This is exactly why the notetags you list aren't going to be solutions for you. The On Add code will be run one time, when the state is first applied.

    The VisuStella Core Engine can change how parameters are calculated, as can Hakuen Studio Dynamic Parameters.
    Okay, thank you for the reminder.
  10. 1. How do I check if an actor has a state that has restriction: 'cannot move' during battle?
    2. Is $gameTroop.turnCount() accurate for counting battle turns in Time Progress Wait?
  11. In rmmz_objects I see

    JavaScript:
    Game_BattlerBase.prototype.canMove = function() {
        return this.isAppeared() && this.restriction() < 4;
    };

    So I would suspect $gameParty.members()[x].canMove() would do it.
  12. Fionn23 said:
    2. Is $gameTroop.turnCount() accurate for counting battle turns in Time Progress Wait?
    How do you mean? That is the function that troop events reference, if that's your point of comparison.

    If you Google it, you'll find this article that describes what the different kinds of turns are in Time Progress and how they're calculated:
    RPG Maker MZ, Preview #5: TPBS, A Closer Look
  13. ATT_Turan said:
    How do you mean? That is the function that troop events reference, if that's your point of comparison.

    If you Google it, you'll find this article that describes what the different kinds of turns are in Time Progress and how they're calculated:
    RPG Maker MZ, Preview #5: TPBS, A Closer Look
    I just want to count the turns passed in a Time Progress (Wait) Battle. Thanks for this.
  14. Fionn23 said:
    I just want to count the turns passed in a Time Progress (Wait) Battle. Thanks for this.
    For whom? The individual or the battle turn count ? Please read the thread @ATT_Turan has linked to if you are unsure.

    If you want the battle turncount, it's $gameTroop.turnCount(), otherwise I think it should be $gameParty.members()[x].tpbTurnCount, judging from the below in rmmz_objects.js:

    JavaScript:
    Game_Battler.prototype.turnCount = function() {
        if (BattleManager.isTpb()) {
            return this._tpbTurnCount;
        } else {
            return $gameTroop.turnCount() + 1;
        }
    };

    EDIT: oh wait, if you're using TPB $gameParty.members()[x].turnCount will automatically give you the individual turn count... doh!
    EDIT2: I just confirmed this in a playtest, but as the code suggests you need to add 1 to get the battle turn count as it starts at 0, so $gameTroop.turnCount() + 1.
  15. Is there anyway to get rid of the "game end" option in the main menu with JS?
  16. I think just a matter of overwriting the relevant function in rmmz_windows.js (or rpg_windows.js):

    JavaScript:
    (function() {
        'use strict';
        Window_MenuCommand.prototype.makeCommandList = function() {
        this.addMainCommands();
        this.addFormationCommand();
        this.addOriginalCommands();
        this.addOptionsCommand();
        this.addSaveCommand();
    //    this.addGameEndCommand();
    };
    })();
  17. werzaque said:
    I think just a matter of overwriting the relevant function in rmmz_windows.js (or rpg_windows.js):

    JavaScript:
    (function() {
        'use strict';
        Window_MenuCommand.prototype.makeCommandList = function() {
        this.addMainCommands();
        this.addFormationCommand();
        this.addOriginalCommands();
        this.addOptionsCommand();
        this.addSaveCommand();
    //    this.addGameEndCommand();
    };
    })();
    Thanks, I'll try it out.
  18. Or just make that method do nothing:
    JavaScript:
    Window_MenuCommand.prototype.addGameEndCommand = function() {};
  19. With RPG Maker MV, is it possible to play Sound Effects from a subfolder?
    I have a pretty good amount of voice acting files and it would be SO nice to sort them into subfolders. I know MZ has this capability baked into the engine, but is there perhaps a script call I can use for MV? Or a plugin, by chance?
  20. Prescott said:
    With RPG Maker MV, is it possible to play Sound Effects from a subfolder?
    I have a pretty good amount of voice acting files and it would be SO nice to sort them into subfolders. I know MZ has this capability baked into the engine, but is there perhaps a script call I can use for MV? Or a plugin, by chance?
    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.