JavaScript questions that don't deserve their own thread

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.
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?
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.
@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
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.
@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?
@Vis_Mage @Lanzy Yes, and you can use BattleManager._action._item._dataClass to check the type.

Code:
BattleManager._action._item._dataClass === 'skill'
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)?
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?
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.
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
Is it possible to drawChildAt underneath showPicture images?
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?
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.
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?
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.
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);
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.
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?
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.

Original thread: https://forums.rpgmakerweb.com/threads/javascript-questions-that-dont-deserve-their-own-thread.46341/