|
qball989 Newbie
Joined: 20 Mar 2012 Posts: 9
|
Posted: Tue Mar 20, 2012 2:50 pm
Trying to compare a string list variable |
Very first post, so apologies in advance.
I am trying to make sure that I have all my skills/spells up on my main character before I start a fight. I'm using #If (%null(aflist)) as my basis. The @aflist variable contains skills for my character that is populated by wear-off messages using #additem. I'm checking this list after every mob fight. I'm banging my head against the wall and i'm sure there's an easier way to do it
Code: |
#if {%null(@aflist)} {aff} {#SHOW %pop(aflist)} |
|
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Tue Mar 20, 2012 3:59 pm |
That seems like a simple enough line of code. What is the problem with it? What shortcomings do you want to fix? You may need to explain in more detail what you want.
|
|
|
|
qball989 Newbie
Joined: 20 Mar 2012 Posts: 9
|
Posted: Tue Mar 20, 2012 5:36 pm |
Thanks for the speedy reply. I had this line working just fine but in 2 different places to do a couple different things. I commented them out because one of them wasn't working, and now neither of them do. What I'm after is killing a mob, then pausing to check the skills that wore off, then recasting them, then continuing on to the next mob.
|
|
|
|
qball989 Newbie
Joined: 20 Mar 2012 Posts: 9
|
Posted: Tue Mar 20, 2012 5:45 pm |
I also don't know if version matters, but it's CMUD 2.37. I'm not seeing %null in the list of things associated with string lists.... maybe it's any string in that list is why it works?
|
|
|
|
qball989 Newbie
Joined: 20 Mar 2012 Posts: 9
|
Posted: Tue Mar 20, 2012 5:59 pm |
Ok, fixed that problem... mostly because I forgot to fix the special characters under the scrpting tag..... Now to see if i can fix it. I had the % symbol unchecked for the parameter... *bonks self*
|
|
|
|
qball989 Newbie
Joined: 20 Mar 2012 Posts: 9
|
Posted: Tue Mar 20, 2012 6:21 pm RE Broken |
So now my exits trigger is broken, which seems to happen every time i tinker with it. So here's what I have:
Code: |
#TR {~[Exits:(*)~]}
{mobEnemy="";#t+ MatchEnemy;
#var exits {%replace(%1, " ", "|")};
#alarm {+.5} {hunt}} |
And the value i keep getting in my @mobEnemy variable is %1... |
|
Last edited by qball989 on Tue Mar 20, 2012 6:30 pm; edited 1 time in total |
|
|
|
qball989 Newbie
Joined: 20 Mar 2012 Posts: 9
|
Posted: Tue Mar 20, 2012 6:24 pm |
and also,
Code: |
#TR {*({@rkList})*} {#var mobenemy{%1} #t- MatchEnemy} |
|
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Wed Mar 21, 2012 12:03 am |
This piece of code is clearly broken. What value are you trying to assign here? I assume there should be a semicolon before the #t-?
Code: |
#TR {*({@rkList})*} {#var mobenemy{%1} #t- MatchEnemy} |
In the trigger value, you don't need the * at the beginning and end, either.
I suspect that this is the code you want, but I'm not certain that I'm interpreting what you are trying to do here:
Code: |
#TR {({@rkList})} {#var mobenemy %1; #t- MatchEnemy} |
|
|
|
|
Anaristos Sorcerer
Joined: 17 Jul 2007 Posts: 821 Location: California
|
Posted: Wed Mar 21, 2012 12:55 am |
I've noticed in the last few posts that %replace continues to be used to change a string to a string list. While this is quite viable, I don't believe is as efficient as using the %list function.
So..
Code: |
#VAR exits {%replace( %1, " ", "|")}
|
would be better represented this way, imo
Code: |
#VAR exits {%list( %1, " ")}
|
|
|
_________________ Sic itur ad astra. |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Wed Mar 21, 2012 2:08 am |
Unfortunately, qball989 can't use %list() because that was only introduced in v3.18, and he is on v2.37. But you're right, %list is probably a more robust method for those of us on 3.xx, and less likely to run into problems in future upgrades. I keep forgetting about %list because I've been using the %replace trick for so long; I suspect that's true of others, too.
|
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Wed Mar 21, 2012 2:28 am |
%list() is limited to only one-character substitutions for the delimiter. %list("string",", ") fails to do anything, for example. I think it also has problems with certain characters like commas.
|
|
_________________ EDIT: I didn't like my old signature |
|
|
|
Anaristos Sorcerer
Joined: 17 Jul 2007 Posts: 821 Location: California
|
Posted: Wed Mar 21, 2012 3:05 am |
Yes, it is. But the usage that I've observed, #VAR x %replace($list," ","|"), is quite manageable by %list. Commas offer no challenge to the function, as far as I know.
|
|
_________________ Sic itur ad astra. |
|
|
|
qball989 Newbie
Joined: 20 Mar 2012 Posts: 9
|
Posted: Wed Mar 21, 2012 5:57 am |
Rahab thanks for the help editing my code, greatly appreciated. The braces around the %1 were messing it up. And thanks for the input / info on list in future versions :)
|
|
|
|
|
|