|
kwirlkarphys Newbie
Joined: 16 Aug 2007 Posts: 9
|
Posted: Thu Aug 16, 2007 6:20 am
Using Gauges and Windows for a health checker.... |
I've been fumbling with some triggers that I just can't seem to do what I want. I suppose to start I will list my objective.
I want to take the results of a group display command, have the results captured to either a window or gauge button, or both. I want the gauges to be colorized, updated when i check the group display, and when i click on one of the gauges, it will execute a predetermined action.
Make sense? Let me tell you what I've got now (its a sloppy culmination of several other things I've found)
Quote: |
Your group consists of:
( Head) 100/100 hit, 100/100 move Larry
(Front) 150/150 hit, 100/100 move Moe
(Front) 100/150 hit, 100/100 move Curly |
Quote: |
#TRIGGER {*%s(%d)/(%d)%shit,*move (%*)} {#ADD Gnum 1;#math GStatus (%1 - %2); #if (@Gstatus <= 0) {#window {Group Stats} {F@Gnum~. %3 %repeat( ., 15-%len( %3)) %ansi( Yellow)@Gstatus}} |
That second line creates an output window that captures the result of the 'group' check, but I want it to utilize the #GAUGE function instead of the #WINDOW output....but I can't really get my fingers around it. Do i make sense? |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu Aug 16, 2007 10:13 am |
The #gauge command probably isn't the best way to do this - it's intended for creating new gauges and not for updating existing ones. You can't easily update one part of the gauge without updating all parts of the gauge. zMUD really expects you to use variables for the current value of the gauge, which it will then check and update on its own.
So with that said, is there an upper limit to the number of people you can have in a group? I'd create that number of gauges, using variables for the caption and values (and the command, if you want that to change too) and then disable the ones I don't need. Then just use your trigger there to give the variables proper values. |
|
|
|
kwirlkarphys Newbie
Joined: 16 Aug 2007 Posts: 9
|
Posted: Thu Aug 16, 2007 10:28 am |
ok, what i'm probably looking to do is to make a list of #buttons, 13 in all. i haven't done programming in years, so what is the most efficient method to take
Quote: |
Your group consists of:
( Head) a/b hit, 100/100 move SnowWhite
(Front) c/d hit, 100/100 move Sleepy
(Front) e/f hit, 100/100 move Sneezy
(Front) g/h hit, 100/100 move Grumpy
(Front) i/j hit, 100/100 move Itchy
(Front) k/l hit, 100/100 move Scratchy
(Front) m/n hit, 100/100 move Gassy
|
and use the health/maxhealth for conditionally colored buttons. I.E., when i type group, if the value for (a) is <= 80% of (b), then the button for SnowWhite will be redrawn as yellow, and perhaps red at <= 40%.
I've been trying to figure this out for 9 hours now, so if i don't make sense, then i blame sleep depravation and the fact that i don't really have any experience or support with scripting before signing up here (although i bought my copy of zmud almost 9 years ago lol!) |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu Aug 16, 2007 10:47 am |
Gauges will recolour themselves for you. They have the options "Value", "Max" and "Low". There's a Gauge colour, a background colour, and a low colour. When the value falls below the Low value, the gauge will be coloured the Low colour. No need to do it yourself.
You're really expected to make buttons with the GUI in zMUD. It's very difficult to support the many, many options that buttons can have (take a look at the helpfile for the #button command) in the TINTIN-like zScript syntax.
If you need that many buttons, I'd have them as part of a sidebar. Change them to Panel 2 and Right aligned. Colour them however you like, and since they're going to be very similar, you could just copy and paste the first one 12 times and then change the details (variable names etc).
The trouble with that text you just gave is that there's no way for the script to know when the list has finished. It needs to know when the list has ended because there could be any number of people in the group. That said, here's something you can try (or something to give you an idea anyway)
#trig {Your group consists of:} {membercount=1;#loop 13 {#var %concat("Group_",%i) ""};#t+ membertrig}
#cond {some way of knowing the list has ended, possibly your prompt} {#t- membertrig;#loop 13 {#if (@{%concat("Group_",%i)}) {#call %btnenable(%concat("GroupBtn_",%i),1)} {#call %btnenable(%concat("GroupBtn_",%i),0)}
#trig "membertrig" {~(%s%w~) (%d)/(%d) hit, (%d)/100 move (%w)} {#addkey %concat("Group_",@membercount) CurrentHealth %1;#addkey %concat("Group_",@membercount) MaxHealth %2;#addkey %concat("Group_",@membercount) CurrentMove %3;#addkey %concat("Group_",@membercount) Name %4;#add membercount 1} {disable}
In short, this script assumes that your 13 buttons are called GroupBtn_X where X is a number 1-13. It stores the current health, max health, current moves, and name of the group member in data record variables called Group_X. To use those values in the buttons, just use @Group_1.currenthealth, @Group_2.maxhealth, @Group_4.name and so on.
I haven't tested this, but hopefully you understand the idea. |
|
|
|
kwirlkarphys Newbie
Joined: 16 Aug 2007 Posts: 9
|
Posted: Thu Aug 16, 2007 10:53 am |
ok, im gonna take a break from numbers and variables and come back to hit this again in an hour or so, i appreciate the help.
oh, fyi - here is what i see exactly in a group of 2(just for example's sake) before and after i type the 'group' command
< 654h/654H 159v/159V Pos: standing >
<> group
Your group consists of:
( Head) 654/654 hit, 159/159 move Julian
(Front) 435/435 hit, 130/130 move Kwyrl
< 654h/654H 159v/159V Pos: standing >
<> |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu Aug 16, 2007 10:58 am |
Since your MUD sends a blank line after the list (that's pretty much ideal) you can use the patterns ^$ or $ to match it.
|
|
|
|
kwirlkarphys Newbie
Joined: 16 Aug 2007 Posts: 9
|
Posted: Thu Aug 16, 2007 12:48 pm |
fyi - i hate the zscript formatting :P its such a pain to debug syntax errors with.
|
|
|
|
kwirlkarphys Newbie
Joined: 16 Aug 2007 Posts: 9
|
Posted: Thu Aug 16, 2007 1:05 pm |
Ok, I got the first part of your code to work, btw its
Quote: |
#trig {Your group consists of:}
membercount=1
#loop 13 {#var %concat( "Group_", %i) ""}
#t+ membertrig
#cond ($^)
#t- membertrig
#loop 13 {#if (@{%concat( "Group_", %i)}) {#call %btnenable(%concat("GroupBtn_",%i),1)} {#call %btnenable(%concat("GroupBtn_",%i),0)}} |
now, keeping in mind that i'm teaching myself scripting as i type it - i'm having trouble parsing out the
Quote: |
#trig "membertrig"
{~(%s%w~) (%d)/(%d) hit, (%d)/(%d) move (%w)} {#addkey %concat("Group_",@membercount) CurrentHealth %1;#addkey %concat("Group_",@membercount) MaxHealth %2;#addkey %concat("Group_",@membercount) CurrentMove %3;#addkey %concat("Group_",@membercount) Name %4;#add membercount 1} {disable} |
no matter what tweaks i seem to be making, i'm getting funky syntax errors returned, and im manually entering these, not via command line |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu Aug 16, 2007 5:26 pm |
Be careful with that first part, you're missing a couple of braces. The #cond command isn't part of the #trig command's script, it's a separate command that creates trigger states. Look it up.
I made a typo with the first #trig command - it needs two more closing braces } right at the end for it to work. Whoops :(
The second is being annoying - the syntax is valid, but it's not working. Just create the trigger manually, give it the ID "membertrig", disable it, and paste in the script. The contents of the script (from addkey %concat() Currenthealth to #add membercount 1) doesn't have any syntax errors when I paste it that way. |
|
|
|
kwirlkarphys Newbie
Joined: 16 Aug 2007 Posts: 9
|
Posted: Thu Aug 16, 2007 10:53 pm |
okies status here
pattern
Quote: |
*%s(&%d{current_hp})/(&%d{max_hp})%shit,%s(&%d{current_mv})/(&%d{max_mv})%smove%s(&group_member)$ |
value
Quote: |
#math hp_difference (@current_hp - @max_hp)
#math hp_percentage (@current_hp*100/@max_hp)
#if @hp_difference<@temp_hp {
temp_hp=@hp_difference
#var healfirst @group_member
}
#if @hp_percentage<@temp_percentage {
temp_percentage=@hp_percentage
#var healmefirst @group_member
}
#if @hp_percentage<21 {
#math hp_difference (@max_hp-@current_hp)
#unbutton {@group_member}
#BUTTON {@group_member} {@group_member} {fh @group_member} {} {} {} {} {} {} {} {} {} {} {} {13} {} {} {} "" {} {} {@group_member}
#SAY {"Health"%ansi( bold, white)~[ %ansi( bold, green)-@hp_difference %ansi( bold, white)~| %ansi( bold, cyan)@group_member is %ansi( bold, blink, red)dying %ansi( bold, white)~| %ansi( bold, blink, red)@hp_percentage%ansi( bold, green)~% %ansi( bold, white)~]}
:tells: #SAY {" "%ansi( bold, white)~[ %ansi( bold, green)-@hp_difference %ansi( bold, white)~| %ansi( bold, cyan)@group_member is %ansi( bold, blink, red)dying %ansi( bold, white)~| %ansi( bold, blink, red)@hp_percentage%ansi( bold, green)~% %ansi( bold, white)~]}
#abort 1
}
#if @hp_percentage<41 {
#math hp_difference (@max_hp-@current_hp)
#unbutton {@group_member}
#BUTTON {@group_member} {@group_member} {fh @group_member} {} {} {} {} {} {} {} {} {} {} {} {12} {} {} {} "" {} {} {@group_member}
#SAY {"Health"%ansi( bold, white)~[ %ansi( bold, green)-@hp_difference %ansi( bold, white)~| %ansi( bold, cyan)@group_member is %ansi( bold, red)hurting %ansi( bold, white)~| %ansi( bold, blink, red)@hp_percentage%ansi( bold, green)~% %ansi( bold, white)~]}
:tells: #SAY {" "%ansi( bold, white)~[ %ansi( bold, green)-@hp_difference %ansi( bold, white)~| %ansi( bold, cyan)@group_member is %ansi( bold, red)hurting %ansi( bold, white)~| %ansi( bold, blink, red)@hp_percentage%ansi( bold, green)~% %ansi( bold, white)~]}
#abort 1
}
#if @hp_percentage<61 {
#math hp_difference (@max_hp-@current_hp)
#unbutton {@group_member}
#BUTTON {@group_member} {@group_member} {fh @group_member} {} {} {} {} {} {} {} {} {} {} {} {14} {} {} {} "" {} {} {@group_member}
#SAY {"Health"%ansi( bold, white)~[ %ansi( bold, green)-@hp_difference %ansi( bold, white)~| %ansi( bold, cyan)@group_member is %ansi( bold, blue)wounded %ansi( bold, white)~| %ansi( bold, blink, red)@hp_percentage%ansi( bold, green)~% %ansi( bold, white)~]}
:tells: #SAY {" "%ansi( bold, white)~[ %ansi( bold, green)-@hp_difference %ansi( bold, white)~| %ansi( bold, cyan)@group_member is %ansi( bold, blue)wounded %ansi( bold, white)~| %ansi( bold, blink, red)@hp_percentage%ansi( bold, green)~% %ansi( bold, white)~]}
#abort 1
}
#if @hp_percentage<81 {
#math hp_difference (@max_hp-@current_hp)
#unbutton {@group_member}
#BUTTON {@group_member} {@group_member} {fh @group_member} {} {} {} {} {} {} {} {} {} {} {} {10} {} {} {} "" {} {} {@group_member}
#SAY {"Health"%ansi( bold, white)~[ %ansi( bold, green)-@hp_difference %ansi( bold, white)~| %ansi( bold, cyan)@group_member has %ansi( bold, yellow)small wounds %ansi( bold, white)~| @hp_percentage%ansi( bold, green)~% %ansi( bold, white)~]}
:tells: #SAY {" "%ansi( bold, white)~[ %ansi( bold, green)-@hp_difference %ansi( bold, white)~| %ansi( bold, cyan)@group_member has %ansi( bold, yellow)small wounds %ansi( bold, white)~| @hp_percentage%ansi( bold, green)~% %ansi( bold, white)~]}
#abort 1
}
#if @hp_percentage<96 {
#math hp_difference (@max_hp-@current_hp)
#unbutton {@group_member}
#BUTTON {@group_member} {@group_member} {fh @group_member} {} {} {} {} {} {} {} {} {} {} {} {2} {} {} {} "" {} {} {@group_member}
#say {"Health"%ansi( bold, white)~[ %ansi( bold, green)-@hp_difference %ansi( bold, white)~| %ansi( bold, cyan)@group_member is scratched %ansi( bold, white)~| @hp_percentage%ansi( bold, green)~% %ansi( bold, white)~]}
:tells: #SAY {" "%ansi( bold, white)~[ %ansi( bold, green)-@hp_difference %ansi( bold, white)~| %ansi( bold, cyan)@group_member is scratched %ansi( bold, white)~| @hp_percentage%ansi( bold, green)~% %ansi( bold, white)~]}
#abort 1
} |
The problem is, that it doesnt seem to be getting rid of the previous buttons correctly. what am i doing wrong? |
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|