JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 11 of 171 View original ↗
  1. That's weird... how can I detect that when I am in paying the cost of the skill? Because I want to change that too:

    Code:
    Game_BattlerBase.prototype.paySkillCost = function(skill) {   this._tp -= this.skillTpCost(skill);    if (this instanceof Game_Actor && $dataClasses[this.currentClass].note.match(/<\s*reverse\s*>/im)) {        this._hp -= this.skillMpCost(skill);    } else {        this._mp -= this.skillMpCost(skill);    }   };
  2. currentClass is a function, so you'll have to write "this.currentClass()". Also, this example is different, because you are using a logical AND "&&", instead of an OR "||".
  3. I determined that the actor should be the only ones checked with it since they're the only one with class. A new error appears though, it says it doesn't know the note of an undefined value. I am guessing the this where the currentclass is getting itself at is blank. Any ideas how to make it work properly?
  4. "currentClass" returns the class object itself, so you don't have to do a manual lookup in $dataClasses. Your

    if (this instanceof Game_Actor && $dataClasses[this.currentClass].note.match(/<\s*reverse\s*>/im)) {can be rewritten as

    Code:
    if (this instanceof Game_Actor && this.currentClass().note.match(/<\s*reverse\s*>/im)) {
  5. Thanks, it works properly! <3
  6. actually nevermind.  figured that out.  new question though.  Is there any easy way to change what parameters are shown on the equip screen?  I'd like something different than the basic stats there. 
  7. I've got some questions about invoking time. How do you exactly let the engine wait for a few seconds before another function is executed? By example, what I do is to create a loop of thousand values. I will make a loop from say 1 to 19000 just to let the loop start and wait a few millisecond / second before the function is executed. What is the best way for me to wait for a few seconds? I want to generate that.
  8. err, I should say:

    this.currentClass().note.match(/<\s*reverse\s*>/imshould be:

    this.currentClass().meta.reverseNotetags are precompiled on mv :p
  9. Milena said:
    I've got some questions about invoking time. How do you exactly let the engine wait for a few seconds before another function is executed? By example, what I do is to create a loop of thousand values. I will make a loop from say 1 to 19000 just to let the loop start and wait a few millisecond / second before the function is executed. What is the best way for me to wait for a few seconds? I want to generate that.
    Don't do this, it will use up your CPU to 100% and prevent the user from doing anything.

    The correct way would be to add a "wait" property to your plugin and decrement it during every update. Once it reaches 0, you can continue, like this:

    Code:
    function update() {    if(this.wait && this.wait-- > 0) { return; }    // do stuff}
  10. Iavra said:
    Don't do this, it will use up your CPU to 100% and prevent the user from doing anything.

    The correct way would be to add a "wait" property to your plugin and decrement it during every update. Once it reaches 0, you can continue, like this:

    function update() { if(this.wait && this.wait-- > 0) { return; } // do stuff}
    Should I place the function outside of all the classes? If I remember correctly, this.wait is from Game_Interpreter. It does work outside as well?
  11. No, this will only work in classes, that have an update function, which is called every frame. The property doesn't need to be called "wait", you can name it anyway you want.
  12. I see. So for example my wait method is like 10. So it gets decreased every update. If I do something like this:

    if(this._maxwait != 0){ this._maxwait--;} else { this._maxwait = 0;}will this work properly? I am thinking this would be way too fast.
  13. 1 second == 60 frames by default, I think.

    So maxwait of 10 will make it wait 1/6 of a second.
  14. KockaAdmiralac said:
    1 second == 60 frames by default, I think.
    Yes 1 s = 60 fps, with the TTPD fluent script there are always 60 updates per second (no matter the frame rate), so that may be even better to use.
  15. I want to know how to change maximum values over time. For example, if I have x state, I want my max hp to become my current hp. I have this as an example:

    Spoiler
    Scene_Battle.prototype.update = function() { var active = this.isActive(); $gameTimer.update(active); $gameScreen.update(); this.updateStatusWindow(); this.updateWindowPositions(); if (active && !this.isBusy()) { this.updateBattleProcess(); } Scene_Base.prototype.update.call(this); for (var i = 0; i <= $gameParty.battleMembers.length; i++){ if ($gameParty.battleMembers()._states.contains(12)) { $gameParty.battleMembers().mhp = $gameParty.battleMembers().hp; } }}; 

    But it doesn't work.
  16. Milena said:
    I want to know how to change maximum values over time. For example, if I have x state, I want my max hp to become my current hp. I have this as an example:

    Spoiler
    Scene_Battle.prototype.update = function() { var active = this.isActive(); $gameTimer.update(active); $gameScreen.update(); this.updateStatusWindow(); this.updateWindowPositions(); if (active && !this.isBusy()) { this.updateBattleProcess(); } Scene_Base.prototype.update.call(this); for (var i = 0; i <= $gameParty.battleMembers.length; i++){ if ($gameParty.battleMembers()._states.contains(12)) { $gameParty.battleMembers().mhp = $gameParty.battleMembers().hp; } }}; 
    Spoiler


    But it doesn't work.


    It's because you can't change MaxHP like that.

    With

    $gameParty.battleMembers().mhp

    you're accessing the getter for MaxHP.

    Try

    $gameParty.battleMembers().addParam(0, $gameParty.battleMembers()[i].hp);

    instead.

    But that the MaxHP will stay at that value even after battle.
  17. It works now but it made my HP 999999
  18. Milena said:
    It works now but it made my HP 999999
    That's weird.

    Then try

    $gameParty.battleMembers()._paramPlus[0] += $gameParty.battleMembers()[i].hp;

     

    directly.
  19. It still makes it 9999. I tried doing:

    $gameParty.battleMembers()._paramPlus[0] = $gameParty.battleMembers().hp;and its not showing the current hp value. Something's wrong.
  20. Milena said:
    It still makes it 9999. I tried doing:

    $gameParty.battleMembers()._paramPlus[0] = $gameParty.battleMembers().hp;
    and its not showing the current hp value. Something's wrong.
     

    Hmm... then I'm out of ideas.

    Normally addParam or _paramPlus[0] += XX works.

    For example to increase a stat permanently like in Yanflys Tips & Tricks Video here:






     

    Could you upload your project or just the script?

    I would look over it again after I've got a little sleep. :D

     

     

    /EDIT:

    Okay.

    Now that I got a little rest I have to correct something,

    because I know why the HP went that high with the two statements I gave you. >_>

    It's is because everytime your update function gets called (and that is very often)

    your actor gets a plus on top of his hp until it reaches the default maximum off 999999.

    Silly me :D

    But I don't know why your last approach didn't work, yet.