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


Joined: 31 Aug 2005
Posts: 15

PostPosted: Fri Sep 09, 2005 1:52 pm   

Weird variable behavior.
 
Generally, one would think that given the script

Code:
#TRIGGER "RoomDesc_Capture" {^%e[1;30m(*)} {RoomDesc="";RoomDesc=%concat( @RoomDesc, %1);#SHOW %1} "Mapping" {color}
#COND {%e[1;30m(*)} {RoomDesc=%concat( @RoomDesc, %1);#SHOW %1} {looplines|param=99|color}

Would mean that in short, the text displayed with #SHOW(OR #EC, for that matter), and the text stored in @RoomDesc is the same. However, it seems that storing stuff into variables is more that tricky. It's super tricky!

Given the example:
People bustle past with almost no regard of your presence, such is their hurry in delivering their
goods or seeing to whatever business that vexes them. Above you, on some of the balconies that
upholster the Parade, members of the gentry are to be found, sneering at the commoners cramped
together along the avenue. The rest of the Parade as it carves its way to the south does not promise
anything better in terms of noise level.
A runic totem is planted solidly in the ground.

#Show displayes all the text that is in dark red. Thus, I believe it is right to say that the %1 argument only receives text colored in dark red, as per the Trigger pattern.

But then, the last command, which should be RoomDesc=%concat(@RoomDesc, %1) takes, seemingly, instead of %1 something like %line.

Anyone care to enlighten me why parameters are not saved properly into a variable? Maybe this is a bug?
Reply with quote
Seyen
Beginner


Joined: 31 Aug 2005
Posts: 15

PostPosted: Fri Sep 09, 2005 2:26 pm   
 
Oh, and one more gripe.. seems like %concat eats up the ", " in any string it concatenates to the first one. ie %concat("123 123 ", "123, 123, 123" would end up concatenated like "123 123 123123123". Workaround?
Reply with quote
Carabas
GURU


Joined: 28 Sep 2000
Posts: 434
Location: USA

PostPosted: Fri Sep 09, 2005 2:57 pm   
 
The entirety of the last line is captured because the line starts with the grey color. zMUD is capturing everthing following the %e[1;30m escape sequence, including other escape sequences. To resolve the %concat problem, you need to use quotes. Try this trigger. I've highlighted my changes.

#TRIGGER "RoomDesc_Capture" {^%e[1;30m([%a%p'])} {RoomDesc="";RoomDesc=%concat( @RoomDesc, "%1");#SHOW %1} "Mapping" {color}
#COND {%e[1;30m([%a%p'])} {RoomDesc=%concat( @RoomDesc, "%1");#SHOW %1} {looplines|param=99|color}
_________________
Carabas
Reply with quote
Seyen
Beginner


Joined: 31 Aug 2005
Posts: 15

PostPosted: Fri Sep 09, 2005 4:19 pm   
 
Holy crap, it worked, and it's much cleaner and easier than the workaround I did. I used a temoprary variable to escape the concat problem(doesn't trim the variables contents, it seems). And used another trigger to trim the uneeded text, and strip the ansi, and god knows what else.. This is so much easier on the processing. Thank you very much Smile

Some questions though. The [] is a defined range. I noticed you can use wildcards inside too. But you added " ' ". That because it's not considered punctuation by zMUD?
Next, is #TEMP unable to use parameters? I enclosed the needed patterns in () but it didn't catch anything, even though it fired on the matching string like it should.
And, {|} does not allow for any wildcards? Even defined ranges? Any workarounds to this? (Maybe using variables with lists?)
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Fri Sep 09, 2005 8:24 pm   
 
You need to turn on Use Wildcards in Stringlists in Preferences to use wildcards in {|}
_________________
EDIT: I didn't like my old signature
Reply with quote
Carabas
GURU


Joined: 28 Sep 2000
Posts: 434
Location: USA

PostPosted: Sun Sep 11, 2005 1:21 am   
 
I added the apostrophe because the %p and %q wild-cards do not currently match an apostrophe. I submitted a bug report.
_________________
Carabas
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