PowTTY xpcounter help?

Here we discussed clients, mappers, tunnels and their settings.
Locked
Materia
Posts: 12
Joined: Tue Jul 29, 2008 5:39 pm

PowTTY xpcounter help?

Post by Materia »

Hi, I have used Axel's xp counter for a while, and Lessar added a wp counter to it a while back. I have been bored and wanted to see if I can change it to show your session time (in minutes, I am not skilled enough to figure out the math scripts to make it hour:minute yet) and your next level. Right now I was just trying to get it to show the minutes, and current level (I can do the var+1 later) but I can't get it to show level!

Here is my current script:

Code: Select all

#alias xpcounterreset={xpreset|tpreset|wpreset|xp|#var $xpcal=1}
#action >+xp0 Welcome to the land of Middle Earth.={#print|wpreset|xpreset|tpreset|xp|#var $xpcal=1}
#action >+xp1 XPCOUNTER: &1 &2 &3 &4 &5 (&6) &7 &8.={#if ($xpcal=="1") {xpcalc $1 $2 $6 $7 $8\|#var $xpcal=0}\|xpprint $1 $2 $3 $4 $6 $7 $8}
#action >+xp2 ^You receive your share of experience.={#print|xp|#var $xpcal=1}
#action >+xp3 ^You feel more experienced.={#print|xp|#var $xpcal=1}
#action >+xp4 XPCOUNTER: &1 &2 &3 &4 unknown at war &7 &8.={#if ($xpcal=="1") {xpcalc $1 $2 0 $7 $8\|#var $xpcal=0}\|xpprint $1 $2 $3 $4 0 $7 $8}
#action >+xp5 ^You are dead! Sorry...={#print|xp|#var $xpcal=1}

#alias xp=info XPCOUNTER: %x %t %X %T %K %L %l.
#alias xpcalc={#var $gainxp=($1-@oldxp)|#var $gaintp=($2-@oldtp)|#var $gainwp=($3-@oldwp)|#if (@oldxp==0) {#var $gainxp=0|#var $sessxp=0}|#if (@oldtp==0) {#var $gaintp=0|#var $sesstp=0}|#if (@oldwp==0) {#var $gainwp=0|#var $sesswp=0}|#var $sessxp=((%($sessxp))+(%($gainxp)))|#var $sesstp=((%($sesstp))+(%($gaintp)))|#var $sesswp=((%($sesswp))+(%($gainwp)))|#var @oldwp=$3|#var @oldxp=$1|#var @oldtp=$2}
#alias xpprint={#print ("\015\012"+$bgr+"-->"+$noattr+" Gained   xp: "+$bwh+($gainxp)+$noattr+"\015\011\011\011\011tp: "+$bwh+($gaintp)+$noattr+"\015\011\011\011\011\011\011wp: "+$bwh+($gainwp)+$noattr )\|#print ($bgr+"-->"+$noattr+" Trip     xp: "+($sessxp)+"\015\011\011\011\011tp: "+($sesstp)+"\015\011\011\011\011\011\011wp: "+($sesswp)+"\015\011\011\011\011\011\011\011\011time: $7 min"+$noattr)\|#print ($bgr+"-->"+$noattr+" Needed   xp: $3\015\011\011\011\011tp: $4\015\011\011\011\011\011\011wp: $5 total\015\011\011\011\011\011\011\011\011Nxlv: $8"+$noattr)}

#alias xpreset={#var $sessxp=0|#var @oldxp=0}
#alias tpreset={#var $sesstp=0|#var @oldtp=0}
#alias wpreset={#var $sesswp=0|#var @oldwp=0}

#alias xpoff={#action -xp0|#action -xp1|#action -xp2|#action -xp3|#action -xp4}
#alias xpon={#action +xp0|#action +xp1|#action +xp2|#action +xp3|#action +xp4}

#(@oldtp = 0, @oldxp = 0, @oldwp = 0)

#($bgr = "\033[1m\033[32m")
#($bwh = "\033[1m")
#($noattr = "\033[0m")

#($gaintp = "0")
#($gainxp = "0")
#($gainwp = "0")
#($sesstp = "0")
#($sessxp = "0")
#($sesswp = "0")
#($xpcal = "0")
This should all seem well, but when I kill something or type xp (to trigger it), it does not show the level and instead shows:

Code: Select all

!# CW>xp
[info XPCOUNTER: %x %t %X %T %K %L %l.]

--> Gained   xp: 0              tp: 0           wp: 0
--> Trip     xp: 0              tp: 0           wp: 0           time: 18 min
--> Needed   xp: 181919         tp: 0           wp: 1 total     Nxlv:
Anyone know what I am doing wrong?

*Edit: Also, it seems to stick on the %L, stayed at 18 minutes whole session.
Jahara
Posts: 228
Joined: Sat Feb 23, 2008 9:55 pm
Location: Indiana, USA
Contact:

Re: PowTTY xpcounter help?

Post by Jahara »

Here is my version of the PowTTY xp counter:

Code: Select all

#alias trip={#send ("emote has received " + %(@xpcnt_session_xp) + " xp and " + %(@xpcnt_session_tp) + " tp on this trip.")}
#alias gain={#send ("emote received " + %(@xpcnt_gain_xp) + " xp and " + %(@xpcnt_gain_tp) + " tp from the last kill.")}
#alias hour={#send ("emote is averaging " + %(@xpcnt_hour_xp/1000) + "k xp and " + %(@xpcnt_hour_tp) + " tp per hour.")}
#alias tnl={#send ("emote needs " + %(@xpcnt_need_xp/1000) + "k xp and " + %(@xpcnt_need_tp) + " tp to reach the next level.")}

#(@xpcnt_hour_xp = 0)
#(@xpcnt_hour_tp = 0)
#(@xpcnt_gain_tp = 0)
#(@xpcnt_gain_xp = 0)
#(@xpcnt_session_tp = 0)
#(@xpcnt_session_xp = 0)
#(@xpcnt_session_time = 1)
#(@xpcnt_calculate = 1)
#(@xpcnt_old_tp = 0)
#(@xpcnt_old_xp = 0)

#alias xp+={#action +xp2|#(@xpcnt_timer = (timer))}
#alias xp-={#action -xp2}

#al xp={#send ("info XPCOUNTER: %x %t %X %T %L.")}
#al xpreset={#if ("$0"=="") #var @xpcnt_session_xp=0| #else #var @xpcnt_session_xp=$0|#var @xpcnt_session_time=1}
#al tpreset={#if ("$0"=="") #var @xpcnt_session_tp=0| #else #var @xpcnt_session_tp=$0|#var @xpcnt_session_time=1}

#al xpcalc={#(@xpcnt_gain_xp=$1-@xpcnt_old_xp)|#(@xpcnt_gain_tp=$2-@xpcnt_old_tp)|#(@xpcnt_session_xp+=@xpcnt_gain_xp)|#(@xpcnt_session_tp+=@xpcnt_gain_tp)|#(@xpcnt_old_xp=$1)|#(@xpcnt_old_tp=$2)|#(@xpcnt_need_xp=$3)|#(@xpcnt_need_tp=$4)}

#alias ratecalc={#(@xpcnt_session_time=$1)|#(@xpcnt_hour_xp=60*@xpcnt_session_xp/@xpcnt_session_time)|#(@xpcnt_hour_tp=60*@xpcnt_session_tp/@xpcnt_session_time)}

#al xpprint={#print ("- Gained:  xp: " + %(@xpcnt_gain_xp) + "\011\011tp: "+ %(@xpcnt_gain_tp) )|#print ("- Trip:    xp: " + %(@xpcnt_session_xp) + "\011\011tp: " + %(@xpcnt_session_tp) + "  \011\011Session: " + %(@xpcnt_session_time) + " min.")|#print ("- Needed:  xp: " + %(@xpcnt_need_xp) + "\011\011tp: " + %(@xpcnt_need_tp))|#print ("- Rate:    xp: " + %(@xpcnt_hour_xp) + "\011\011tp: " + %(@xpcnt_hour_tp))}

#ac >+xp2 ^You receive your share of experience.={#print|#if (((timer-@xpcnt_timer)) > 5) {#(@xpcnt_timer=timer)|#var @xpcnt_calculate=1|xp}}

#ac >+xp1 XPCOUNTER: $1 $2 $3 $4 $5.={#if (@xpcnt_calculate==1) {#(@xpcnt_calculate=0)|xpcalc $1 $2 $3 $4}|ratecalc $5|xpprint}

#ac >-xp0 ^Welcome to the land of Middle Earth.={#print|xpreset|tpreset|xp|#var @xpcnt_calculate=1}
#ac >-xp3 ^Reconnecting.={#print|xpreset|tpreset|xp|#var @xpcnt_calculate=1}

If that helps :-)
Materia
Posts: 12
Joined: Tue Jul 29, 2008 5:39 pm

Re: PowTTY xpcounter help?

Post by Materia »

Sort of, looks complicated! I'll have to try to add my wp counter into that and see how it goes.

BTW Jahara, could you explain to me what the \015 and \011 is doing? I realize its some sort of placeholder, but thats all I have grasped so far. :p And do you know what I may have done wrong in my script above? (I'm trying to get a deeper understanding of the way powtty works with its microlanguage.)
Elestir
Posts: 231
Joined: Sat Feb 23, 2008 11:47 pm
Location: Olomouc, Czech Republic
Contact:

Re: PowTTY xpcounter help?

Post by Elestir »

Materia wrote:...but I can't get it to show level! ... Anyone know what I am doing wrong?
In your code, you call alias xpprint on 2 places like this:

Code: Select all

xpprint $1 $2 $3 $4 $6 $7 $8
xpprint $1 $2 $3 $4 0 $7 $8
As you can see, each time, you call it with 7 arguments. In the body of the xpprint alias you try to use 8 arguments though. 8th which is expected to contain the level is always undefined and hence empty string.
I.e. your $1-$4 becomes $1-$4 in xpprint, $6 or 0 becomes $5, $7 becomes $6 and $8 becomes $7.

Also I would use numeric variables for numbers, no idea why Axel used string variables.
I am talking about stuff like:

Code: Select all

  why this: if ($varname=="1") do_something
if you can: if (@varname==1) do_something
I myself prefer the to use 3-state numeric variables for switches, where -1 means false, +1 true and 0 means undefined. Then in aliases i just:

Code: Select all

    if (@varname>0) do_something
or: if (@varname>=0) do_something
...depending on if I want the default (undefined) to work like true (1) or false (-1).

Also you can save bit space and make things more readable if

Code: Select all

instead of: #alias xpreset={#var $sessxp=0|#var @oldxp=0}
        do: #alias xpreset=#(@sessxp=@oldxp=0)
Materia
Posts: 12
Joined: Tue Jul 29, 2008 5:39 pm

Re: PowTTY xpcounter help?

Post by Materia »

EDIT: Nevermind, I'm an idiot. You meant when I call it via the xpprint alias that will SHOW it I need to use the lesser value, rather than what I am setting it at first.

Well, that should function right (I'll test in the morning!) now I just got to implement Jahara's hourly rate calc!

Thanks. :)
Elestir
Posts: 231
Joined: Sat Feb 23, 2008 11:47 pm
Location: Olomouc, Czech Republic
Contact:

Re: PowTTY xpcounter help?

Post by Elestir »

Materia wrote:EDIT: Nevermind, I'm an idiot. You meant when I call it via the xpprint alias that will SHOW it I need to use the lesser value, rather than what I am setting it at first.

Well, that should function right (I'll test in the morning!) now I just got to implement Jahara's hourly rate calc!

Thanks. :)
I am not sure you got it right.
$0-$9 are local variables assigned during call (usage) of any alias. E.g., if you do:

Code: Select all

xpprint a b c
Then during execution of the xpprint alias, $0 will be set to "a b c", $1 will be set to "a", $2 to "b", $3 to "c".
If you do something like this:

Code: Select all

#alias test=xpprint $3 $2 $1
test a b c
Then during the execution of the test alias, $0 is "a b c", $1 is "a", $2 is "b" and $3 is "c", but during the inner execution of the nested xpprint alias, $0 is "c b a", $1 is "c", $2 is "b" and $3 is "a" (and $4-$9 will be empty strings "" in both cases).
Your problem is you are not giving any 8th argument when calling xpprint, i.e. for you $8 is always "" and your level info is in fact assigned to $7 (as it is the 7th argument).
Materia
Posts: 12
Joined: Tue Jul 29, 2008 5:39 pm

Re: PowTTY xpcounter help?

Post by Materia »

Yeah, I had it. I just didn't word it correctly :).
Jahara
Posts: 228
Joined: Sat Feb 23, 2008 9:55 pm
Location: Indiana, USA
Contact:

Re: PowTTY xpcounter help?

Post by Jahara »

I should probably mention that my xp counter has a built in timer which only loots if it hasn't looted in the past 5 seconds. This is useful for quaking and you kill a bunch of mobiles at once.
Materia
Posts: 12
Joined: Tue Jul 29, 2008 5:39 pm

Re: PowTTY xpcounter help?

Post by Materia »

I guess by loot you mean show?

Ok, I've got it functioning! (I'm going to clean up the code soon, and add some of Jahara's snippets.)

Code: Select all

#alias xpcounterreset={xpreset|tpreset|wpreset|xp|#var $xpcal=1}
#action >+xp0 Welcome to the land of Middle Earth.={#print|wpreset|xpreset|tpreset|xp|#var $xpcal=1}
#action >+xp1 XPCOUNTER: &1 &2 &3 &4 &5 (&6) &7 &8.={#if ($xpcal=="1") {xpcalc $1 $2 $6 $8|#var $xpcal=0}|xpprint $1 $2 $3 $4 $6 $7}
#action >+xp2 ^You receive your share of experience.={#print|xp|#var $xpcal=1}
#action >+xp3 ^You feel more experienced.={#print|xp|#var $xpcal=1}
#action >+xp4 XPCOUNTER: &1 &2 &3 &4 unknown at war &7 &8.={#if ($xpcal=="1") {xpcalc $1 $2 0 $8|#var $xpcal=0}|xpprint $1 $2 $3 $4 0 $7}
#action >+xp5 ^You are dead! Sorry...={#print|xp|#var $xpcal=1}

#alias xp=info XPCOUNTER: %x %t %X %T %K %L %l.
#alias xpcalc={#var $gainxp=($1-@oldxp)|#var $gaintp=($2-@oldtp)|#var $gainwp=($3-@oldwp)|#var $nxtlv=($4+1)|#if (@oldxp==0) {#var $gainxp=0|#var $sessxp=0}|#if (@oldtp==0) {#var $gaintp=0|#var $sesstp=0}|#if (@oldwp==0) {#var $gainwp=0|#var $sesswp=0}|#var $sessxp=((%($sessxp))+(%($gainxp)))|#var $sesstp=((%($sesstp))+(%($gaintp)))|#var $sesswp=((%($sesswp))+(%($gainwp)))|#var @oldwp=$3|#var @oldxp=$1|#var @oldtp=$2}
#alias xpprint={#print ("\015\012"+$bgr+"-"+$noattr+" Gained   xp: "+$bwh+($gainxp)+$noattr+"\015\011\011\011\011tp: "+$bwh+($gaintp)+$noattr+"\015\011\011\011\011\011\011wp: "+$bwh+($gainwp)+$noattr )\|#print ($bgr+"-"+$noattr+" Trip     xp: "+($sessxp)+"\015\011\011\011\011tp: "+($sesstp)+"\015\011\011\011\011\011\011wp: "+($sesswp)+"\015\011\011\011\011\011\011\011\011in: $6 min"+$noattr)\|#print ($bgr+"-"+$noattr+" Needed   xp: $3\015\011\011\011\011tp: $4\015\011\011\011\011\011\011wp: $5 total\015\011\011\011\011\011\011\011\011to: "+($nxtlv)+$noattr)}

#alias xpreset={#var $sessxp=0|#var @oldxp=0}
#alias tpreset={#var $sesstp=0|#var @oldtp=0}
#alias wpreset={#var $sesswp=0|#var @oldwp=0}

#alias xpoff={#action -xp0|#action -xp1|#action -xp2|#action -xp3|#action -xp4}
#alias xpon={#action +xp0|#action +xp1|#action +xp2|#action +xp3|#action +xp4}

#(@oldtp = 0, @oldxp = 0, @oldwp = 0)

#($bgr = "\033[1m\033[32m")
#($bwh = "\033[1m")
#($noattr = "\033[0m")

#($nxtlv = "0")
#($gaintp = "0")
#($gainxp = "0")
#($gainwp = "0")
#($sesstp = "0")
#($sessxp = "0")
#($sesswp = "0")
#($xpcal = "0")
Thanks Jahara and Elestir!

*Although, I have some #print error when I take out most of the \015\011\011 in order to make it kinda shorter like Jahara's (just \011\011).

**Fixed that for the most part, I'm guessing \015 is some sort of thing that disregards anything written in front of it as a placement, and \011 is 5 blank spaces.
Drugo
Posts: 478
Joined: Sun Feb 24, 2008 5:02 pm
Location: Italy

Re: PowTTY xpcounter help?

Post by Drugo »

Reading from powwow documentation the \XXX notation is for inserting special characters in octal notation.
so \011 octal is 9 decimal and is the TAB char, and \015 octal is 13 decimal and is the CR char
Hope this helps
Drugo
Locked