What's the script call for returning an enemy's name?

Animebryan

Need more resources!
Veteran
Joined
Jul 31, 2012
Messages
444
Reaction score
226
First Language
English
Primarily Uses
RMMZ
I'm using SumRndmDde's HUD Maker plugin & I'm trying to show text that returns a enemy's name based on its Enemy Index position. So far, the RMMV Script Call list shows $gameTroop.members()[enemyIndex] in reference to enemies but how do I use this to show an enemy's name based on its index?

HUD Maker.png
This is what's being used on the screen:
Code:
$gameTroop.members()[0].name()
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
You have the correct script call.

I'm not familiar with the SRD HUD Maker, do you have to tell it somewhere that it's a Javascript eval?

For the future, if you press F8 to open the Console, you can test any script commands to see if they work or not.
upload_2019-5-18_16-27-48.png
 

Animebryan

Need more resources!
Veteran
Joined
Jul 31, 2012
Messages
444
Reaction score
226
First Language
English
Primarily Uses
RMMZ
I'm not familiar with the SRD HUD Maker, do you have to tell it somewhere that it's a Javascript eval?
HUD Maker 2.png
I used it in the Developer Tools & it does return the name 'Slime', but its not working in the HUD Maker. I wonder if the HUD Maker isn't able to properly use all script calls. This is the only method I can think of to return an enemy's name & show it like this.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,100
Reaction score
13,705
First Language
English
Primarily Uses
RMMV
$gameTroop.members()[enemyIndex].enemy().name

$gameTroop.members()[id] gives you the enemy object, but that does not have a name. The name is on the database object, which is retrieved by the enemy() function.
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
$gameTroop.members()[id] gives you the enemy object, but that does not have a name. The name is on the database object, which is retrieved by the enemy() function.
Just wondering, did you see my screenshot?

@Animebryan
After reading through the plugin, it looks like the author is making use of template strings.

More info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

That means that for any value you want to evaluate as Javascript, needs to be surrounded with ${value}

So in your case:
Code:
${$gameTroop.members()[0].name()}
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,093
Reaction score
1,509
First Language
EN
Primarily Uses
RMMZ
:kaohi: I think you have to put evals inside ${} for SRD's HUD Maker? Try this:
Code:
${$gameTroop.members()[0].name()}
name() will include the letter (e.g. Bat A, Bat B ); if you want to avoid that then try originalName() instead~

Edit: ninja'd! :kaoback:
 

Animebryan

Need more resources!
Veteran
Joined
Jul 31, 2012
Messages
444
Reaction score
226
First Language
English
Primarily Uses
RMMZ
Yup! That did the trick, which is odd because the requirement to use that is inconsistent. Some hud elements need it, some don't. Now I just need script calls to check to see if actors & enemies exist in battle. 2nd & 3rd party members HUDs should only show if there is in fact a 2nd & 3rd member in the party. Same for enemy indexes too. Enemy index 1 & 2 (2nd & 3rd enemies as well).
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
For those elements, you can use a condition for whether it shows or not.

Easiest way would be to use the bang bang operator (that's not an official term) to check whether things exist or not.

So for enemies:
Code:
!!$gameTroop.members()[1] // for the 2nd enemy *true* if it exists and *false* if it does not exist
For party battle members:
Code:
!!$gameParty.battleMembers()[1] // for the 2nd party member *true* if it exist and *false* if it does not exist
 

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

Latest Threads

Latest Posts

Latest Profile Posts

I should realize that error was produced by a outdated version of MZ so that's why it pop up like that
Ami
i can't wait to drink some ice after struggling with my illness in 9 days. 9 days is really bad for me,i can't focus with my shop and even can't do something with my project
How many hours have you got in mz so far?

A bit of a "sparkle" update to the lower portion of the world map. :LZSexcite:
attack on titan final season is airing tomorrow, I'm excited and scared at the same time!

Forum statistics

Threads
105,882
Messages
1,017,231
Members
137,607
Latest member
Maddo
Top