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

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()
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
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.
$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.
$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()}
👋 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! 👋
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).
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
$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.
Hi, I tried this with my own project, but I can't seem to get a name result. Is there something wrong with the formatting or an extra step I should take? I know this thread is old, but I came across this same exact issue and wanted to know how to fix.
1734423319588.png
Is there something wrong with the formatting or an extra step I should take?
any value you want to evaluate as Javascript, needs to be surrounded with ${value}
I think you have to put evals inside ${}
Oh thank you, this is getting somewhere. I'm sure the answer is already within this somehow, but is there a way for me to just get the name of whatever enemy the cursor is selected at that moment in time? Would the code be different for this?
try
Code:
${SceneManager._scene._enemyWindow.active ? SceneManager._scene._enemyWindow.enemy().name() : ""}
try
Code:
${SceneManager._scene._enemyWindow.active ? SceneManager._scene._enemyWindow.enemy().name() : ""}
1734429438544.png

No luck, sorry to say. Edit: hold on, IT WORKED !!! Thank you a ton.
1734429539281.png
Necro-post notice: @emma_watson

Original thread: https://forums.rpgmakerweb.com/threads/whats-the-script-call-for-returning-an-enemys-name.109140/