Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
SJ Hook
Beginner


Joined: 17 Jun 2005
Posts: 18

PostPosted: Sat Nov 08, 2008 4:47 pm   

%db and %replace simple question.
 
Hello

I was using something like that on Zmud:
Code:

#TR @vTest

#CW 5
#ST >%ansi( 128)F5-> Kill %ansi( 7)
#KE F5 {
  kill %db( @vTest, %replace( %1))
  }


Variable @vTest was in looking like this:
Code:

goblin=green ugly looking monster
ork=black tall warrior
trooper=shiny trooper with a gun


It was working fine on old zMud, but now I cant get that work on Cmud, all I get is "kill " on screen, nothing else. I guess im missing something.

Anyone can help me please?
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Sat Nov 08, 2008 5:03 pm   
 
If it was working in zMUD, I'm surprised. %replace takes an old string and replaces it with a new string. Therefore, it requires three parameters.

Without knowing more about your script, I'd imagine changing the kill %db(@vTest, %replace(%1)) to just kill %db(@vTest, %1) will work just fine.

Charneus
Reply with quote
SJ Hook
Beginner


Joined: 17 Jun 2005
Posts: 18

PostPosted: Sat Nov 08, 2008 5:34 pm   
 
charneus wrote:
If it was working in zMUD, I'm surprised. %replace takes an old string and replaces it with a new string. Therefore, it requires three parameters.

Without knowing more about your script, I'd imagine changing the kill %db(@vTest, %replace(%1)) to just kill %db(@vTest, %1) will work just fine.

Charneus

Thx for fast answer, but, I tryied that too, and its simply not working, I still get only "kill " and nothing else behind.
The script should check if the key 'trooper' exist in @vTest and if yes, it should get value from the 'trooper' key, and bind on F5 ' kill shiny trooper with a gun'. Any ideas?
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Sat Nov 08, 2008 6:14 pm   
 
Well, it appears your trigger is NOT capturing any vital information. Assuming the rest of the code is within the TRIGGER part, change your trigger to:

#TR ({@vTest})

That should work. I haven't tested it myself today, but I'll test it soon enough if it doesn't work for you.

Charneus
Reply with quote
SJ Hook
Beginner


Joined: 17 Jun 2005
Posts: 18

PostPosted: Sat Nov 08, 2008 6:52 pm   
 
Yr right, all the time I was looking in the wrong place.... thanks so much Charneus.
Last question, its working good on #SHOW, but its not working on #KEY F5 {kill %db( @vTest, %1)}, all I have on key is 'kill %db( @vTest, %1)' instead of 'kill shiny trooper with a gun' . What do I need to add?
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Sat Nov 08, 2008 7:01 pm   
 
Hmmm... not sure why it's not working correctly in that case. It may be that it's not all on one line. Try putting it as #KEY F5 {kill %db(@vTest, %1)} instead of on three separate lines. However, if that still doesn't work, there is a workaround for it, I'm sure, which is:

#EXEC {%concat("#KEY F5 {kill ",%db(@vTest, %1),"}")}

That should work.
Reply with quote
SJ Hook
Beginner


Joined: 17 Jun 2005
Posts: 18

PostPosted: Sat Nov 08, 2008 7:13 pm   
 
Yes, its working now perfectly, thank U soo much .
Now im off to kill that troopers Mr. Green
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sat Nov 08, 2008 7:17 pm   
 
You know, it might be a lot simpler, rather than redefining the macro each time, to just have the macro do, say, kill @something and then your script do something=%db(@vTest,%1). You could also just store the value of %1 in a variable and do the %db function in the macro.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)

Last edited by Fang Xianfu on Sat Nov 08, 2008 7:56 pm; edited 1 time in total
Reply with quote
SJ Hook
Beginner


Joined: 17 Jun 2005
Posts: 18

PostPosted: Sat Nov 08, 2008 7:26 pm   
 
Nice idea too, this kill list is very long, I will test which method is more effective for me.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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