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
klerindias
Novice


Joined: 23 Jan 2010
Posts: 37

PostPosted: Mon Apr 30, 2012 8:51 am   

using %1 %2
 
Hi,
I got probably simple problem.

I had cmud 2.34 and alias like this worked well.
And after i changed to 3.34 this things stop to work

#alias gbp {get %1 %2.bp}

example:

gbp bracer 1 should do -> get bracer 1.bp

it showing now:

get bracer -> You do not see bracer here.

So it missing 1.bp somehow.

this not works and tried many option and not working.

and aliases like

#alias er {enter %1.rift} not works as well

with %1 working like this:

er 1 should do -> enter 1.rift

it showing now

enter -> You can't seem to find anything to enter.

So it missing 1.rift

what am i missing?
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Mon Apr 30, 2012 12:55 pm   
 
Change it to:
#alias gbp {get %1 {%2}.bp}
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Mon Apr 30, 2012 2:19 pm   
 
@Rahab: That doesn't work. Not sure why, but it says there's an extra } brace, whether you try to paste it in on the command line or make an alias manually and then try to run it. Possible bug here?

@klerindias: The problem is actually that the function of the dot changed when database variables were rewritten. Your code is looking for a 'bp' or a 'rift' key in %1, and not finding it, so it expands to null. If you want a literal dot, you need to enclose it in quotes.
Reply with quote
klerindias
Novice


Joined: 23 Jan 2010
Posts: 37

PostPosted: Mon Apr 30, 2012 2:34 pm   
 
Rahab wrote:
Change it to:
#alias gbp {get %1 {%2}.bp}


so i did:

get %1 {%2}.bp

and:

i write

gbp bracer 1 -> (it sending) get %1 {%2}.bp

result:
You do not see or have the {%2}.bp.

in compile tab saying error:
Error compiling script:
extra } brace
Reply with quote
klerindias
Novice


Joined: 23 Jan 2010
Posts: 37

PostPosted: Mon Apr 30, 2012 2:37 pm   
 
Daern wrote:

@klerindias: The problem is actually that the function of the dot changed when database variables were rewritten. Your code is looking for a 'bp' or a 'rift' key in %1, and not finding it, so it expands to null. If you want a literal dot, you need to enclose it in quotes.


So how this alias should looks like?
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Mon Apr 30, 2012 2:45 pm   
 
Try this:
Code:
#alias gbp {#send {"get "%1" "%2".bp"}}


Just get %1 %2"."bp would technically be enough (it's only the dot that you need to force to be a literal) but it's generally good practice to put quotes around anything that you want to be a literal string.
Reply with quote
klerindias
Novice


Joined: 23 Jan 2010
Posts: 37

PostPosted: Mon Apr 30, 2012 3:27 pm   
 
When i do:

#alias lh {exa %1.hole}

it not works like i showed above

but when i used it just once and replace %1 with %0 it works.

Problem is just when you use more than 1.

#alias lh {exa %0.hole} works

so for the future for people they must just change where they use more than 1 parameter need use quotes
with just 1 parameter enough to change to %0.

If im mistaken somone please check me.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Mon Apr 30, 2012 4:19 pm   
 
Ultimately, the problem is with implicit concatenation. As Daern indicated, a dot and text following a numeral now looks like database variable reference.

In general, the most thorough solution to problems with implicit concatentation is to turn it into explicit concatenation:
Code:

#alias gbp {#SEND %concat("get ",%1, " ", %2, ".bp")}
#alias lh {#SEND %concat("exa ", %1, ".hole")}
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