JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 108 of 171 View original ↗
  1. @Arthran you made a small typo in your code, you use first && and than & instead of also && :p
  2. ShadowDragon said:
    @Arthran you made a small typo in your code, you use first && and than & instead of also && :p
    Oops, thanks for pointing that out. I've got it edited now.
  3. I am trying to identify which actor an item is being used on. What I have done previously is put the code in the damage formula of the item, and have that item call up a common event which does the business. In case there's any query about how I'm calling the c.e., here is the command - straightforward bog standard method.
    1659515256251.png

    For the formula I have tried both

    $gameVariables[27] = b.id; 0
    and

    $gameVariables.value[27] = b.id; 0

    When selected and used on an actor nothing happens, the console shows 'null' and the item is consumed.
    I have a text check on the common event to see if it is being called, and that check never shows, so it looks as if the whole thing is aborted at the start of the process.

    Can anyone offer advice on what code to use for this purpose?

    Thanks
  4. Kes said:
    I am trying to identify which actor an item is being used on. What I have done previously is put the code in the damage formula of the item, and have that item call up a common event which does the business. In case there's any query about how I'm calling the c.e., here is the command - straightforward bog standard method.
    View attachment 236511

    For the formula I have tried both

    $gameVariables[27] = b.id; 0
    and

    $gameVariables.value[27] = b.id; 0

    When selected and used on an actor nothing happens, the console shows 'null' and the item is consumed.
    I have a text check on the common event to see if it is being called, and that check never shows, so it looks as if the whole thing is aborted at the start of the process.

    Can anyone offer advice on what code to use for this purpose?

    Thanks
    You actually don't need JavaScript for that, and you don't need to do anything with the damage formula. MZ has a built-in way to obtain this information: Control Variables -> Game Data -> Last -> Last Target Actor ID

    But if you do prefer to access it via script call, then: $gameTemp.lastActionData(4)
  5. @Arthran I hadn't noticed that 'Last...' had been added since Ace. It seems I have more exploring of the event commands to do than I had thought.

    This worked perfectly. Thank you very much.
  6. Does anyone know any plugins that let you use message bubbles besides Galv's MessageStyles? I'm working on an update to a word-wrapper plugin that I want to have compatible with that kind of plugin. It works fine with Galv's, and I'd like to consider adding support for others.
  7. What is wrong with this code? (Yanfly buff & States)

    Code:
    <Custom Apply Effect>
    if(user.actorId==2)origin.addState(105);
    </Custom Apply Effect>

    if the actor id is 2, it should add State 105 to the caster of the state, but it doesn't do anything :(
  8. stramin said:
    What is wrong with this code? (Yanfly buff & States)
    actorId is a function, so it needs parentheses after it: user.actorId()
  9. Thank you so much!

    problem solved
  10. I don't believe this would need its own thread, but if I'm wrong please let me know. I've been trying to mess with how Escape and Defeat is handled in the javascript code. I searched for awhile and found out how to remove the text box that appears when you successfully escape/when you are defeated. However, I wanna go a bit further. For the Defeat function, I want it to not display a text notifying the player that an actor has fallen. I want to then set it up so when the last actor of the party has fallen, the screen flashes once and it waits 60 frames before going to the game over screen. I know how to get the screen flash to work, but I couldn't figure out how to implement the code to wait until the flash stopped before moving to the game over screen.

    JavaScript:
    BattleManager.processDefeat = function() {
        $gameScreen.startFlash([255, 0, 0, 225], 60);
        if (this._canLose) {
            this.replayBgmAndBgs();
        } else {
            AudioManager.stopBgm();
        }
        this.endBattle(2);
    };

    This is the code I have that allows the screen to flash, but it happens after announcing the final actor has fallen. I want it to happen when the final actor falls, and without displaying the message they've fallen (currently I only have one actor in this project, but I plan to use this method of defeat/escape in future projects too.) So the questions I am asking are how to make the flash happen when the final actor falls instead of afterwards, how to remove the message saying they've fallen, and how do I make it wait 60 frames before moving to the game over screen once the party is defeated?
  11. Does someone know what the syntax would be for checking the scope of a skill in Yanfly's Buffs and States plugin?

    Basically I have coded a "cover ally" state which redirects damage aimed at the actor with the state to the actor who applied the state. I would like to include a conditional before the damage redirection that checks whether the scope of the attack is multi targeting or not (and if so, not redirect damage).

    Code:
    <Custom React Effect>
    if (SCOPE OF USED SKILL IS NOT MULTI TARGETING) {
      var dmg = value
      origin.gainHp(-dmg);
      origin.startDamagePopup();
      origin.clearResult();
      value = 0
    }
    </Custom React Effect>
  12. Nate_Tillern said:
    Does someone know what the syntax would be for checking the scope of a skill
    Checking if (this.isForOne()) will return true if it's a single-target scope.
  13. Hi, I'm trying to change the code to not interrupt the battle BGM when I don't set any ME victory.
    I tried to change some things in "rpg_managers.js" and "rpg_scenes" but I can't get the desired result.
    I belive that somewhere in the code there's a piece of code that blocks my battle BGM when I win, but I just can't find it!
    What I managed to find is the line that makes me start the ME victory and I will take a conditional branch to activate or exclude it based on a switch (or, even better, if the system does not find any ME set in the database).
    All this to ensure that in some maps (not all) there is no audio transition between map and battle.
    I apologize for any spelling mistakes, I'm not very good at English but I always try to improve... :kaoswt2:
  14. UmbrotheUmbreon said:
    I don't believe this would need its own thread, but if I'm wrong please let me know. I've been trying to mess with how Escape and Defeat is handled in the javascript code. I searched for awhile and found out how to remove the text box that appears when you successfully escape/when you are defeated. However, I wanna go a bit further. For the Defeat function, I want it to not display a text notifying the player that an actor has fallen. I want to then set it up so when the last actor of the party has fallen, the screen flashes once and it waits 60 frames before going to the game over screen. I know how to get the screen flash to work, but I couldn't figure out how to implement the code to wait until the flash stopped before moving to the game over screen.

    JavaScript:
    BattleManager.processDefeat = function() {
        $gameScreen.startFlash([255, 0, 0, 225], 60);
        if (this._canLose) {
            this.replayBgmAndBgs();
        } else {
            AudioManager.stopBgm();
        }
        this.endBattle(2);
    };

    This is the code I have that allows the screen to flash, but it happens after announcing the final actor has fallen. I want it to happen when the final actor falls, and without displaying the message they've fallen (currently I only have one actor in this project, but I plan to use this method of defeat/escape in future projects too.) So the questions I am asking are how to make the flash happen when the final actor falls instead of afterwards, how to remove the message saying they've fallen, and how do I make it wait 60 frames before moving to the game over screen once the party is defeated?
    You may try working with this:

    Code:
    Game_Actor.prototype.performCollapse = function() {
        Game_Battler.prototype.performCollapse.call(this);
        if ($gameParty.inBattle()) {
            SoundManager.playActorCollapse();
        }
    };
    (note: this is from MZ, but MV should have a similar method inside its rmmv_objects.js file)
  15. RPGMaker MV:
    Want to set variable 15 to be equal to 2nd partymember's actor id.
    pretty sure it something like $gameVariables.setValue(15, something);
  16. Sagi007 said:
    RPGMaker MV:
    Want to set variable 15 to be equal to 2nd partymember's actor id.
    pretty sure it something like $gameVariables.setValue(15, something);
    Code:
    $gameVariables.setValue(15, $gameParty.members()[1].actorId());

    Also, just to mention it, depending on how you're using this there's no need to use JavaScipt.

    You can use event commands to do Control Variable -> Game Data -> Party -> Member #2
  17. Arctica said:
    You may try working with this:

    Code:
    Game_Actor.prototype.performCollapse = function() {
        Game_Battler.prototype.performCollapse.call(this);
        if ($gameParty.inBattle()) {
            SoundManager.playActorCollapse();
        }
    };
    (note: this is from MZ, but MV should have a similar method inside its rmmv_objects.js file)

    I found the code and it did what I wanted with actor collapsing and playing the screen flash. Now I am struggling with the defeat scene being handled. I want it to wait ten frames before fading the BGM, then wait 60 frames to move to the Game Over screen.

    JavaScript:
    BattleManager.processDefeat = function() {
        if (this._canLose) {
            this.replayBgmAndBgs();
        } else {
            interpreter.wait(10);
            AudioManager.stopBgm();
            interpreter.wait(60);
        }
        this.endBattle(2);
    };

    I feel like I'm missing something with how I'm adding wait time into the coding. I get a reference error saying "interpreter is not defined" so I must be leaving out something. The problem is I don't know what
  18. Try $gameMap._interpreter instead.
  19. eomereolsson said:
    Try $gameMap._interpreter instead.
    So it no longer gives me an error, but I set the wait time to be 600 frames (to make sure it actually worked), and it doesn't. It still just goes right to the game over screen without waiting at all.

    I probably should clarify the battle system I'm using a bit more. It's typical side view turn based RPG that uses a battle background.
  20. Oh sorry, I kind of missed the part where we are talking about battle. My script call is a valid interpreter (hence no error) but not the currently running one (hence no effect).
    Try $gameTroop._interpreter instead.