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

Discussion in 'RPG Maker MV' started by Animebryan, May 19, 2019.

  1. Animebryan

    Animebryan Feels like I'm slowly dying! Veteran

    Messages:
    335
    Likes Received:
    153
    Location:
    Marysville, CA
    First Language:
    English
    Primarily Uses:
    RMMV
    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()
     
    #1
  2. Aloe Guvner

    Aloe Guvner Walrus Veteran

    Messages:
    1,561
    Likes Received:
    978
    Location:
    USA
    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
     
    #2
  3. Animebryan

    Animebryan Feels like I'm slowly dying! Veteran

    Messages:
    335
    Likes Received:
    153
    Location:
    Marysville, CA
    First Language:
    English
    Primarily Uses:
    RMMV
    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.
     
    #3
  4. Shaz

    Shaz Veteran Veteran

    Messages:
    37,579
    Likes Received:
    11,292
    Location:
    Australia
    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.
     
    #4
    Animebryan likes this.
  5. Aloe Guvner

    Aloe Guvner Walrus Veteran

    Messages:
    1,561
    Likes Received:
    978
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMMV
    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()}
     
    #5
  6. caethyril

    caethyril ^_^ Veteran

    Messages:
    1,116
    Likes Received:
    690
    Location:
    UK
    First Language:
    English
    Primarily Uses:
    RMMV
    :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:
     
    #6
    Aloe Guvner likes this.
  7. Animebryan

    Animebryan Feels like I'm slowly dying! Veteran

    Messages:
    335
    Likes Received:
    153
    Location:
    Marysville, CA
    First Language:
    English
    Primarily Uses:
    RMMV
    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).
     
    #7
  8. Aloe Guvner

    Aloe Guvner Walrus Veteran

    Messages:
    1,561
    Likes Received:
    978
    Location:
    USA
    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
     
    #8
    Animebryan likes this.

Share This Page