|
SteveThing Beginner
Joined: 29 Aug 2010 Posts: 12
|
Posted: 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 |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4690 Location: Pensacola, FL, USA
|
Posted: Sun Aug 29, 2010 9:50 am |
try using double quotes?
that should force multiple words to only use one parameter |
|
_________________ Discord: Shalimarwildcat |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4690 Location: Pensacola, FL, USA
|
Posted: 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 |
|
|
|
SteveThing Beginner
Joined: 29 Aug 2010 Posts: 12
|
Posted: Sun Aug 29, 2010 10:58 am |
I'll give that a shot.
Thank you! |
|
|
|
SteveThing Beginner
Joined: 29 Aug 2010 Posts: 12
|
Posted: 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? |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: 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 |
|
|
|
|
|