JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 74 of 171 View original ↗
  1. Vis_Mage said:
    Are there any script calls I can use to store the last Skill ID used, and the last actor/enemy ID to have acted? Ideally, I would use these in a common event directly after the skill is used.

    I'm assuming you are talking about a battle. Do you mean the last actor/enemy to perform any kind of action during battle? If so, you want to recall the IDs in a common event during the battle?
  2. Lanzy said:
    I'm assuming you are talking about a battle. Do you mean the last actor/enemy to perform any kind of action during battle? If so, you want to recall the IDs in a common event during the battle?

    Yep, in battle. And to be more specific, I have certain skills that trigger a common event upon use in battle. I'd only need the variables to be set to the skill ID and actor/enemy ID of the most recent action in battle.
  3. @Vis_Mage You can use the following the nab the database ID of the skill that called the common event :

    Code:
    BattleManager._action._item._itemId


    EDIT:
    Code:
    // Actor ID
    BattleManager._action._subjectActorId + 1
    
    // Enemy ID
    BattleManager._action._subjectEnemyIndex
  4. Vis_Mage said:
    Yep, in battle. And to be more specific, I have certain skills that trigger a common event upon use in battle. I'd only need the variables to be set to the skill ID and actor/enemy ID of the most recent action in battle.

    Try this plugin. Put it anywhere, it doesn't matter. What it does is it tracks during battle every last skill-, enemy-, and actor-ID. Access the IDs through following script call commands:
    JavaScript:
    $gameParty._lastActorId //for last Actor Id
    $gameParty._lastEnemyId //for last Enemy Id
    $gameParty._lastSkillId //for last Skill Id

    This should work. Let me know if this is what you needed.
  5. Ossra said:
    @Vis_Mage You can use the following the nab the database ID of the skill that called the common event :

    Code:
    BattleManager._action._item._itemId


    EDIT:
    Code:
    // Actor ID
    BattleManager._action._subjectActorId + 1
    
    // Enemy ID
    BattleManager._action._subjectEnemyIndex

    I guess that should work too lol

    Edit:
    Isn't there the possibility for the item id to be a non-skill id?
  6. @Vis_Mage @Lanzy Yes, and you can use BattleManager._action._item._dataClass to check the type.

    Code:
    BattleManager._action._item._dataClass === 'skill'
  7. Thank you both for the help!

    @Lanzy
    Thank you for the plugin! Works great on a fresh project! There seems to be a comparability issue with something in my main project that causes a crash, but I'll have to figure that out on my end. I'll edit my comment once I figure out what it is, though.

    @Ossra
    The script calls you listed seem to do the trick, and being able to check the skill/item/etc type will be handy! An additional questing though, is there an additional script call I can use alongside BattleManager._action._subjectEnemyIndex in order to get the enemy database ID (as opposed to the enemy's troop ID)?
  8. Vis_Mage said:
    Thank you both for the help!

    @Lanzy
    Thank you for the plugin! Works great on a fresh project! There seems to be a comparability issue with something in my main project that causes a crash, but I'll have to figure that out on my end. I'll edit my comment once I figure out what it is, though.

    @Ossra
    The script calls you listed seem to do the trick, and being able to check the skill/item/etc type will be handy! An additional questing though, is there an additional script call I can use alongside BattleManager._action._subjectEnemyIndex in order to get the enemy database ID (as opposed to the enemy's troop ID)?

    Can you post a screenshot of the error?
  9. What is the condition script to check if a textbox or choice box is displayed?

    I want to ignore execution of events with a button press if the textbox or choice box is displayed.
  10. MikeMakes said:
    What is the condition script to check if a textbox or choice box is displayed?

    I want to ignore execution of events with a button press if the textbox or choice box is displayed.

    JavaScript:
    $gameMessage._choices.length === 0 // check if there are no choices shown
    $gameMessage._texts.length === 0 // check if there are no texts shown
  11. Is it possible to drawChildAt underneath showPicture images?
  12. lionex said:
    Is it possible to drawChildAt underneath showPicture images?

    I don't quite understand what you mean. What exactly is it that you want to do?
  13. I want to draw a bunch of images underneath the images that appear when showPicture is used. I can't really use lower tier showpictures since the function is too slow so I have to use some other JS way.
  14. lionex said:
    I want to draw a bunch of images underneath the images that appear when showPicture is used. I can't really use lower tier showpictures since the function is too slow so I have to use some other JS way.

    Why don't you just load images via js and not even bother with the clumsy showPicture method?
  15. Lanzy said:
    Why don't you just load images via js and not even bother with the clumsy showPicture method?

    Because that is not what I'm trying to do here.
  16. lionex said:
    Because that is not what I'm trying to do here.

    Do you mean something like this?

    JavaScript:
    var yourSprite = new Sprite();
    yourSprite.bitmap = ImageManager.loadPicture("YourPictureName");
    SceneManager._scene._spriteset.addChildAt(yourSprite, INSERT INDEX);
  17. Lanzy said:
    Do you mean something like this?

    JavaScript:
    var yourSprite = new Sprite();
    yourSprite.bitmap = ImageManager.loadPicture("YourPictureName");
    SceneManager._scene._spriteset.addChildAt(yourSprite, INSERT INDEX);

    It is exactly, thankyou. I had pretty much the exact same code but I was missing the spriteset bit and that is what must have been causing the issues.
  18. Code:
    Window_Base.prototype.drawText = function(text, x, y, maxWidth, align) {
        this.contents.drawText(text, x, y, maxWidth, this.lineHeight(), align);
    };
    
    Window_Base.prototype.drawTextEx = function(text, x, y, width) {
        this.resetFontSettings();
        const textState = this.createTextState(text, x, y, width);
        this.processAllText(textState);
        return textState.outputWidth;
    };

    These 2 methods are in Window_Base (MZ).
    What is the difference between the two?
  19. meowengine said:
    Code:
    Window_Base.prototype.drawText = function(text, x, y, maxWidth, align) {
        this.contents.drawText(text, x, y, maxWidth, this.lineHeight(), align);
    };
    
    Window_Base.prototype.drawTextEx = function(text, x, y, width) {
        this.resetFontSettings();
        const textState = this.createTextState(text, x, y, width);
        this.processAllText(textState);
        return textState.outputWidth;
    };

    These 2 methods are in Window_Base (MZ).
    What is the difference between the two?

    DrawTextEx does what drawText does with the addition of accepting text codes like /n for new line etc.
  20. Lanzy said:
    DrawTextEx does what drawText does with the addition of accepting text codes like /n for new line etc.
    Thanks!
    I was wondering why the Window_Gold glass used DrawTextEx over DrawText and this a lot of sense!