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
bartistcs
Beginner


Joined: 15 Sep 2005
Posts: 14
Location: USA-CA

PostPosted: Sat Sep 17, 2005 1:43 am   

Creating a list from the contents of a container
 
I'm trying to create a list variable from the contents of a container. A portion of the container is:
Code:

A Card Collector contains:
     (#001) Card 1
     (#002) Card 2
     (#004) Card 3
     (#005) Card 4
     (#007) Card 5



I want to read the #xxx portion (there are 200) and read just the number into a variable. I want to scan the container and add just the xxx portion into my variable containerlist. Do I have to create a trigger for EACH card then use #ADDITEM to add it? Or is there a simpler way?

Secondly, and I think this has to do with %ismember, I want to compare containerlist with cardlist and have it tell me which cards ARE NOT in containerlist. Would I do:
Code:

#FORALL @containerlist {#if %ismember(%i,@cardlist) {} {#STATUS Missing Cards: %i}}



Any help/direction would be much appreciated! Thanks!
-Batistics
_________________
-BArtistics
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sat Sep 17, 2005 2:56 am   
 
You really only need three triggers:

1)trigger on A Card Collector contains:. This trigger will do any of the preliminary work you might need/want--setting variables to zero, enabling other triggers, etc.

2)trigger on (#001) Card 1. This trigger will do nothing but fill in the variables, and since each card follows the same format (and since we're only interested in card numbers) we don't need 200 separate triggers for this.

3)trigger on whatever ends the list. It might be your prompt, it might be a blank line, or it could even be trailing lines about help/status. This trigger will do the figuring and calculating, which you have moreorless correct in the #FORALL.
_________________
EDIT: I didn't like my old signature
Reply with quote
bartistcs
Beginner


Joined: 15 Sep 2005
Posts: 14
Location: USA-CA

PostPosted: Sat Sep 17, 2005 4:38 am   
 
I got 2/3 working...the #FORALL is screwing me up. In it's current state:

Code:

#FORALL @containerlist {#if %ismember( %i, @cardlist) {#ECHO Missing Cards:} {#ECHO Missing Cards: %i}}



It is spitting back the cards I *have* If I reverse the variables, it spits back pretty much @cardlist. So I have some questions: 1) First, how is %ismember supposed to work? I've read the helps and don't get it still, 2) the first {#ECHO MIssing Cards:}, I am assuming the way it is set up, this value should be a TRUE value therefore I don't want it to output anything and 3) this one goes with 2...how do I get the script to pass over the number that is there and not display anything and keep moving until it comes across a card that ISN'T there and display it?

To add some more info...@cardlist contains the numbers 200 - 001 (not sure if being ordered backwards matters) and @containerlist contains the cards in my container (these are in 001-200 ascending because I have sorted them already, but typically they are unsorted (and I don't want to run my sort script everytime) so the order could be such 128|055|200|006 etc; does this matter?) - comparing these two should yield the cards I am missing.

Thanks for bearing with an inquisitive n00b. I'm trying :D
_________________
-BArtistics
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Sat Sep 17, 2005 6:00 am   
 
#FORALL @cardlist {#if [red]![/red]%ismember( %i, @containerlist) {#ECHO Missing Cards: %i}
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
bartistcs
Beginner


Joined: 15 Sep 2005
Posts: 14
Location: USA-CA

PostPosted: Sun Sep 18, 2005 8:54 pm   What a headache
 
Ok, I am posting my script in all it's glory because nothing is working now. Nexela's script only sends me into an infinite trigger loop that can only be shut down when zMUD asks me to disable the trigger (which doesn't even work) and the class won't disable either. To top it off, for some reason, the settings editor stopped recognizing it's own commands - for example, as i manually type a #FORALL script, the WHOLE line will be in black, no matter what I do. It won't even let me copy and paste either because I get the same results. I think this trigger class is screwing my whole client up. Anyway, here it is, I need massive help!

Code:

#CLASS {Smurf} {disable}
#VAR cardlist {200|199|198|197|196|195|194|193|192|191|190|189|188|187|186|185|
184|183|182|181|180|179|178|177|176|175|174|173|172|171|170|169|
168|167|166|165|164|163|162|161|160|159|158|157|156|155|154|153|
152|151|150|149|148|147|146|145|144|143|142|141|140|139|138|137|
136|135|134|133|132|131|130|129|128|127|126|125|124|123|122|121|
120|119|118|117|116|115|114|113|112|111|110|109|108|107|106|105|
104|103|102|101|100|099|098|097|096|095|094|093|092|091|090||089|
088|087|086|085|084|083|082|081|080|079|078|077|076|075|074|073|
072|071|070|069|068|067|066|065|064|063|062|061|060|059|058|057|
056|055|054|053|052|051|050|049|048|047|046|045|044|043|042|041|
040|039|038|037|036|035|034|033|032|031|030|029|028|027|026|025|
024|023|022|021|020|019|018|017|016|015|014|013|012|011|010|009|
008|007|006|005|004|003|002|001}
#VAR list {099|098|097|096|095|094|093|092|091|090||089|088|087|086|085|084|
083|082|081|080|079|078|077|076|075|074|073|072|071|070|069|068|
067|066|065|064|063|062|061|060|059|058|057|056|055|054|053|052|
051|050|049|048|047|046|045|044|043|042|041|040|039|038|037|036|
035|034|033|032|031|030|029|028|027|026|025|024|023|022|021|020|
019|018|017|016|015|014|013|012|011|010|009|008|007|006|005|004|
003|002|001}
#VAR containerlist {}
#TRIGGER {*Smurfemon Card Collector's Smurfedex contains~:} {containerlist {}}
#TRIGGER {*~(~#(*)~) (*) ~*Smurfemon Card~*} {#ADDITEM containerlist %1}
#TRIGGER {$} {#FORALL @cardlist {#if !%ismember( {%i}, @containerlist) {#ECHO %i}};#T- Smurf}
#TRIGGER {There is no %d here.$} {#CAP missingcard}
#CLASS 0
#ALIAS smurflist {#T+ Smurf;look in smurfedex}



I set the class to disable on startup because of the headache it gives me. I need alot of help getting this beast running and I haven't a clue why it's giveing me so many problems.

NOTE: ignore the list variable, that is being used from another alias that is working. Also, the alias used to fire this script off is smurflist.
_________________
-BArtistics
Reply with quote
psyber624
Newbie


Joined: 17 Sep 2005
Posts: 5

PostPosted: Mon Sep 19, 2005 4:07 am   
 
That is screwing you up because the line
#TRIGGER {$} {#FORALL @cardlist {#if !%ismember( {%i}, @containerlist) {#ECHO %i}};#T- Smurf}

THis line triggers at the end of the line. but since you give it no pattern to match it will match at the end of EVERY line, including your output lines. Since the #T-Smurf doesnt execute till the #FORALL statement is finished, you wind up matching ALOT of endlines, and running ALOT of for all statements.

Find a better match statement for the end trigger. If the $ is your prompt for your mud, you need to put ~ in front of it, because $ is a zmud wildcard to force the trigger to match at the end of a line.

That should stop your eternal trigger problem. Not sure tho, writing this at work and cant test it on my own right now. If it does fix it, but doesnt get the output right, ensure your cardlist variable is being populated correctly.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Mon Sep 19, 2005 9:14 am   
 
The cardlist variable is not truly needed since it is a continuous series of numbers. You can use #LOOP instead to have the same sort of series, it is up to you whether you want to eliminate the variable.

#TRIGGER {^$} {#T- Smurf;#ECHOP "Missing Cards: ";#FORALL @cardlist {#if (!%ismember("%i", @containerlist)) {#ECHOP "%i "}};#ECHO {}}
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
bartistcs
Beginner


Joined: 15 Sep 2005
Posts: 14
Location: USA-CA

PostPosted: Mon Sep 19, 2005 10:04 pm   
 
I need the cardlist variable because zmud defaults 001 to 1 and 099 to 99 and the keywords for these cards are 200-001. Unless I can force zmud to register 001 AS 001 I don't know any other way around it.

As for the two suggestions, I'm working on them :D Fiddling with page pausing because it seems to be scrolling too fast and sometimes zmud stores the wrong info into the containerlist var which screws it up.

I'll post something as soon as I make some headway.

Thanks all for helping and for those who do later as well ;D

(little bit later - my containerlist is not populating correctly. I've tried setting it to be empty using #var containerlist "" but it doesn't seem to be working at all. Not to mention I keep capturing the ( ) around the card numbers sometimes. I think it's moving too fast.)
_________________
-BArtistics
Reply with quote
bartistcs
Beginner


Joined: 15 Sep 2005
Posts: 14
Location: USA-CA

PostPosted: Wed Sep 21, 2005 6:40 am   
 
I got it working spot in. Found out that my container var wasn't filling because it was INSIDE the class I was enabling, causing me some issues with triggering the blank line. Moved things around and viola! Worked like a dream. Thanks for bearing with me and giving me some help :)
_________________
-BArtistics
Reply with quote
bartistcs
Beginner


Joined: 15 Sep 2005
Posts: 14
Location: USA-CA

PostPosted: Wed Sep 21, 2005 7:12 am   
 
Ok, one more question :) I have the following trigger:

~(~#(%d)~) (*) ~*Smurfemon Card~*$

and i do #ADDITEM containerlist %1

What I would like to do is add both the %d and * into one line into the string. For example...

(#198) B.S.O.D. Smurf *Smurfemon Card*

and I get 198 and B.S.O.D. Smurf and put them into one line of the container list var so it looks like:

198 B.S.O.D Smurf

I've used commas, | , and {} and parentheses....haven't an idea how to do it.
_________________
-BArtistics
Reply with quote
billaben
Wanderer


Joined: 02 Sep 2005
Posts: 60

PostPosted: Wed Sep 21, 2005 7:26 am   
 
There's two main ways to handle that.

#VAR Card {%concat(%1, %2)}

or simply

#VAR Card {%1 %2}

Either should work.
Reply with quote
bartistcs
Beginner


Joined: 15 Sep 2005
Posts: 14
Location: USA-CA

PostPosted: Wed Sep 21, 2005 7:37 pm   
 
I tried both using #ADDITEM no dice. not sure what's going on. I almost think it doesn't want to add %2. If I echo it to my terminal, I get the right name.
_________________
-BArtistics
Reply with quote
Slaem
Apprentice


Joined: 20 Sep 2005
Posts: 135

PostPosted: Thu Sep 22, 2005 3:30 am   
 
Would using quotes around %2

#VAR Card {%1 "%2"}

add the "text" portion.
_________________
Show your love.
Support Zugg Software!
Donate to zugg@zuggsoft.com with PayPal Send Money.
Reply with quote
bartistcs
Beginner


Joined: 15 Sep 2005
Posts: 14
Location: USA-CA

PostPosted: Thu Sep 22, 2005 7:42 pm   
 
Ok I got this working. I forgot to change my two variables to have the same matching patterns. I used #ADDITEM containerlist (%1 %2) so it would have the format 001 Card Name. Works great.

Only problem I am having is comparing the two variables...maybe it's too much text for it to handle? it adds in cards that ARE listed in both varaibles and therefore should not be echoed to my window. Is there a certain trick to preventing this or do I have to do something special for comparison because of adding %1 and %2 into the same text string?
_________________
-BArtistics
Reply with quote
billaben
Wanderer


Joined: 02 Sep 2005
Posts: 60

PostPosted: Thu Sep 22, 2005 8:01 pm   
 
The FORALL in this trigger looks fairly time consuming. It may help to make it a priority sequence. If it is 'too much text' for it to handle this should resolve it. Note, I also see that your {$} trigger has been changed to something, obviously you should include any such changes, this was just the only copy I could see to grab.

A good way to test this is to color each line that you trigger on so that you can SEE if a trigger line gets skipped or not.

#TRIGGER {$} {
#PRIORITY {
#FORALL @cardlist {#if !%ismember( {%i}, @containerlist) {#ECHO %i}}
#T- Smurf
}
}
Reply with quote
bartistcs
Beginner


Joined: 15 Sep 2005
Posts: 14
Location: USA-CA

PostPosted: Thu Sep 22, 2005 9:11 pm   
 
My actual trigger to capture the items works fine. The variable populates perfectly. I checked it manually and found no errors. During the comparison, there seems to be an error. My capture trigger is as follows:

#TR {~(~#(%d)~) (*) ~*Smurfemon Card~*$} {#ADDITEM containerlist {%1 %2}}

which works perfectly.

Once the end of the list is encountered, I do the followng:

#TR {^$} {#T- Smurf;#WAIT 1000;#WINDOW Smurf "Card Count:" %numitems( @containerlist);#FORALL @cardlist {#if (!%ismember( %i, @containerlist)) {#WINDOW Smurf %i}};put smurfedex belt}

This is to compare and report missing values. Problem is that it is reporting values that are identical in BOTH variables that it shouldn't be reporting.

I'm still tweaking it, and any comments are appreciated!
_________________
-BArtistics
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Sep 22, 2005 10:23 pm   
 
You shouldn't need the #WAIT since you are sending your output to a seperarate window. Using #WAIT in triggers tends to have some very bad consequences, even for just the 1 second you have.

Next I would suggest putting some surrounding characters in your output with #WINDOW. This will help you identify the problem if it is an odd trailing space. #WINDOW Smurf {Missing '%i'}

Also keep in mind that %ismember is a case-sensitive function. Upper and lower case as well as spacing must match exaclty. I would suggest having output on all the cards while debugging. Inside the #FORALL just before the #IF add in #WINDOW Smurf {Checking '%i'}

Once debugging is done you can remove that line.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
bartistcs
Beginner


Joined: 15 Sep 2005
Posts: 14
Location: USA-CA

PostPosted: Fri Sep 23, 2005 12:35 am   
 
It's not a matching issue because the funky values are the same throughout. There are no wrapping issues involved because i put ' ' around it and everything stayed on lined spaced nicely. As for the #WINDOW...wouldn't work. got weird syntax errors no matter how i put it in there with the #if statement.

so i'm at a loss. there should be no reason for it to bugger up like this. I'll leave it as is unless somebody as a solution cause I can't find one.
_________________
-BArtistics
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Fri Sep 23, 2005 8:37 am   
 
Sometimes syntax errors can actually be ignored. The syntax checker is more picky then the parser and doesn't always know every exception there is.

%i is subject to a form of early expansion and should be surrounded with quotes in your %ismember.
#if (!%ismember( "%i", @containerlist))
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
bartistcs
Beginner


Joined: 15 Sep 2005
Posts: 14
Location: USA-CA

PostPosted: Sat Sep 24, 2005 12:51 am   
 
Ok nailed the problem down. Thanks to vijilante with the " " around the %i i also used a #priority when capturing the cards. but this is the problem:

the " " in certain card names are killing it. making it appear as if they aren't there when they are. i checked both vars and they are the same just not recognizing the quotes. so what do i do to force the quotes to be recognized?
_________________
-BArtistics
Reply with quote
bartistcs
Beginner


Joined: 15 Sep 2005
Posts: 14
Location: USA-CA

PostPosted: Sat Sep 24, 2005 4:07 am   
 
got it! used %quote(s) syntax around my two variables for output.

thanks everybody for your help!
_________________
-BArtistics
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