HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: Changing Bars to Numbers  (Read 3293 times)

Higler

  • World Owners
  • ****
  • Posts: 13
    • View Profile
Changing Bars to Numbers
« on: Apr 22, 13, 07:35:12 AM »

I am tryng to change hit point stamina and mana bars into numbers for example 100/100. Anyone know what properties I would need to change for the sliders to convert them from standard bars to numbers I would greatly apprecate the help.
Logged

Thazager

  • General Accounts
  • *
  • Posts: 1160
  • Never stop learning
    • View Profile
Re: Changing Bars to Numbers
« Reply #1 on: Apr 22, 13, 02:45:07 PM »

At present we still have the max value of 100 for the health and stamina bars. I do however display the numeric value on top of the bar as a player option. I added a button over the top of each bar to toggle the display of the numeric values. In the GUI on HealthPanel add text and button. Set the defaultpresentation.color.a of the button to 0 (that way it can be interacted with, but not displayed). Set the size to the same as bar size.

Code: [Select]
// toggle buttons
method onMouseClick(args references Class GUIMouseEvent)
  acct as NodeRef of Class E_playerAccount = GetAccountID()
  char as NodeRef of Class E_playerCharacter = acct.GetMyCharacter()
  target as NodeRef of Class GUIControl = args.source
  if args.leftButton
    when target.name
      is "HPButton"
        text as NodeRef of Class GUILabel = FindGUIControlByName(None, "game.HaV_CharBar.HealthPanel.HPtext")
        if text.visible
          text.visible = false
        else
          text.visible = true     // here is where you can toggle the bar off, if you want
        .
      .
    .
  .
.

method SetPlayerHP(hp copies Integer, hpMax copies Integer)
  if hp < 0
    hp = 0
  .
  healthText as NodeRef of Class GUILabel = FindGUIControlByName(me, "HealthPanel.HPtext")
  healthText.text = "" + hp + " / " + hpMax
  healthSlider as NodeRef of Class GUIControl = FindGUIControlByName(me, "HealthPanel.HealthSlider")
  healthSlider.removeAnimations()
  percentage as Float = 100.0 * (hp)/(hpMax)      // based on 100% percent not 100 total
  var size = -1.0 * percentage  //hp

  animationString as String = "size.x,"
  animationString = animationString + healthSlider.size.x + ","
  animationString = animationString + size +","
  animationString = animationString + .1 + ","
  animationString = animationString + 1 + ","
  animationString = animationString + "false,"
  animationString = animationString + "LINEAR," 
  animationString = animationString + "false,"
  animationString = animationString + "0,"
  animationString = animationString + "slide"
 
  GUIAnimation:addAnimation(healthSlider, "Interpolate", animationString)
.


« Last Edit: Apr 22, 13, 03:08:56 PM by Thazager »
Logged
Lead scripter for EO, Repop helper.
HSL Video tutorials:
https://community.heroengine.com/forums/index.php/topic,1719.msg36858.html#msg3685

Higler

  • World Owners
  • ****
  • Posts: 13
    • View Profile
Re: Changing Bars to Numbers
« Reply #2 on: Apr 22, 13, 10:49:43 PM »

Hmmm I really picture what your aying Thaz, we are using max value of 100 as well but we need the bars completely gone and value/max value layout on status bar (just numbers and /)
Logged

Thazager

  • General Accounts
  • *
  • Posts: 1160
  • Never stop learning
    • View Profile
Re: Changing Bars to Numbers
« Reply #3 on: Apr 22, 13, 11:05:01 PM »

There are 2 easy ways of making them gone. One way is to delete them with destroynode(node), the other is to hide them with visible = false. For showing the text, see code in post above, you dont need the button to use it.

HP as Noderef = FindGUIControlByName(None, "game.HaV_CharBar.HealthPanel")
destroynode(HP)

or

HP.visible = false
Logged
Lead scripter for EO, Repop helper.
HSL Video tutorials:
https://community.heroengine.com/forums/index.php/topic,1719.msg36858.html#msg3685

Higler

  • World Owners
  • ****
  • Posts: 13
    • View Profile
Re: Changing Bars to Numbers
« Reply #4 on: Apr 23, 13, 11:36:23 PM »

Where exactly do I put the code Thaz? E_commoncharacterclassmethods? I put the text display boxes for each stat on the GUI but didn't add buttons as we don't want buttons, is there a property I set to read from the mycharacter noderef? like for strength to display as what the characters strength as?
We have added all the stats Strength, Dexterity, Intelligence, hit points, stamina, and mana points I need the status bar (i assume what you called healthpanel?) to show each numerically
Logged

Thazager

  • General Accounts
  • *
  • Posts: 1160
  • Never stop learning
    • View Profile
Re: Changing Bars to Numbers
« Reply #5 on: Apr 24, 13, 03:41:10 AM »

A stat like strength is different from a stat like health. Health is a value that can most likely be seen by other players at a glance, they can see if you are injured. A stat like STR, Dex, Int, are values that can be displayed on GUI panel using _labels. To save these values with the character, there are a few ways.

You could have the base stats in a function on the server side, and then items that give stats can be counted up to give the total stat value.

Another way is to keep the actual total on the character and checked when its displayed. In this way, a field like strength can be created in the DOM, and then the field added to the character class. I believe its E_playercharacter, unless you have made your own class for the character. Anything that is tagged on the character is saved with the character. Like the hitpoints in the DOM, strength can be made the same way. Though it does not need all the same places through the scripts for displaying it.

To find where things are in script, you can do a search all scripts. In heroscript, click find then check both the client and server sides. If you are wanting to display the value on the statusbar, do a search for setHP. It will most likely be in the statusbar script. We added healthText.text = "" + hp + " / " + hpMax to display it.

healthpanel is actual code used in the E_ scripts.
Logged
Lead scripter for EO, Repop helper.
HSL Video tutorials:
https://community.heroengine.com/forums/index.php/topic,1719.msg36858.html#msg3685

Strata

  • World Owners
  • ****
  • Posts: 29
  • I eat textures
    • View Profile
Re: Changing Bars to Numbers
« Reply #6 on: Jan 19, 14, 09:14:43 AM »

so do i need a healthpanel XML script in the GUI files and copy and paste this code into it ? and then edit the defaultstatepresentation on that one or on something else
Logged
I eat textures

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: Changing Bars to Numbers
« Reply #7 on: Jan 19, 14, 01:50:23 PM »

Quote
we need the bars completely gone
I'd recommend opening the gui prototype in the gui editor and just deleting the controls you don't want. Then you don't need to do anything in code to get rid of them.
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.