Basic Health/Move/Mana and Opponent Health Bars
Posted: Tue Sep 10, 2013 8:17 am
Here are some very basic Hp/Mv/Ma bars and an opponent Hp bar for Mudlet. They are designed to show current/max and update whenever any of the 3 current values change. I'm focusing on very minimal code and my main goal is to understand this stuff as I create it. At any rate, I was glad to finally see some progress and would appreciate any suggestions. Big thanks to Akayan for the MSDP code and other pointers.
In order for this to work the MSDP variables must be turned on and I would highly recommend reading Akayan's post about getting that setup
First, I went into settings and set top and bottom borders to 15 to allow room for my bars w/o overlapping my mud scroll.
Then I created a script (name is not important) to create the gauges that I used to display health/moves/mana and opponent health with the following code:
Next, I created a script to handle my bar updates, I called this "updatebars" and it was set to go off on the following User Defined Event Handlers:
The code for this script is as follows (pay attention to the function being named the same as the script, again.. thanks to Akayan for explaining how this works):
In hopes of not losing this post to a second Chrome crash I will post a screenshot in a reply. I hope this is helpful or at least interesting for someone
-Nate
In order for this to work the MSDP variables must be turned on and I would highly recommend reading Akayan's post about getting that setup
First, I went into settings and set top and bottom borders to 15 to allow room for my bars w/o overlapping my mud scroll.
Then I created a script (name is not important) to create the gauges that I used to display health/moves/mana and opponent health with the following code:
- Code: Select all
WindowWidth = 0;
WindowHeight = 0;
WindowWidth, WindowHeight = getMainWindowSize();
createGauge("HealthBar", WindowWidth/3, 15, 0, WindowHeight-15, nil, 200, 0, 0)
createGauge("MoveBar", WindowWidth/3, 15, WindowWidth/3, WindowHeight-15, nil, 0, 200, 0)
createGauge("ManaBar", WindowWidth/3, 15, WindowWidth/3*2, WindowHeight-15, nil, 0, 0, 200)
createGauge("OppHealthBar", WindowWidth, 15, 0, 0, nil, 200, 0, 0)
Next, I created a script to handle my bar updates, I called this "updatebars" and it was set to go off on the following User Defined Event Handlers:
- Code: Select all
MSDPHEALTH
MSDPMOVEMENT
MSDPMANA
MSDPOPPONENT_HEALTH
The code for this script is as follows (pay attention to the function being named the same as the script, again.. thanks to Akayan for explaining how this works):
- Code: Select all
function updatebars()
setGauge("HealthBar",atcp.MSDPHEALTH,atcp.MSDPHEALTH_MAX)
echo("HealthBar",[[<p style="font-size:14px"><center><b>]]..atcp.MSDPHEALTH..[[/]]..atcp.MSDPHEALTH_MAX..[[</b></center></p>]])
setGauge("MoveBar",atcp.MSDPMOVEMENT,atcp.MSDPMOVEMENT_MAX)
echo("MoveBar",[[<p style="font-size:14px"><center><b>]]..atcp.MSDPMOVEMENT..[[/]]..atcp.MSDPMOVEMENT_MAX..[[</b></center></p>]])
setGauge("ManaBar",atcp.MSDPMANA,atcp.MSDPMANA_MAX)
echo("ManaBar",[[<p style="font-size:14px"><center><b>]]..atcp.MSDPMANA..[[/]]..atcp.MSDPMANA_MAX..[[</b></center></p>]])
setGauge("OppHealthBar",atcp.MSDPOPPONENT_HEALTH,atcp.MSDPOPPONENT_HEALTH_MAX)
echo("OppHealthBar",[[<p style="font-size:14px"><center><b>]]..atcp.MSDPOPPONENT_HEALTH..[[/]]..atcp.MSDPOPPONENT_HEALTH_MAX..[[</b></center></p>]])
end
In hopes of not losing this post to a second Chrome crash I will post a screenshot in a reply. I hope this is helpful or at least interesting for someone
-Nate