|
yipfur Beginner
Joined: 12 Jan 2003 Posts: 13 Location: Australia
|
Posted: Mon Sep 24, 2012 6:54 am
Joining stings together in a string list so the string goes on a new line |
Hi I am using CMUD.
I have a problem with a string list I have made up. On the mud I play 'Discworld' there is a command called 'killers' which gives a list of playerkillers that are online. I have made a script that will colour the name of a killer when they enter the room I am in or there name turns up. It makes a strings list that is read by another trigger and colours the name, it works sort of but it needs improvment as it is doing funny output and sometimes reads the wrong data and then I need to go in manualy and remove the wrong information.
When I type in 'killers' the output of the mud is;
There are eight player killers logged in:
Aslo(F), Chaste, Leyan, Limmer, Llylia, Reed, Wile and Rhalesalt
>
I use the follwing trigger to get this infomation;
#trigger There are (*) player killers logged in:
#T+ PKcapture
which turns on the following trigger
#trigger (*)
#IF (%1!="> ") {PKlist=%concat( @PKlist, %1)} {PKlist=%subchar( @PKlist, ", ", "||");#DELITEM PKlist {and};#DELITEM PKlist {};PKlist=%insert( @PKlist, |, "");#T- PKcapture;#VAR PKlist {%dups( @PKlist)}}
and puts the collected names into the stringlist PKlist
The names are read with;
#trigger %q{@PKlist}%q
#CW yellow
Now the problems I am haveing are.
1. If the the sringlist PKlist is not on AutoType and turns itself to Sting list the trigger %q{@PKlist}%q does not read the string list. Somehow I need to keep it AutoType or figure out how to read it as a string list as it turns itself automaticaly from AutoType into String list every time I use it, once it goes to string list it won't read the names.
2. When I run the killers command to update the string list it adds the first name to the last name in the sting list if I use the above supplied example if I had the name Bob as the last name in the origanal Pklist string list it will turn it into BobAlso(f) so I end up with a stinglist of double names. Sometimes it dosn't even put the names in different lines and will have all of them on the same line. I need to be able to join the new information into the string list on the next line that would be the solution. So it would be Bob then on the next line Aslo(f)
3. Sometimes the main trigger (*) pkcapture will not turn off and continues to read information and I end up getting rooms descitpionts etc despite the prompt > comeing up, I then have to clean it all up or even delete the entire string list and start all over again which is very frustratng. I thought if I used and #action trigger under the (*) trigger with the > prompt to turn of the entire trigger I would be able to get rid of the #if statement completely and then just use sting manipulation functions to clean up and add the the killers names into the PKlist string list. I am thinking this would be the best solution but don't know how to code it.
4. What I am aiming for with this trigger is to gather the names of the killers and put them into a Database then using other commands with triggers to gather further information about the playerkiller, eg name, guild, age, specalition etc. which is then displayed on a button I have created so I can guage whether I have a chance of takeing out the killer or I should run. This is what I would like to end up with and if a competely different approach is needed then I am fine with that. I thought useing pop and push and addkey would be the way to go but am unsure how to proced. At the moment I can not even figure out how to get the #action command to work so I can get the If statment gone.
I hope this is enough information about my problems and would appriciate some help to fix up the script which is not working how I want it to work, it sort of worked in zmud but with Cmud it seams to have gone all funny, as I would like to be more active in the killers commuity I need to fix this and make it work properly everytime.
Thank you
Yipfur |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Mon Sep 24, 2012 9:04 am |
You're making this far too complicated for what you want done. First, CMUD is functioning as it's supposed to, and AutoType would refer to it as a stringlist anywa.
Second, why in the world are you adding items by using a | character?
Third, #ADDITEM will not add duplicates.
Ultimately, this is what you want:
Code: |
#TRIGGER {^There are %d player killers logged in:}
#COND {(*) and (*)} {#LOOP %numworlds(%1,",") {#ADDITEM PKList %word(%1,%i,", ")};#ADDITEM PKList %2}
#TRIGGER {%q{@PKList%q} {#CW yellow} |
Keep in mind the above trigger only works if there is more than one person listed on player killers. You can rectify this by going into the Settings editor, choosing the #COND I set above (click the + next to the first trigger to expand) and then changing the trigger line from (*) and (*) to (.*)(?:and (.*))? then ticking the box that says Regex near the bottom.
Let us know if there's anything more you need.
Edit: Additionally, if you want to add them to a database, you can do that as well. You'd want to use #ADDKEY for that, though, and you'd need to change your pklist trigger to {%%dbkeys(@PKList)} (I believe). |
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Mon Sep 24, 2012 1:12 pm |
You wouldn't need to add %%dbkeys actually, it's implied when using a database variable in a trigger pattern.
|
|
|
|
|
|
|
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
|
|