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


Joined: 29 Aug 2010
Posts: 12

PostPosted: Sun Aug 29, 2010 6:35 am   

Complex alias (maybe)
 
Hello all,

I'm trying to create a spell casting alias that will fill some variables automatically and parse the output properly to the MUD. Here's an example:

Code:

Input from me:
cast 'magic missile' 'male goblin'
cast mag goblin
cast mag 'male goblin'
cast 'minor magic barrier'
cast invis


My variables are @spell and @target. Pretty obvious what goes where, but I'm having a heck of a time getting the alias right. I have the following code:

Code:

#LOCAL $Spell
#LOOP %numparam-1 {$Spell = %concat($Spell,%param(%i)," ")}
$Spell = %trim($Spell)
#var target %param(%numparam)
cast '$Spell' @target


This works ok on input such as "c magic missile goblin", but if I input "cast detect invis", obviously it sets @target to invis. Is there a way to parse parameters that are in between single quotes? I.E. "cast 'magic missile' 'male goblin'" I've looked through the help file and think regex is what I need to use, but I'm having a real brain fart in trying to figure it out. I don't think I will have any more than one target on any spell, but the target might be multiple words.

Thanx
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4689
Location: Pensacola, FL, USA

PostPosted: Sun Aug 29, 2010 9:50 am   
 
try using double quotes?
that should force multiple words to only use one parameter
_________________
Discord: Shalimarwildcat
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4689
Location: Pensacola, FL, USA

PostPosted: Sun Aug 29, 2010 9:55 am   
 
#ALIAS c($spell, $target) {cast $spell $target}

c "this spell" "those guys"
c "head exploding" dog
c identify "my weapon"
_________________
Discord: Shalimarwildcat
Reply with quote
SteveThing
Beginner


Joined: 29 Aug 2010
Posts: 12

PostPosted: Sun Aug 29, 2010 10:58 am   
 
I'll give that a shot.

Thank you!
Reply with quote
SteveThing
Beginner


Joined: 29 Aug 2010
Posts: 12

PostPosted: Mon Sep 06, 2010 4:03 am   
 
I tried the following:

<alias name="c($spell, $victim)" id="138">
<value>#var target $victim
cast $spell @target</value>
</alias>

Doesn't even fire. Did I miss something?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Sep 06, 2010 3:38 pm   
 
That because you made the alias name "c($spell,$victim)" instead of just "c". For named parameters, you do things like Shalimar posted (you can copy that code and put it in the commandline, then press enter) OR you enter the parameters in the Params field in the Package Editor (it'll be in the More/Less panel.)
_________________
EDIT: I didn't like my old signature
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