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


Joined: 02 Nov 2008
Posts: 10

PostPosted: Sun Nov 02, 2008 8:37 pm   

Need an idea on how to begin...
 
I have a Bard in Imperian and I’m trying to write something that would allow me to sing songs with multiple words by using a short name for the word. It would be something like this.

Sing %1 (person) %2 (person) %3 (person)

%1= light
%2+= fly
%3 = shiver

But the actually song names I would prefer to be able to use short hand for, so that I would actually type in something like:

sing l f s billybob

and it would convert it to sing light billybob fly billybob shiver billybob

Also it would have to take into account that sometimes I would be using 1 spell, sometimes 2 or more.

It would be great if someone could give me an example or place to start.
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Sun Nov 02, 2008 9:06 pm   
 
Edited version:

songshorthand="l=light|f=fly|s=shiver"
#ALIAS sing {#LOOP %eval( %numparam( )-1) {~sing %db( @songshorthand, %param( %i)) %param( %numparam( ))}}

That should get you started. It's not perfect yet, but at least it's something. I'll keep trying to come up with something different that fully works.

Charneus
Reply with quote
impyplayer
Beginner


Joined: 02 Nov 2008
Posts: 10

PostPosted: Tue Nov 04, 2008 2:28 pm   
 
Hi Charneus,

Thanks for your help on this. I took your example and have been trying to play with. Unfortunately I’m not really good at coding, so I may be missing something simple. I’ve put in all the shorthand for the songs and am now trying to get the code working, basically doing kind of a hit and miss thing. I’ve been reading the help files but haven’t really gotten much to work.

When I put your example in I got:

#LOOP %eval( %numparam( )-1) {~sing %db( @songshorthand, %param( %i)) %param( %numparam( ))}

Enter: sing f l
- sing flight l f l

So I figured I could at least try and put my target alias in. With that I got:

#LOOP %eval( %numparam( )-1) {~sing %db( @songshorthand, %param( %i)) @target %param( %numparam( ))}

Enter: sing f l
-sing flight billybob l f l

So the first one seems to work and then it no longer converts the shorthand, plus it adds two more of the same input and it only targets once. The outcome I’m trying to get too is:

Sing flight billybob light billybob (with the possibility of at least one more “song name billybob”)

I fiddled with some of it and got a single version to work using:

~sing %db( @songshorthand, %param( %1)) @target
#noop

Enter: sing f
-sing flight billybob

So now I’m trying to combine your version with the single version. I’ve done as many combos as I can think of and nothing is working. Like I said, it might be an easy fix I really have no idea. Any ideas?
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Tue Nov 04, 2008 5:20 pm   
 
I think you'll need to loop and put your command in a string. By way of example; I've not tested this:

string=""
#loop %numparam()-1 {string=%concat(@string," ",%db(@songshorthand,%param(%i))," ",%param(%numparam())," ")}
~sing @string

This follows on from Charneus' idea of having a list of shorthands in a database variable, where keys are shortcuts and values are long names. You loop through each of the song parameters, adding the long version of that song and the name to the end of a string. Once the string is complete, you sing the result.

If you want to use a variable @target with this alias (something you didn't mention in your original post), I'd suggest adding another layer of abstraction. Don't call this alias (with the code I gave above) sing; call it something else, like SingSH or something. Then use another alias, this one called sing, that uses your @target variable. You can then do, say:

#alias sing {singsh %1 %2 %3 @target}
#alias singat {singsh %1 %2 %3 %4}

or whatever.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Tue Nov 04, 2008 6:22 pm   
 
Alternatively, what you could also do is the following:

#ALIAS sing {#LOOP 2,%numparam() {~sing %db(@songshorthand, %param(%i)) %2}}

Of course, doing it this way, you'd have to do:

sing billybob f l s

But if you can get used to that syntax, it might make things that much easier. Just a thought. At work, so can't test it right now.

Charneus
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Tue Nov 04, 2008 7:11 pm   
 
But that's not what he's after, charneus. Changing the order of the parameters is pretty trivial - though I think you meant %1 at the end rather than %2.

The idea of this problem isn't to send three separate sing commands, but just one. So not "sing flight billybob;sing something billybob;sing somethingelse billybob" but "sing flight billybob something billybob somethingelse billybob", which is a different problem.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Tue Nov 04, 2008 8:03 pm   
 
Bah. You're right, Fang. I misread and also mistyped.

In view of my errors, the correct way would probably be to do a string. So...

#LOOP 1,(%numparam()-1) {string=%concat(@string, " ", %db(@songshorthand, %param(%i)), " ",%param(%numparam()))}:~sing @string

I believe that's what Fang had. :p Good luck!

Charneus
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