|
Eraldo Beginner
Joined: 05 Aug 2003 Posts: 17 Location: Austria
|
Posted: Wed Apr 18, 2007 10:55 pm
Gain / Loss - Prompt |
Greetings !
In my promt there are hitpoints spellpoints etc....
Unfortunately my promt is rather long:
Code: |
[Eraldo 23:42:41 397/399 68/93 20/123 9999 5498574 be -(im Kampf)0-Erdaura I0] |
So i'll take a different promt to simplify matters:
I used a Trigger looking like this:
Code: |
#TRIGGER {^~[&%d{Char.HP}/&%d{Char.HPmax} &%d{Char.SP}/&%d{Char.SPmax} &%d{Char.mp}~]} {#sub ">"} |
Now I decided that it would be cool to see in the prompt if there where any gains or losses...
Example: Lets asume I had 40 hitpoints, 30 spellpoints and 400 mana...
now the promt
was sent by the mud....
thats a gain of 20 hp and a loss of 100 mana (sp staying the same)
so here the prompt should show
instead of
for no gain / loss
I know that i could get this result by using a promt trigger like this:
Code: |
#TRIGGER {^~[(%d)/(%d) (%d)/(%d) (%d)]} {
#IF (%1 != @hp) {#MATH hpgain %1-@hp;#IF (@hpgain > 0) {#VAR hpgain +[@hpgain]} {}} {#VAR hpgain 0}
#IF (%3 != @sp) {#MATH spgain %3-@sp;#IF (@spgain > 0) {#VAR spgain +[@spgain]} {}} {#VAR spgain 0}
#IF (%5 != @mp) {#MATH mpgain %5-@mp;#IF (@mpgain > 0) {#VAR mpgain +[@mpgain]} {}} {#VAR mpgain 0}
#IF (@hpgain or @spgain or @mpgain) {#SUB %ansi(white)~[%ansi(red)@hpgain %ansi(blue)@spgain %ansi(magenta)@mpgain%ansi(white)~]}
} |
(Code not be working ...I wrote that from my head right now but I hope its clear what I mean)
The problem is that the promt substituting seems to allready take some time (i see the prompt when walking fast)
so I have a bad feeling about having so much functions in such an important trigger... which has to fire so often...
Furthermore I know that my coding is not very neat nor that effective...
If one of you nice people out there could show me a more professional way getting where I want,
I would be veeery thankful !!! |
|
|
|
Tech GURU
Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: Thu Apr 19, 2007 7:45 pm |
Try this...
Code: |
#TRIGGER {^(~[(%d)/(%d) (%d)/(%d) (%d)])} {
$hp=@hp
$mp=@mp
$sp=@sp
$hpgain=0
$spgain=0
$mpgain=0
#IF (%2 != $hp) {$hpgain=(%2-$hp);#IF ($hpgain > 0) {$hpgain="+"+$hpgain} }
#IF (%4 != $mp) {$mpgain=(%4-$mp);#IF ($mpgain > 0) {$mpgain="+"+$mpgain} }
#IF (%6 != $sp) {$spgain=(%6-$sp);#IF ($spgain > 0) {$spgain="+"+$spgain} }
$prompt=%ansi(white)~[%ansi(red)$hpgain+ " " +%ansi(magenta)$mpgain+ " "+ %ansi(blue)$spgain %ansi(white)~]
#IF ($hpgain or $spgain or $mpgain) {#SUB $prompt}
hp=%2
mp = %4
sp=%6
}
|
I changed most of your variable references to local variables for speed and cleanup some of text processing.
If you prompt values don't change the regular prompt is displayed. |
|
_________________ Asati di tempari! |
|
|
|
Eraldo Beginner
Joined: 05 Aug 2003 Posts: 17 Location: Austria
|
Posted: Fri Apr 20, 2007 12:58 am |
Wow,.. now that reply came faster than I thought !
-Thanks
However ... I have to admit that I am not familiar with the '$' Prefix for Variables ?!
I tried to find some information in the documentation... but nothing...
May I ask for a link where I can read about that ?
Maybe if I understand the trigger better i can get it to work... so far I could not.
Further I'd like to know if it is wiser to use mxp coloring(<color red></color>) oder ansi(%ansi)
...thinking of speed |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Fri Apr 20, 2007 1:05 am |
It's a CMUD feature, not a zMUD one. In CMUD, $ prefixes local variables like @ prefixes normal ones.
You should be able to accomplish the same thing that Tech is doing in zMUD by removing the first three lines of the script ($name=@name) and then changing all the other local variable references to normal ones. |
|
|
|
Tech GURU
Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: Fri Apr 20, 2007 1:23 am |
Doh!! I'm soo CMUD focused now I didn't even notice I did this for the zMUD forums.
I think it's time you upgraded. :) |
|
_________________ Asati di tempari! |
|
|
|
Eraldo Beginner
Joined: 05 Aug 2003 Posts: 17 Location: Austria
|
Posted: Fri Apr 20, 2007 2:10 am |
;)
I fear that I would spend hours and hours updating my triggers to cmud quality (local vars etc)
But I _am_ thinking about that change ^^
Thanks for the replies! |
|
|
|
|
|