ID:157370
 
Hi all,
I'm trying to get some bars on my skin to work with stats of a character. So you can see the condition of your stats in bar form on the skin. (If you get what I mean)
Anyone know how I would do this?

Much appreciated if you could give me an example. :)
winset its value variable (which has to be between 0 and 100).
If that's not what you had trouble with, please elaborate a bit more on where you ran into a barrier.
In response to Schnitzelnagler
I've got no idea how to specify the 'output' in essence.. Like to send it to the bar.
Say I've got a HP stat, and have made a bar on the skin for it. I just want to know how to code the bar to represent the characters HP stat.
In response to Iv3rson
Iv3rson wrote:
I've got no idea how to specify the 'output' in essence.. Like to send it to the bar.

When linked to a reference entry, it is most useful to read this very entry.
winset follows the interface of winset(player, control_id, params), where player is a mob or client, control_id is the unique ID of a control in the player's skin and params is a list of parameters to set, in the format returned by list2params().


Iv3rson wrote:
Say I've got a HP stat, and have made a bar on the skin for it. I just want to know how to code the bar to represent the characters HP stat.

Say your HP stat follows the bad, but often used habit of mob.HP and mob.MaxHP (it would likely be much smarter to write use a datum for encapsulation of stats in general).
Since the bar value has to be between 0 and 100, we use a simple percentage value (mob.HP/mob.MaxHP). Now, if your bar is in a window called MyWindow and has the name HPBar, you'd send set it as winset(player, "MyWindow.HPBar", "value=[player.HP/player.MaxHP]").
In response to Schnitzelnagler
Ugh, I've tried that but I bet I'm doing something wrong for sure.. Any chance I could send you what I have (I've been trying it out in a test environment)?
Really appreciate all the help btw.
In response to Iv3rson
Sure, you copy and paste the code snippet and place it between a <dm> and a </dm> tag, which formates it in decent way.

E.g.:
client
East()
if(probe)
return step(probe, EAST)
else
return ..()


As a side-note, it helps to describe the actual result you're seeing, when you're looking for a problem to be diagnosed.
In response to Schnitzelnagler
Sweet, thanks alot.. I just got it to work :O
Is there anything I should maybe change? or a more efficient way to code it? (I'm going to have about 4 bars apart from the HP one)
mob
proc
slowlydie()
src.hp -= 10
src.updateHP()
sleep(2)
slowlydie()


mob
Login()
world << "Testing hp bar now.."
src.slowlydie()
src.updateHP()
..()


mob/Stat()
stat("Health: [round(src.hp / src.maxhp *100)]%")

mob
var
hp = 900
maxhp = 1000
mob

proc
updateHP()
winset(src, "main.hpbar", "value=[src.hp / src.maxhp * 100]")
In response to Iv3rson
That way, you're always going to be doing
hp-=10
src.updateHP()


A hint would just be to combine both.

LoseHP(10,attacker)

mob
proc
LoseHP(HPLost,attacker)
hp-=HPLost
DeathCheck(attacker)
winset(src, "main.hpbar", "value=[hp/maxhp*100]")

DeathCheck(attacker)
if(hp>0) return 0
if(attacker&&ismob(attacker))
world<<"[attacker] killed [src]!"
else world<<"[src] died a natural death."
In response to Emasym
I'd give that argument a name other than "source", such as "attacker". The name is too easily conflated with src, which could cause great confusion.

Lummox JR