GUI Scripting Gauges

YverdaerYverdaer North Carolina, USA
Hello everyone!

I am trying to create both HP and Mana guages, however there are errors still. This is on Mudlet, and I am following a tutorial found here: http://wiki.mudlet.org/w/Manual:Geyser

My current scripts are as follows:

Heath Bar:

hpbar = Geyser.Gauge:new({

name="hpbar",

x="0%", y="85%",

width="18%", height="20px",

})

hpbar.front:setStyleSheet([[background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #f04141, stop: 0.1 #ef2929, stop: 0.49 #cc0000, stop: 0.5 #a40000, stop: 1 #cc0000);

border-top: 1px black solid;

border-left: 1px black solid;

border-bottom: 1px black solid;

border-radius: 7;

padding: 3px;]])

hpbar.back:setStyleSheet([[background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #bd3333, stop: 0.1 #bd2020, stop: 0.49 #990000, stop: 0.5 #700000, stop: 1 #990000);

border-width: 1px;

border-color: black;

border-style: solid;

border-radius: 7;

padding: 3px;]])



current_health, max_health = tonumber(matches[2]), tonumber(matches[3])


hpbar:setValue(current_health, max_health)


lua local hp = math.random(1,100)

hpbar:setValue(current_health, max_health, "<b>"..max_health.."hp</b>")


Mana Bar:


manabar = Geyser.Gauge:new({

name="manabar",

x="0%", y="90%",

width="18%", height="20px",

})


manabar.front:setStyleSheet([[background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #98f041, stop: 0.1 #8cf029, stop: 0.49 #66cc00, stop: 0.5 #52a300, stop: 1 #66cc00);

border-top: 1px black solid;

border-left: 1px black solid;

border-bottom: 1px black solid;

border-radius: 7;

padding: 3px;

]])

manabar.back:setStyleSheet([[background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #78bd33, stop: 0.1 #6ebd20, stop: 0.49 #4c9900, stop: 0.5 #387000, stop: 1 #4c9900);

border-width: 1px;

border-color: black;

border-style: solid;

border-radius: 7;

padding: 3px;

]])



current_Mana, max_Mana = tonumber(matches[2]), tonumber(matches[3])


Mana_bar:setValue(current_Mana, max_Mana)


lua local mana = math.random(1,100)

manabar:setValue(current_Mana, max_Mana, "<b>"..max_Mana.."hp</b>")


Thank you for your help!!





Comments

  • The current_health bit is in a trigger, yeah?
  • YverdaerYverdaer North Carolina, USA
    Oh, no. I have that all in the same script box. Also, thank you for writing the manual I am using to write these scripts!!
  • YverdaerYverdaer North Carolina, USA
    Ehh, sorry to ask it of you, but could you tell me what goes where?
  • The part where you update the gauge should go into a trigger ("wherever you get your new health at (be it prompt, gmcp, atcp or whatever)").

    Check the triggers tutorial on how to make them, and then you could make yourself a prompt trigger that does the job!
  • YverdaerYverdaer North Carolina, USA
    Alright, but what do you mean by prompt, gmcp, atcp? Sorry, very VERY new at this.
  • The prompt is the line that you see whenever something else happened - it has your health, mana, and so on stats on it (if you aren't seeing it, see CONFIG PROMPT STATS).

    GMCP and ATCP are some more advanced scripting things - I wouldn't worry about them now, the tutorial mentions them for those who do. I'd just make a prompt trigger at this stage.
  • YverdaerYverdaer North Carolina, USA
    Thank you very much!! I'll do this ASAP.
  • YverdaerYverdaer North Carolina, USA
    For some reason it still isn't working. What I have is as follows:

    in the trigger, as an exact match I have: 1460h, 1534m, 6200e, 7068w exb-

    And in the big box below in the trigger I have: current_health, max_health = tonumber(matches[2]), tonumber(matches[3])

    However, it still isn't working. Once again, thank you so much for all your help!
  • JonathinJonathin Retired in a hole.
    Your trigger isn't capturing anything. It's just matching '1460h, 1534m, 6200e, 7068w exb-' exactly.
    I am retired and log into the forums maybe once every 2 months. It was a good 20 years, live your best lives, friends.
  • YverdaerYverdaer North Carolina, USA
    Alright, so then what do I do to fix it?
  • You want to replace the numbers with placeholders for any number, use the (\d+) things for that.
  • YverdaerYverdaer North Carolina, USA
    Ahhhhh! Thank you!
  • YverdaerYverdaer North Carolina, USA
    Sorry to have to be lead by the hand so much, but I replaced those vales with the (\d+), so now it's (as a pearl regex):

    (\d+)h, (\d+)m, (\d+)e, (\+d)w exb-

    And in the big box I have:

    current_health, max_health = tonumber(matches[2]), tonumber(matches[3])


    However, it is still not working. Is there anything else I'm missing? Or just something that needs to be added? Do I need the other values to be added somewhere?:


    hpbar:setValue(current_health, max_health)


    lua local hp = math.random(1,100)

    hpbar:setValue(current_health, max_health, "<b>"..max_health.."hp</b>")


    Thank you!

  • The values in the matches table (matches[2], matches[3], etc) correspond to whatever those \d+ wildcards match in the trigger. In this case, matches[2] is your current health, matches[3] is your current mana, and matches[4] and matches[5] are your current endurance and willpower. So what your script is doing currently is setting the gauge to display your current health as a fraction of your current mana. Since max health/mana/end/will don't show up on the prompt, you'll need to get those somewhere else. The usual way to do that (if you're not worrying about gmcp yet) is to set them from another trigger that matches the appropriate line in your SCORE.
  • YverdaerYverdaer North Carolina, USA
    Ohhhh, but that's a problem since those aren't displayed typically like the PROMPT are. So I guess to make those meters I must have the gmcp? I don't understand how this could work without them then. Thank you for the great explanation!!

    I'm guessing this is what I want then?: 
  • YverdaerYverdaer North Carolina, USA
    Alright, I got the numbers to work!! But I see your problem, that is, that my "health" is a summary of the difference between my total health and mana. In that case, how can I get it to just represent my health?

    Thanks!
  • You are setting your max health with matches[3] which in this case is mana. You will need to either set it manually or capture it from somewhere else (score being a good place, or the variable gmcp.Char.Vitals.maxhp will always be kept up to date if gmcp is enabled). Once you set that right it should work I think?
  • YverdaerYverdaer North Carolina, USA
    If I were to capture it from gmpc, how would I set that up?

    my stats are around the lines of 

    1500h, 1700m elrx<>- [1500/1500h]
  • you don't actually need to capture anything from gmcp, the variables gmcp.Char.Vitals.hp and gmcp.Char.Vitals.maxhp will always be kept up to date with what achaea sends you, you will however need to refresh your gauges at some point, probably at every prompt.
  • YverdaerYverdaer North Carolina, USA
    Thanks, but how do I do that then? 
  • One option is to make a trigger
    type: lua function 
    pattern: return isPrompt()

    then just do whatever the update thing for gauges is 
  • YverdaerYverdaer North Carolina, USA
    Thank you!!
  • JonathinJonathin Retired in a hole.
    edited April 2014
    In case you are looking for some resources about scripting in Mudlet, here are some links below.

    Here is a tutorial for using GMCP with Mudlet.

    Here is a tutorial for using tables in Mudlet.

    Here is a tutorial for using basic RegEx.

    Here is a thread with a bunch of video tutorials I did.

    I'm sure that you have checked out the Mudlet Manual / wiki, but here are links in case you haven't had the chance.
    I am retired and log into the forums maybe once every 2 months. It was a good 20 years, live your best lives, friends.
Sign In or Register to comment.