Displaying Current Weapon - HUD Maker

Discussion in 'Javascript/Plugin Support' started by OneMoveLeft, May 24, 2019.

  1. OneMoveLeft

    OneMoveLeft Warper Member

    Messages:
    4
    Likes Received:
    1
    First Language:
    English
    Primarily Uses:
    RMMV
    Hi folks. I‘m finding it hard to resolve my issue and after 2 days have decided to see if the helpful RMMV community can assist. Im using SumRndmDde’s impressive HUD Maker plugin. Is someone able to inform me of the HUD Maker property value I would need to use in order to get the equipped weapon for an actor (say ID 150 in the actor database) displaying on the map HUD? Is it possible? It would have to change automatically when equipped weapon is changed. Also, can the associated weapon icon be displayed along with it?

    Many thanks in anticipation. OML

    Edit: Totally forgot to post the plugin link. Please forgive me!

    Plugin can be downloaded here: http://sumrndm.site/hud-maker/
    It may also be a good idea to install The Super Tools Engine: http://sumrndm.site/super-tools-engine/
     
    Last edited: May 24, 2019
    #1
  2. Kes

    Kes Global Moderators Global Mod

    Messages:
    20,580
    Likes Received:
    10,504
    First Language:
    English
    Primarily Uses:
    RMVXA
    @OneMoveLeft Please edit your post to include a link to the web page where you got the plugin. That way, if anyone needs to check something before offering advice they won't have to go hunting.
    Thanks.
     
    #2
  3. caethyril

    caethyril ^_^ Veteran

    Messages:
    1,116
    Likes Received:
    689
    Location:
    UK
    First Language:
    English
    Primarily Uses:
    RMMV
    Try one of these:
    • Name of first equipped weapon, or an empty string if no weapons equipped:
      Code:
      var weapon = $gameActors.actor(150).weapons()[0]; weapon ? weapon.name : ""
    • Name of item equipped in first equip slot, or an empty string if no item present:
      Code:
      var equip = $gameActors.actor(150).equips()[0]; equip ? equip.name : ""
    Related: https://steamcommunity.com/app/363890/discussions/4/1333474229065936360/#c1333474229066371294

    If that doesn't work, I think SRD's HUD Maker requires at least some evals to be enclosed in ${...} so that could be worth a try, e.g.
    Code:
    ${var item = $gameActors.actor(150).weapons()[0]; item ? item.name : ""}
     
    #3
  4. OneMoveLeft

    OneMoveLeft Warper Member

    Messages:
    4
    Likes Received:
    1
    First Language:
    English
    Primarily Uses:
    RMMV
    Thank you for the reply Caethyril.

    Yes you are correct that the evals must be enclosed in ${...}.
    I tried using the above examples and mostly got errors but then I removed the 'var item =' portion of the eval and everything after the semi colon so that visually it more resembled other evals that I've seen. This made the output change from 'Error' to '[object Object]' (minus quotes). Was not sure what this meant but it looked better!

    Newayyyyy! To the good news. Between your code and the link you posted, I managed to stumble upon my 'Eureka' moment and now it is working!

    The required eval is : ${$gameActors.actor(150).weapons()[0].name}

    And Voila, HUD magic!!!
    Many thanks for your assistance. I feel I may get a good night's sleep now!!!

    P.S. This solution alone will still give an error if there are no weapons equipped. I believe I'll need to enter some conditions in HUD Maker to get that working. So for now ill just make sure a weapon is always equipped until I'm ready to battle that task!
     
    Last edited: May 24, 2019
    #4
    caethyril likes this.
  5. caethyril

    caethyril ^_^ Veteran

    Messages:
    1,116
    Likes Received:
    689
    Location:
    UK
    First Language:
    English
    Primarily Uses:
    RMMV
    Oh, strange. I'm not familiar with the ${} string literal stuff, I guess it doesn't accept multiple lines (i.e. semi-colons). The var stuff was just to avoid writing stuff out multiple times; this is longer but could be worth a try:
    Code:
    ${$gameActors.actor(150).weapons()[0] ? $gameActors.actor(150).weapons()[0].name : ''}
    I.e. "is actor 150's first weapon truthy ? if so, return its name : otherwise return an empty string". If they have no weapons equipped, the first weapon will be undefined/null, both of which are falsy. Technical details here: Falsy (definition). :kaothx:

    Also, the [object Object] thing you got is likely because you were asking the game to "write" the actual item, rather than just its name. :kaoswt:
     
    #5
  6. OneMoveLeft

    OneMoveLeft Warper Member

    Messages:
    4
    Likes Received:
    1
    First Language:
    English
    Primarily Uses:
    RMMV
    Worked like a charm! You absolute Legend! :D

    Don't suppose you have any suggestions on the related icon issue, i.e code to display the icon for an equipped weapon?

    OML
     
    #6
  7. caethyril

    caethyril ^_^ Veteran

    Messages:
    1,116
    Likes Received:
    689
    Location:
    UK
    First Language:
    English
    Primarily Uses:
    RMMV
    I think this'll get the associated icon's index (i.e. a number):
    Code:
    ${$gameActors.actor(150).weapons()[0] ? Number($gameActors.actor(150).weapons()[0].iconIndex) : 0}
    I'm not sure how the HUD Maker plugin handles drawing them, though. :kaoswt:
     
    #7
  8. OneMoveLeft

    OneMoveLeft Warper Member

    Messages:
    4
    Likes Received:
    1
    First Language:
    English
    Primarily Uses:
    RMMV
    I’m just about to travel so once I’ve landed and settled in, i’ll whack this into HUD Maker and update you.

    But to be fair, it looks pretty legit to my untrained eye. Can’t wait to test. OML

    Edit: Hi again. So I've finally tested the above code and it hasn't really worked out! HUD Maker provides a selection of elements to customise your HUD e.g Text, Text Picture, Gauge, etc. The text element, I have used to display the weapon name. When using the icon code in the text element, it displays the weapon icon number which means its pointing at the correct thing but as yet I've not managed to get a Icon showing even after plugging the code into all element types.

    The TextEx element type provides a way to display a selected icon but from what I see, it is only accepting something like, '\i[313]', to display a specific predetermined icon. I may be wrong but I'm stuck there.

    I've had a think and reckon that using a picture element to display an image of my weapon instead may work better and might also be more visually pleasing.

    Thanks again for the time and help that you have afforded me. OML
     
    Last edited: May 28, 2019
    #8

Share This Page