Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Amylon
Novice


Joined: 31 Jan 2003
Posts: 49
Location: Australia

PostPosted: Wed Feb 05, 2003 7:54 am   

#echoing a stringlist in list form
 
Greetings fellow Zmudians,
I have a question for you all, does anyone know how I can use this:
#var players Traer|Drake|Synn|Jasmine|Valandra|Rangek|Dimm|Mastermune

and make an #echo that will look like this?
---------
Players
---------
Traer
Drake
Synn
Jasmine
Valandra
Rangek
Dimm
Mastermune

I can do the first bit easy enough (the 2 lines and players tile) but what I need help with is breaking the string down again so it will echo as a list instead of a string with |.

Any help greatly appreciated.

Amylon

--------------------
#trigger {(*) tells you, '} {tell %1 NO}
--------------------
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Wed Feb 05, 2003 8:13 am   
 
Try something like:

#ECHO ---------
#ECHO Players
#ECHO ---------
#FORALL @players {#ECHO %i}

Ton Diening
Reply with quote
Amylon
Novice


Joined: 31 Jan 2003
Posts: 49
Location: Australia

PostPosted: Wed Feb 05, 2003 8:19 am   
 
Thank you! This forum is incredible, Ton answered my question in less than 20 minutes!
Three Cheers for the Zmudian elite!


--------------------
#trigger {(*) tells you, '} {tell %1 NO}
--------------------
Reply with quote
Mathian
Newbie


Joined: 30 Apr 2004
Posts: 9
Location: Australia

PostPosted: Thu May 06, 2004 9:25 am   
 
Ok then, I have a stringlist that has spaces in it like this:
Cohosh 18|Bellwort 16|Deathdust 67

And I would like it to echo like this:
Code:
Cohosh            18
Bellwort          16
Deathdust         67


Instead of like this:
Cohosh 18
Bellwort 16
Deathdust 67

Any ideas?
Thanks in advance!


edited to actually show what I meant!
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Thu May 06, 2004 10:26 am   
 
Ok if what your getting at is linning up the numbers this leaps into my mind *TESTED*

#FORALL @players {#ECHO %word( "%i", 1)%repeat( " ", 25-%len( %word( "%i", 1)))%word( "%i", 2)}
Reply with quote
Mathian
Newbie


Joined: 30 Apr 2004
Posts: 9
Location: Australia

PostPosted: Thu May 06, 2004 11:54 am   
 
You rock!
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Thu May 06, 2004 2:14 pm   
 
Of course I forget to Mention Using Data Records (not to be confused with Zmuds Database Module) would probaly be eaiser to update and has a lot of nifty features. as an example if your storing Names and Levels

Data to add:
char1 lvl 5
char2 lvl 39
char3 lvl 12

Code stuffs to enter it
PLevels.char1=5
Plevel.char2=39
Plevel.char3=12

Code Stuffs to retrieve it.
#LOOPDB @Plevel {#SHOW "Player %key is level %val}
or
#SHOWDB @PLevel
or
#SHOW %expanddb(@PLevel,%crlf,": ")


Using those commands and functions among others you could loop through the record and easily show how many are of a certain level, or who all is a certain level etc, plus if the level changes its easier to change then a string list.
Reply with quote
remus
Wanderer


Joined: 06 Jul 2002
Posts: 53
Location: Australia

PostPosted: Fri Nov 26, 2004 11:49 am   
 
I was wondering how that could be applied within the #stat window?

I have a list that captures my who list names and levels like this:

TA- 3|UW- 1 [ Baron 81] Reggy Parker is stranger
NoCln|NoTmp [ Lord 57] Kannis Jacker is Wierd

#TR {(%d)] (%w)} {#add cwho "%2 %1"}

At present I just have my #stat window value set like this:

WHO
%item( @cwho, "1")
%item( @cwho, "2")
%item( @cwho, "3")
%item( @cwho, "4")
%item( @cwho, "5")
%item( @cwho, "6")
%item( @cwho, "7")
%item( @cwho, "8")
%item( @cwho, "9")
%item( @cwho, "10")

but this shows like this

Kannis 81
Reggy 57

What I want is

Kannis 81
Reggy 57

Also is there a better way to do my #stat window?

Any ideas?
_________________
Once the Known was unknown now its Known...
Do you know it???
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Fri Nov 26, 2004 11:55 am   
 
Instead of all those seperate items you could use this [read the helpfile for correct syntax this is off thetop of my head]

%expandlist(@Cwho,%cr)

as for spacing it out Ill have to get back to ya right now I need sleep :p
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
remus
Wanderer


Joined: 06 Jul 2002
Posts: 53
Location: Australia

PostPosted: Sun Nov 28, 2004 6:49 pm   
 
Thanks for the Expandlist commmand that has been a total help to me in more ways than just the status window. I find it amazing that the smallest things often change so much. I have basically rewritten a heap of string related commands and such after just learning this simple thing.

Thanks Nexela.
Any luck with the spacing issue?

Thanks
_________________
Once the Known was unknown now its Known...
Do you know it???
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Mon Nov 29, 2004 12:42 am   
 
Since your entire list uses the form "%w %d", you can easily convert it to a record variable. Simple code to do the conversion and update your current trigger.

#VAR tempcwho {%replace(@cwho," ","=")}
#VAR cwho {}
#ADDKEY cwho {@tempcwho}
#UNVAR tempcwho
#TR {(%d)] (%w)} {#addkey cwho "%2 %1"}

Next we use a a somewhat complex expansion trick to format it in the status window. There probably is another way to do it (something involving %subregex), but I can't quite think of it right now.
#STAT {%expandlist(%exec(%literal(#LOOPDB @cwho {%format("&s&12.0f",%key,%val)})),%cr)}
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
remus
Wanderer


Joined: 06 Jul 2002
Posts: 53
Location: Australia

PostPosted: Mon Nov 29, 2004 9:40 am   
 
So then I would have this?

#TR {(%d)] (%w)} {#addkey cwho "%2 %1"}

And all the rest above in the who alias like this?

#alias who
Value:
#VAR tempcwho {%replace(@cwho," ","=")}
#VAR cwho {}
#ADDKEY cwho {@tempcwho}
#UNVAR tempcwho
~who

And then this line in the status window?

%expandlist(%exec(%literal(#LOOPDB @cwho {%format("&s&12.0f",%key,%val)})),%cr)
_________________
Once the Known was unknown now its Known...
Do you know it???
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Mon Nov 29, 2004 11:06 am   
 
You got the trigger and status window stuff right. The rest is just a one time thing that you put in the command line to convert your variable from a list to a record.
#VAR tempcwho {%replace(@cwho," ","=")}
#VAR cwho {}
#ADDKEY cwho {@tempcwho}
#UNVAR tempcwho
Goes directly in the command once then is done.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
remus
Wanderer


Joined: 06 Jul 2002
Posts: 53
Location: Australia

PostPosted: Mon Nov 29, 2004 11:59 am   
 
It works as far as creating a #var cwho that looks like this:

Gary 45||jeremy 53||mark 12||Jamie 12||

But the status window doesnt work at all.

Also it causes the other stuff within the Status window to flicker as if something is trying to constantly refresh the window behind the scenes.
#LOOPDB is also causing an error in scripting but I am assuming this is to do with a # being within {} which zmud doesnt like?
_________________
Once the Known was unknown now its Known...
Do you know it???
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Mon Nov 29, 2004 1:32 pm   
 
First of all I wouldn't recomend using #Commands via %exec in the status window so I did some thinking on how this could be accomplished more to come in a minute.

For you problem with the variable it is looking like you will prolly have to manualy change it to a data record. or if you have a backup try this instead one time command line entry script then you might be able to use Vijilantes method (I havn't tested his) or my method

#VAR tempcwho {@cwho}
#VAR cwho ""
#FORAL @tempcwho {#ADDKEY cwho %i}
#UNVAR tempcwho

After we have our new DB all figured out we move on to step two an expression trigger to create a formated string list. It is run anytime a variable is updated or changed can't remember which but in either case should be what we want. *please note this might not export correctly*

#TRIGGER (1=1) {
#VAR statcwho ""
#LOOPDB @cwho {#ADDITEM statcwho {%format( "&-10s&5.0f", %key, %val)}}
}

In the %format the -10 is the left justification of the key string. change this to be a couple spaces bigger then the length of your longest name in the DB (keep the -), The 5.0 is the right justification of the numerical value with no decimals if you want them to be lined up with the highest place digit use just .0 else change the 5 to the length of the biggest number you will store +1 or keep as is.


Now in our status window just stick this in there whereever you wan't it

%expandlist(@statcwho)

Tested and works however this might cause a lil Zmud lag if the DB contains many items (+50) in that case I would change the expression trigger to an alarm that executes every 30 minutes of connect time *example below*, The below example uses an alias so you can just type updatecwho to update it immediatly.

#ALARM "statcwhoalarm" {-30:00} {updatecwho}
#ALIAS updatecwho {
#VAR statcwho ""
#LOOPDB @cwho {#ADDITEM statcwho {%format( "&-10s&5.0f", %key, %val)}}
}

Also see page two of this post for a fix on one of your triggers. I meant to edit it into this post damnit! :P
_________________
Zmud Support Library
Zmud Knowledge Base

Last edited by nexela on Mon Nov 29, 2004 1:38 pm; edited 1 time in total
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Mon Nov 29, 2004 1:35 pm   
 
Quote:
#TR {(%d)~] (%w)} {#addkey cwho "%2 %1"}


Actually for that trigger you would want this....
#TR {(%d)] (%w)} {#addkey cwho "%2" "%1"}
_________________
Zmud Support Library
Zmud Knowledge Base

Last edited by nexela on Tue Nov 30, 2004 2:35 am; edited 1 time in total
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Tue Nov 30, 2004 2:35 am   
 
And even after some more thinking you could skip the loopdb etc all together and just format a string list as you add items don't ask me how I missed this it must be that one track train of thought thing


#TRIGGER "addcwho" {(%d)~] (%w)} {#ADDITEM statcwho {%format( "&-10s&5.0f", "%2", "%1")}}

then just use an expandlist in the status window like normal *untested but in theroy should work*
This might also be possible with a Data-record but Im not going any further with it :P
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
remus
Wanderer


Joined: 06 Jul 2002
Posts: 53
Location: Australia

PostPosted: Tue Nov 30, 2004 8:59 am   
 
That last one is perfect and so much easier! Thanks
_________________
Once the Known was unknown now its Known...
Do you know it???
Reply with quote
remus
Wanderer


Joined: 06 Jul 2002
Posts: 53
Location: Australia

PostPosted: Mon Dec 13, 2004 8:32 pm   
 
I have decided to try something harder and I thought these should work but for some reason they dont work properly or not at all?

Here is my who list
Code:

----------===========Mortals===========----------
Clan   Temple
......|...... [War/Sha Elf   2] Gaffiron the Purple Teletubie
......|...... [Thi/War Hum   5] Hido the Human Thief
......|...... [Wwf     Dem  21] Mortical, Creature of Nightmares
......|...... [Thi/Mag Shd  22] Tashor, Silent Stalker
TA- 0 |...... [Nec/Mag Eld  25] Adrianna Bloodmoor, Temptress of Demise
......|...... [Nec/Mag Shd  26] <O> <E> Flurra the shadowy Myst
TA- 1 |...... [  Lord       50] Tyross Mizzerym,- Malice
HD- 2 |SF- 0  [  Lady       52] Mendra Silentblade, Fallen Angel
CF- 2 |...... [  Lord       62] Rangek Ath'loren Philosopher of the Flames
PA- 8 |SF- 0  [  Lady       66] Zinhai Ak'Thun, Symphonic Torment
HD- 5 |SF- 4  [  Lady       69] [PK] Amestrise Nururaama, Malicious Martyr of Misery
CF- 3 |...... [  Baron      80] Mags, Death & Living Reconciled
TA- 7 |TE- 2  [  Count     102] Roan Et'Argnae {Drunken Master}
MI- 5 |GD- 0  [  Count     105] [PK] Hiro Yuy, Visage of Death
HY- 8 |...... [  Count     108] Cerethon Lomendir, The Sentinel
PA- 5 |...... [  Count     112] Nantek
MI- 8 |GD- 3  [  Count     121] <QUESTING> Correus Treveri, Spirit of Dominance
----------==========Immortals==========----------
CF- 9 |TE- 6  [    Heroine    ] <Building> Alastrine, Amhartan of the Realm


And these are the triggers I have

#TRIGGER {(%w)- (%d) ~|* (%d)~] (%w) } {#IF (%1=CF) {#ADDITEM cfwho {%format( "&-10s&5.0f", "%3", "%5")}};#IF (%1=PA) {#ADDITEM pawho {%format("&-10s&5.0f", "%3", "%5")}};#IF (%1=HD) {#ADDITEM hdwho {%format( "&-10s&5.0f", "%3", "%5")}};#IF (%1=TR) {#ADDITEM trwho {%format( "&-10s&5.0f", "%3", "%5")}};#IF (%1=TA) {#ADDITEM tawho {%format( "&-10s&5.0f", "%3", "%5")}};#IF (%1=MI) {#ADDITEM miwho {%format( "&-10s&5.0f", "%3", "%5")}}}

#TRIGGER "addcwho" {......~|* (%d)~] (%w) } {#ADDITEM statcwho {%format( "&-10s&5.0f", "%2", "%1")}}

#TRIGGER "addcwho" {(%w)- (%d) ~|* (%d)~] ({@flags}) (%w) } {#IF (%1=CF) {#ADDITEM cfwho {%format( "&-10s&5.0f", "%3", "%5")}};#IF (%1=PA) {#ADDITEM pawho {%format("&-10s&5.0f", "%3", "%5")}};#IF (%1=HD) {#ADDITEM hdwho {%format( "&-10s&5.0f", "%3", "%5")}};#IF (%1=TR) {#ADDITEM trwho {%format( "&-10s&5.0f", "%3", "%5")}};#IF (%1=TA) {#ADDITEM tawho {%format( "&-10s&5.0f", "%3", "%5")}};#IF (%1=MI) {#ADDITEM miwho {%format( "&-10s&5.0f", "%3", "%5")}}}

To save you some pain here is the main one not in script form:
Code:

Trigger: ^(%w)- (%d) ~|* (%d)~] (%w)
Value:
#IF (%1=CF) {#ADDITEM cfwho {%format( "&-10s&5.0f", "%3", "%5")}}
#IF (%1=PA) {#ADDITEM pawho {%format("&-10s&5.0f", "%3", "%5")}}
#IF (%1=HD) {#ADDITEM hdwho {%format( "&-10s&5.0f", "%3", "%5")}}
#IF (%1=TR) {#ADDITEM trwho {%format( "&-10s&5.0f", "%3", "%5")}}
#IF (%1=TA) {#ADDITEM tawho {%format( "&-10s&5.0f", "%3", "%5")}}
#IF (%1=MI) {#ADDITEM miwho {%format( "&-10s&5.0f", "%3", "%5")}}


The third trigger is almost the same but has the {(@flags)} which checks for <questing> [PK] etc.

The only info I really need in these is
1) The clan Initials ie CF HY etc, so that I can put them each into there own string for easy displaying in the status window.
2) The Level
3) The players name.

The second is for grabbing unclanned/untemple people. At present this does catch the stuff to statcwho but it puts an empty line under the captured text on the screen. (weird isnt it)
I have yet to build the fourth which catches temple but no clan.

Any ideas why they dont work?
Help most gratefully appreciated
_________________
Once the Known was unknown now its Known...
Do you know it???
Reply with quote
remus
Wanderer


Joined: 06 Jul 2002
Posts: 53
Location: Australia

PostPosted: Tue Dec 14, 2004 8:50 pm   
 
Just a quick note to say since posting this I have tried it as a long nested if statement like below but still no luck:

Code:

#IF (%1=CF) {#ADDITEM cfwho {%format( "&-10s&5.0f", "%3", "%5")}} {#IF (%1=PA) {#ADDITEM pawho {%format("&-10s&5.0f", "%3", "%5")}}} {#IF (%1=HD) {#ADDITEM hdwho {%format( "&-10s&5.0f", "%3", "%5")}}} {#IF (%1=TR) {#ADDITEM trwho {%format( "&-10s&5.0f", "%3", "%5")}}} {#IF (%1=TA) {#ADDITEM tawho {%format( "&-10s&5.0f", "%3", "%5")}}} {#IF (%1=MI) {#ADDITEM miwho {%format( "&-10s&5.0f", "%3", "%5")}}}
_________________
Once the Known was unknown now its Known...
Do you know it???
Reply with quote
megamog75
Enchanter


Joined: 20 Nov 2002
Posts: 627
Location: USA

PostPosted: Wed Dec 15, 2004 3:53 am   
 
remus, From your example above would you please scetch me what you would like this to look like in the status window.

I am extremly adaptive and creative when it comes to that window and this sounds like something I would like to take a crack at

Thank you
_________________
megamog75 Smile
I will do this.Nothing in my life matters except this.No moment in my life exists except this moment.I am born in this moment, and if I fail, I will die in this moment. Raistlin Majere
Reply with quote
remus
Wanderer


Joined: 06 Jul 2002
Posts: 53
Location: Australia

PostPosted: Wed Dec 15, 2004 6:15 am   
 
I have done the status window, it is the triggers that I cant get to capture the text that are the problem. When I test the trigger by copying a line from th who is works perfect and allocates each thing to %1 %2 %3 etc. But when I try to use it to capture it doesnt capture as all? I thought maybe the block of test that does who is to scrolled to fast that Zmud cant catch evry line and parse it?
But then zmud never has aproblem with doing that for inventory which is longer so I cant find the problem.

As to the status window I have just dont it like this:

Code:

%ansi( cyan, bright)WHO IS ON DS
%ansi( white)%expandlist( @statcwho)
%ansi( red, bright)Online:%ansi( white) %numitems( @statcwho)
%ansi( black).
%ansi( cyan, bright)CF Who
%expandlist( @cfwho)
%ansi( cyan, bright)HoD Who
%expandlist( @hdwho)
%ansi( cyan, bright)HY Who
%expandlist( @hywho)
%ansi( cyan, bright)MI Who
%expandlist( @miwho)
%ansi( cyan, bright)PA Who
%expandlist( @pawho)
%ansi( cyan, bright)TA Who
%expandlist( @tawho)
%ansi( cyan, bright)CF Who
%expandlist( @cfwho)
%ansi( black).
%ansi( red, bright)Imm Who
%expandlist( @immwho)
_________________
Once the Known was unknown now its Known...
Do you know it???
Reply with quote
remus
Wanderer


Joined: 06 Jul 2002
Posts: 53
Location: Australia

PostPosted: Sat Dec 18, 2004 4:30 pm   
 
Can anyone see why they dont work? If the answer is that you cant could you tell me that too, It might be something I am missing. I really need an opinion.
_________________
Once the Known was unknown now its Known...
Do you know it???
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
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

© 2009 Zugg Software. Hosted by Wolfpaw.net