![](templates/Classic/images/spacer.gif) |
haiku Wanderer
Joined: 19 Nov 2004 Posts: 70
|
Posted: Fri Aug 31, 2007 6:02 am
Trigger assistance again with #VAR assignment of floats |
I originally posted about a similiar problem here: http://forums.zuggsoft.com/forums/viewtopic.php?t=27909
Code: |
#additem PartyMembers %1
#VAR PartyMembersHP %2
#VAR PartyMembersMaxHP %3
#SHOW Evaluating : @PartyMembersHP / @PartyMembersMaxHP
#VAR PartyMemberPercent (@PartyMembersHP * 1.0 / @PartyMembersMaxHP)
#SHOW doesn't work: PartyMemberPercent: @PartyMemberPercent
#IF (@PartyMemberPercent > 0.5 ) {#SHOW %1 needs help} {#SHOW %1 is fine.}
|
Here's my output:
Code: |
Leader: Vlad
Hits Energy Moves Exp
---- ------ ----- ---
[ 79 Ran Orc L ] Vlad 1135/1403 608/608 227/289 61881186
[ 75 Mob Fel ] Sabrina 751/751 268/268 302/302 0
[ 83 Mon Trl ] Grimslade 1085/1142 579/796 247/247 132224796
[ 52 Cle Vyn ] Bartalbe 289/518 336/472 96/96 48519183
[ 71 Ran Hum ] Kimalthea 1013/1037 500/500 327/327 67068751
[ 65 Thi Gob ] Squiurt 821/904 181/181 268/268 123877337
[ 60 Mon Liz ] Vos 403/713 608/608 122/122 43497684
[ 77 Mon Trl ] Groob 1016/1026 28/838 244/244 172240963
<1135hp 608e 227mv 96wm 61881186xp nWD> Evaluating : 1135 / 1403
Evaluating : 751 / 751
Evaluating : 1085 / 1142
Evaluating : 289 / 518
Evaluating : 1013 / 1037
Evaluating : 821 / 904
Evaluating : 403 / 713
Evaluating : 1016 / 1026
doesn't work: PartyMemberPercent: 0.990253411306043
Groob needs help
doesn't work: PartyMemberPercent: 0.990253411306043
Vos needs help
doesn't work: PartyMemberPercent: 0.990253411306043
Squiurt needs help
doesn't work: PartyMemberPercent: 0.990253411306043
Kimalthea needs help
doesn't work: PartyMemberPercent: 0.990253411306043
Bartalbe needs help
doesn't work: PartyMemberPercent: 0.990253411306043
Grimslade needs help
doesn't work: PartyMemberPercent: 0.990253411306043
Sabrina needs help
doesn't work: PartyMemberPercent: 0.990253411306043
Vlad needs help
|
Aside from the logic being wrong, why is it not storing the local variables correctly? I'd like to do this for each line of the output from the group command. |
|
|
![](templates/Classic/images/spacer.gif) |
Larkin Wizard
![](images/avatars/169979204542c57c7448618.gif)
Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Fri Aug 31, 2007 11:53 am |
You can change the type of the variables in the settings editor to Float and that would fix the problem. You could also use %vartype to change them programmatically or use the %float function in your expression.
Code: |
#VAR PartyMemberPercent (%float(@PartyMembersHP) / %float(@PartyMembersMaxHP)) |
|
|
|
![](templates/Classic/images/spacer.gif) |
haiku Wanderer
Joined: 19 Nov 2004 Posts: 70
|
Posted: Fri Aug 31, 2007 2:05 pm |
I'm still not sure why the output is wrong.... shouldn't it give me a percentage based on each individual's hp? It's showing partyMemberPercent as being .990 for each person in the party, when that's obviously false. Also, I'm curious as to why it displays like it does. Shouldn't it output something like this:
Code: |
Evaluating : 1135 / 1403
doesn't work: PartyMemberPercent: 0.9902...43
...
Evaluating : 289 / 518
doesn't work: ParyMemberPercent: 0.5579... //notice that this is different from the actual output
|
|
|
|
![](templates/Classic/images/spacer.gif) |
Vijilante SubAdmin
![](images/avatars/7230815434153eca6be3ad.gif)
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Fri Aug 31, 2007 2:12 pm |
What version of CMud are you using? The way your script is made your output should be more like this:
Code: |
<1135hp 608e 227mv 96wm 61881186xp nWD> Evaluating : 1135 / 1403
doesn't work: PartyMemberPercent: 0.990253411306043
Groob needs help
Evaluating : 751 / 751
doesn't work: PartyMemberPercent: 0.990253411306043
Vos needs help
Evaluating : 1085 / 1142
doesn't work: PartyMemberPercent: 0.990253411306043
Squiurt needs help
Evaluating : 289 / 518
doesn't work: PartyMemberPercent: 0.990253411306043
Kimalthea needs help
Evaluating : 1013 / 1037
doesn't work: PartyMemberPercent: 0.990253411306043
Bartalbe needs help
Evaluating : 821 / 904
doesn't work: PartyMemberPercent: 0.990253411306043
Grimslade needs help
Evaluating : 403 / 713
doesn't work: PartyMemberPercent: 0.990253411306043
Sabrina needs help
Evaluating : 1016 / 1026
doesn't work: PartyMemberPercent: 0.990253411306043
Vlad needs help |
It looks like the trigger processing is getting out of order, and this is a rather serious issue if that is happenning.
Also all the names are in reverse order. This is definitely not a good thing. |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
![](templates/Classic/images/spacer.gif) |
Larkin Wizard
![](images/avatars/169979204542c57c7448618.gif)
Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Fri Aug 31, 2007 2:41 pm |
I was guessing that a synchronization issue could be partially at fault here, too, but without the full trigger command posted, I wasn't sure. That would indeed have serious consequences.
|
|
|
![](templates/Classic/images/spacer.gif) |
haiku Wanderer
Joined: 19 Nov 2004 Posts: 70
|
Posted: Fri Aug 31, 2007 3:24 pm |
using version 1.34.
Here's the trigger pattern:
Code: |
^~[ %d %w %w {L| } ~] (%w) %s (%d)/(%d) %s %d/%d %s %d/%d %s %d$
|
and the script:
Code: |
#additem PartyMembers %1
#VAR PartyMembersHP %2
#VAR PartyMembersMaxHP %3
#SHOW Evaluating : @PartyMembersHP / @PartyMembersMaxHP
#VAR PartyMemberPercent (@PartyMembersHP * 1.0 / @PartyMembersMaxHP)
#SHOW doesn't work: PartyMemberPercent: @PartyMemberPercent
#IF (@PartyMemberPercent > 0.5 ) {#SHOW %1 needs help} {#SHOW %1 is fine}
|
and the output.
Code: |
Leader: Vlad
Hits Energy Moves Exp
---- ------ ----- ---
[ 79 Ran Orc ] Vlad 724/1403 555/608 184/184 28193730
[ 75 Mob Fel ] Sabrina 715/751 268/268 287/287 0
<724hp 555e 184mv 184wm 28193730xp SU> Evaluating : 724 / 1403
Evaluating : 715 / 751
doesn't work: PartyMemberPercent: 0.952063914780293
Sabrina needs help
doesn't work: PartyMemberPercent: 0.952063914780293
Vlad needs help
|
|
|
|
![](templates/Classic/images/spacer.gif) |
gamma_ray Magician
Joined: 17 Apr 2005 Posts: 496
|
Posted: Fri Aug 31, 2007 4:01 pm |
It does look like a synch issue to me, since you can see the last line shown in the Evaluating: ##/## is always correct, and all of the rest are using the percentage from that line. Sounds silly, but have you tried closing and reopening CMud?
|
|
|
![](templates/Classic/images/spacer.gif) |
haiku Wanderer
Joined: 19 Nov 2004 Posts: 70
|
Posted: Fri Aug 31, 2007 4:03 pm |
as a matter of fact I have. I got the first sample output last night after tanking for several hours (manually, ugh). I tried again this morning and got something similiar - although, the first time I tried it I got
doesn't work: PartyMemberPercent: 1
doesn't work: PartyMemberPercent: 1
Let me close and reopen it and see if I can reproduce that. |
|
|
![](templates/Classic/images/spacer.gif) |
charneus Wizard
![](images/avatars/51564989746d852114da6d.jpg)
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Fri Aug 31, 2007 4:07 pm |
Question: Why are you assigning the variables? Do you use them for any other script? If not, you could shorten up your code quite a bit (and possibly save some trouble).
What appears to be happening is the code is taking in the entire input, and using the last line in the series to determine the values. Example:
Code: |
Charneus 1/100
Vlad 2/100
Sabrina 3/100
|
Your trigger is taking the three outputs, but will always show PartyMemberPercent at .03 because that was the last value inputted. That does seem like it's a serious problem - but it may be easily fixed.
Don't know if this will work, but try changing the code to:
Code: |
#SHOW Evaluating : %2 / %3
#SHOW doesn't work : Percentage: %float(%eval(%2/%3))
#IF (%float(%eval(%2/%3)) > 0.5) {#SHOW %1 is fine.} {#SHOW %1 needs help.}
|
Sorry... had to switch computers, so I just re-edited this one.
Charneus
Another edit: By the way, your code shows that if their percentage is higher than 50%, then they need help? Otherwise, they're fine? Might want to rethink that one. I always assume that if it's lower than 50%, they need help. ;)
Oo... another edit:
If you want to get rid of the %floats, you can probably make it a bit easier by doing this:
Code: |
#SHOW Evaluating : %2 / %3
#SHOW doesn't work : Percentage: (%eval((%2/%3)*100))
#IF (%eval((%2/%3)*100)) > 50) {#SHOW %1 is fine.} {#SHOW %1 needs help.}
|
|
|
|
![](templates/Classic/images/spacer.gif) |
haiku Wanderer
Joined: 19 Nov 2004 Posts: 70
|
Posted: Fri Aug 31, 2007 4:30 pm |
Thanks charneus. Much appreciated. Yeah, I tried to point out that I was aware of the logic bug in the original post .. what you were seeing (>50 needing help :P was a copy/paste error :)
Looks like the bug is fixed now. I'll bookmark this page for future reference. Thanks!
Code: |
Hits Energy Moves Exp
---- ------ ----- ---
[ 79 Ran Orc ] Vlad 803/1383 559/608 188/207 19215706
[ 75 Mob Fel ] Sabrina 751/751 268/268 302/302 0
<h|803hp 559e 188mv 188wm 19215706xp ES> Evaluating : 803 / 1383
Evaluating : 751 / 751
doesn't work : Percentage: 1
Sabrina is fine.
doesn't work : Percentage: 0
Vlad needs help.
|
|
|
|
![](templates/Classic/images/spacer.gif) |
haiku Wanderer
Joined: 19 Nov 2004 Posts: 70
|
Posted: Fri Aug 31, 2007 4:39 pm |
Oh you know what? It still doesn't appear to work quite right. After closing and reopening zmud, and changing the trigger:
Code: |
Leader: Vlad
Hits Energy Moves Exp
---- ------ ----- ---
[ 79 Ran Orc ] Vlad 876/1383 608/608 226/226 18703504
[ 75 Mob Fel ] Sabrina 746/751 268/268 299/299 0
<876hp 608e 226mv 226wm 18703504xp NSW> Evaluating : 876 / 1383
Evaluating : 746 / 751
Percentage: 0.993342210386152
Sabrina is fine.
Percentage: 0.633405639913232
Vlad is fine.
|
Here's the new trigger:
Code: |
#additem PartyMembers %1
#SHOW Evaluating : %2 / %3
#SHOW Percentage: %float(%eval(%float(%2)/%float(%3)))
#IF (%float(%eval(%float(%2)/%float(%3))) > 0.5) {#SHOW %1 is fine.} {#SHOW %1 needs help.}
|
and of course it makes perfect sense... by not turning it into a float before the division, we're doing integer math, and then converting the resulting integer into a float. which doesn't quite work. Thanks for the assistance again! |
|
Last edited by haiku on Fri Aug 31, 2007 4:42 pm; edited 1 time in total |
|
|
![](templates/Classic/images/spacer.gif) |
charneus Wizard
![](images/avatars/51564989746d852114da6d.jpg)
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Fri Aug 31, 2007 4:39 pm |
Edit: Ninja'd by the haiku!
Content removed to avoid future confusion! In other words, haiku fixed it before I could point out the other problem.
Charneus |
|
Last edited by charneus on Fri Aug 31, 2007 4:47 pm; edited 1 time in total |
|
|
![](templates/Classic/images/spacer.gif) |
haiku Wanderer
Joined: 19 Nov 2004 Posts: 70
|
Posted: Fri Aug 31, 2007 4:45 pm |
and just in case anyone gets confused by the timing, the trigger is fixed, and my post above has been updated to show the correct data/trigger.
|
|
|
![](templates/Classic/images/spacer.gif) |
charneus Wizard
![](images/avatars/51564989746d852114da6d.jpg)
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Fri Aug 31, 2007 4:54 pm |
By the way, if you want to get rid of the excess numbers (anything after 2 decimal places I consider redundant), just use %format.
Code: |
#SHOW Percentage: %format(2,(%float(%eval(%float(%2)/%float(%3))))
|
Then it should only display 0.63 instead of 0.6323425282491. Makes it a bit easier. Or...
Code: |
#SHOW Percentage: %format(1,%eval(%float(%eval(%float(%2)/%float(%3)))*100))~%
|
I don't have CMUD in front of me, so I'm just adding in what I remember. If the above code works, it should display 63.3% or whatever. I'm all about pretty writing! :P
Charneus |
|
|
![](templates/Classic/images/spacer.gif) |
haiku Wanderer
Joined: 19 Nov 2004 Posts: 70
|
Posted: Fri Aug 31, 2007 4:56 pm |
oh, the #SHOWs are just for debugging purposes. Once I've got a trigger working I generally strip them out. Is there a #COMMENT to explain triggers? With cmud's package system, I'd think that would be useful.
|
|
|
![](templates/Classic/images/spacer.gif) |
charneus Wizard
![](images/avatars/51564989746d852114da6d.jpg)
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Fri Aug 31, 2007 5:07 pm |
Weird. Thought I had posted my comment. But I believe there is no #COMMENT command. I just alias a helpfile to explain it. ;)
Charneus |
|
|
![](templates/Classic/images/spacer.gif) |
gamma_ray Magician
Joined: 17 Apr 2005 Posts: 496
|
Posted: Fri Aug 31, 2007 5:11 pm |
The Notes box?
Or you can use ; to comment lines inside the trigger, but I like the Notes box. |
|
|
![](templates/Classic/images/spacer.gif) |
Larkin Wizard
![](images/avatars/169979204542c57c7448618.gif)
Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Fri Aug 31, 2007 6:14 pm |
I saw behavior like this in zMUD, and it was fixed by putting the entire script code inside a #PRIORITY block. You mentioned zMUD, and I'm wondering now if it was a slip and you meant to say CMUD or if you're trying to do this in zMUD and posted in the wrong forum. ![Smile](images/smiles/icon_smile.gif)
|
|
|
![](templates/Classic/images/spacer.gif) |
haiku Wanderer
Joined: 19 Nov 2004 Posts: 70
|
Posted: Fri Aug 31, 2007 7:20 pm |
Yup, I slipped. I meant cMud. I think that ZMud version 1.34 wouldn't have been able to handle this :)
|
|
|
![](templates/Classic/images/spacer.gif) |
|
|