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


Joined: 09 Sep 2005
Posts: 14

PostPosted: Wed Sep 14, 2005 8:49 pm   

%remove and ansi
 
Using zmud 7.13b and windows XP, I created a variable which contains an eq item name including ansi. I need to delete part of the item name but can't figure out a way to do it when ansi is included in the whole equation. The variable value w/ansi codes looks like this:

%e[1;30man orb of %e[1;33mdancing %e[1;37mmoonlight%e[0m (%e[34mmagic%e[0m) (%e[1;37milluminating%e[0m)

I want to remove the (%e[34mmagic%e[0m) and (%e[1;37milluminating%e[0m) from the variable but need help! It seems like I should be able to just use the %remove command, something like

#VAR temp %remove( %e[0m~(%e[34mmagic%e[0m~), %1)

but it doesn't work. What am I missing?? I know my questions might seem fairly simple because I am really just cracking the surface of all this scripting stuff but I would appreciate any help I can get :-)
Reply with quote
tye
Beginner


Joined: 24 Feb 2005
Posts: 27

PostPosted: Thu Sep 15, 2005 1:38 pm   
 
I've never used the %remove command before, but it seems to me that what you're trying to strip out are the object's "flags", (magic), and (illuminating). So I would simply be inclined to strip out anything and everything that's blocked by parentheses. That might be something like: #VAR temp %remove( ~(*~), %1 ). Not sure, though. I'd have to play with it.
Reply with quote
Carabas
GURU


Joined: 28 Sep 2000
Posts: 434
Location: USA

PostPosted: Thu Sep 15, 2005 7:57 pm   
 
Surround the arguments to %remove in quotes. If there are never any parenthesis in the first part of the string, you can strip them out by using a mix of %left and %pos.
_________________
Carabas
Reply with quote
zmudnoob
Beginner


Joined: 09 Sep 2005
Posts: 14

PostPosted: Fri Sep 16, 2005 7:07 am   
 
Oh wow....tried using %left and %pos and it worked beautifully and painlessly. What an ingenious idea! Thank you very much!!
Reply with quote
Jazzles
Beginner


Joined: 22 Jul 2005
Posts: 17
Location: UK

PostPosted: Fri Sep 16, 2005 10:09 am   
 
I've been following this post with some interest and trying to work out what is fully meant...
zmudnoob, could you please post a corrected and now working variable, just so I can get the full picture.
Reply with quote
zmudnoob
Beginner


Joined: 09 Sep 2005
Posts: 14

PostPosted: Fri Sep 16, 2005 5:12 pm   
 
I hestitate to post any of my scripts because I really don't know what I'm doing and am learning by taking other people's scripts apart and reading reading reading help files :-P But this is what I created from Carabas' suggestion. There are surely much cleaner ways to do it which I will learn as I go but this did exactly what I wanted it to do:

#VAR flagbegin %pos( "(","%1")
#IF (@flagbegin > 0) {
#ADD flagbegin -2
#VAR dbitem.AnsiName %left( %1, @flagbegin)
} {#VAR dbitem.AnsiName { %replace( "%1", " ", " ")}}

In essence this took the name of an item that had flags of any sort ((magic) (glowing) etc) at the end and just grabbed everything up until it hit the first parenthesis to put in my dbitem.ansiname variable. Without the ansi code, it would have been an easy thing but somehow the ansi code was not responding well to %remove. %pos and %left worked like a charm!
Reply with quote
Jazzles
Beginner


Joined: 22 Jul 2005
Posts: 17
Location: UK

PostPosted: Sat Sep 17, 2005 8:05 am   
 
thanks that makes it much easier to comprehend.
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