JavaScript questions that don't deserve their own thread

Vis_Mage

Novice Magician
Veteran
Joined
Jul 28, 2013
Messages
533
Reaction score
183
First Language
English
Primarily Uses
RMMV
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.
 

Lanzy

Veteran
Veteran
Joined
Feb 29, 2020
Messages
106
Reaction score
46
First Language
English
Primarily Uses
RMMV
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?
 

Vis_Mage

Novice Magician
Veteran
Joined
Jul 28, 2013
Messages
533
Reaction score
183
First Language
English
Primarily Uses
RMMV
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.
 

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
845
First Language
English
Primarily Uses
RMMV
@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
 

Lanzy

Veteran
Veteran
Joined
Feb 29, 2020
Messages
106
Reaction score
46
First Language
English
Primarily Uses
RMMV
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.
 

Attachments

Lanzy

Veteran
Veteran
Joined
Feb 29, 2020
Messages
106
Reaction score
46
First Language
English
Primarily Uses
RMMV
@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?
 

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
845
First Language
English
Primarily Uses
RMMV
@Vis_Mage @Lanzy Yes, and you can use BattleManager._action._item._dataClass to check the type.

Code:
BattleManager._action._item._dataClass === 'skill'
 

Vis_Mage

Novice Magician
Veteran
Joined
Jul 28, 2013
Messages
533
Reaction score
183
First Language
English
Primarily Uses
RMMV
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)?
 

Lanzy

Veteran
Veteran
Joined
Feb 29, 2020
Messages
106
Reaction score
46
First Language
English
Primarily Uses
RMMV
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?
 

MikeMakes

Veteran
Veteran
Joined
Sep 30, 2015
Messages
184
Reaction score
44
First Language
English
Primarily Uses
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.
 

Lanzy

Veteran
Veteran
Joined
Feb 29, 2020
Messages
106
Reaction score
46
First Language
English
Primarily Uses
RMMV
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
 

lionex

Villager
Member
Joined
Nov 13, 2016
Messages
6
Reaction score
1
First Language
English
Primarily Uses
RMMV
Is it possible to drawChildAt underneath showPicture images?
 

Lanzy

Veteran
Veteran
Joined
Feb 29, 2020
Messages
106
Reaction score
46
First Language
English
Primarily Uses
RMMV
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?
 

lionex

Villager
Member
Joined
Nov 13, 2016
Messages
6
Reaction score
1
First Language
English
Primarily Uses
RMMV
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.
 

Lanzy

Veteran
Veteran
Joined
Feb 29, 2020
Messages
106
Reaction score
46
First Language
English
Primarily Uses
RMMV
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?
 

lionex

Villager
Member
Joined
Nov 13, 2016
Messages
6
Reaction score
1
First Language
English
Primarily Uses
RMMV
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.
 

Lanzy

Veteran
Veteran
Joined
Feb 29, 2020
Messages
106
Reaction score
46
First Language
English
Primarily Uses
RMMV
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);
 

lionex

Villager
Member
Joined
Nov 13, 2016
Messages
6
Reaction score
1
First Language
English
Primarily Uses
RMMV
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.
 

meowengine

Villager
Member
Joined
Jun 13, 2020
Messages
14
Reaction score
18
First Language
English
Primarily Uses
N/A
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?
 

Lanzy

Veteran
Veteran
Joined
Feb 29, 2020
Messages
106
Reaction score
46
First Language
English
Primarily Uses
RMMV
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.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 3)

Latest Threads

Latest Posts

Latest Profile Posts

I guess if you're just going solo dev, minimize features is better choice.
As close as possible, now I draw all of them with little by little needle sticking.
Welp, back to the drawing board...
Ami
--- Overused ---

Hero: (Drink 3 HP Bottle L)
F.Healer: Don't drink too much,or you got sick!
Hero: Nah,i'm okay. it's the way to repleni---
(Hero Collapse)
Hero: (Weak) Ugh...my head (Coughing Then Vomiting)
F.Healer: I told you to don't Drink 3 HP Bottle L or you're Sick. Let's go to Doctor.
Shaking off the dust. Clearing the cobwebs. Time to get back to gam-mak!

Forum statistics

Threads
103,214
Messages
998,047
Members
134,692
Latest member
Matkacharts
Top