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
Mixsel
Wanderer


Joined: 02 Feb 2003
Posts: 99
Location: Seattle, Wa

PostPosted: Sat May 15, 2004 10:59 pm   

multiline woes
 
Greetings,
Countless hours, stumped beyond belief so i gotta be close!
here's the mud output when i walk into a room...

A cliff
A creepy cavegoyle, a feeble cavegoyle, an ice giant, a cavegoyle and a stealthy ice troll are here.
Exits: southwest.
[hp=2590/mp=2965/mv=670]

this is my trigger i'm trying to tweak to work...

#TRIGGER {^{A|An} (*) {are|is} here.} {#VARIABLE killlist %replace( %1, ", ", " ");#VARIABLE killlist %replace( {@killlist}, " and a ", "|");#VARIABLE killlist %replace( {@killlist}, " and an ", "|");#VARIABLE killlist %replace( {@killlist}, "A ", "");;#VARIABLE killlist %replace( {@killlist}, " ", "|");#ECHO @killlist;#VARIABLE killlist %left( @killlist.1, 1)}}

now if there's only one line of mobs it's works ok sorta

A creepy cavegoyle, a feeble cavegoyle and an ice giant are here.

my echo echoes creepy cavegoyle and thats it unless i redisply the room after i kill one of the mobs

so if the mud outout is:

A creepy cavegoyle and a feeble cavegoyle are here.
it'll echo: creepy cavegoyle|feeble cavegoyle

my problem is trying to capture multiple lines then take out all the comma's the A| An| a an |and a
then store the rest in my killlist variable...and then do my formatting thing so it'll send just the first few letters to a varible in my stat window so i don't have to spam myself trying to remember whats in the room, cause it can get kinda hectic and those few seconds to relook could cost me my life hehe.

any help mucho appreciated as always :)
Z
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Mon May 17, 2004 6:10 pm   
 
#TR {^{A|An} (*) {are|is} here.} {#VAR killlist {%1}
#VAR killlist %replace( {@killlist}, " and a ", "|")
#VAR killlist %replace( {@killlist}, " and an ", "|")
#VAR killlist %replace( {@killlist}, " an ", " ")
#VAR killlist %replace( {@killlist}, " a ", " ")
#VAR killlist %replace( {@killlist}, ", ", "|")
#ECHO @killlist
#VAR shortlist {}
#FORALL @killlist {#VAR shortlist {%additem( %word( %i, 1), @shortlist}}
#ECHO @shortlist}

The major problem in your script was the first replace, where you used %1 and didn't put braces or double-quotes around it.
Reply with quote
Mixsel
Wanderer


Joined: 02 Feb 2003
Posts: 99
Location: Seattle, Wa

PostPosted: Tue May 18, 2004 9:45 pm   
 
ARGH! man i gotta remember about them brackets eer learn the whole how the syntax works thing, as usual you've responded to my post with the answer and i've read many posts that you've responded to and learned tons, just wanted to say thanks.

now gimme... if you have time could you point me in a direction that kinda explains when to use the brackets or quotes to properly tell zmud what to do? I touched on some help file that sorta explained it but i still didn't quite understand it.

anyways Mucho thanks, YOU ROCK! :)

Z
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Tue May 18, 2004 10:28 pm   
 
For the most part I think this is right depending on settings. I forgot the URL that really explains it. Aslo alot of the helpfles have decent examples on where to put them and such

<> Expands //say <%ip>
[] Evaluates //aka %eval()
"" Groups as is? nothing is expanded <-not sure on this one
{} Groups thats it just groups egs.
#TR {pattern group} {Value Group;#if (expression group) {Then Group} {Else group}
#VAR Value DefaultValue //#var magic guard withh set magic as value and guard as default
#VAL {Value Group} {Default group} //#var will set Value Group as value and Default group as default
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Wed May 19, 2004 3:39 am   
 
Grouping inside functions is needed most when you are using %1 inside the function, and the value of %1 may include commas.
Grouping in commands is needed when you use %1 with a value which may include spaces.

I try to just make it a habit to put curly-braces around %1 whenever I use it with a command and double-quotes whenever I use it with a function, UNLESS %1 will be a number. If %1 will be a number, double-quotes would convert it to a string. This all applies to %2, %3, etc. also.

Grouping doesn't seem to be as important with variables, @killlist or %char, but it's still a good idea.
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