About Us
Products
Purchase
Downloads
Support
Forums
Contact Us
Site
 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
miconnor
Newbie


Joined: 27 Aug 2008
Posts: 5

PostPosted: Sun Aug 31, 2008 2:32 am   

using alias to create a trigger
 
I'm trying to use an alias to create aliases and triggers for some spell macros. creating aliases works great, but I'm having some trouble with trigger creation. Here's the alias I'm trying to use

Code:

new_spell:

$spell = %-2
$abrv = %1
#alias $abrv {cast '$spell' %-1} {Sorcerer Spells}
#trigger {$spell} {#SUB {$spell} {$spell ($abrv)}} {Sorcerer Spells|Spell Alias}


If execute the above like this

new_spell bb bigbys clenched fist

it creates the correct alias

Code:

bb:

cast 'bigbys clenched fist' %-1


but it creates a trigger with the pattern= $spell
and the script as
Code:

#SUB bigbys clenched fist {bigbys clenched fist (bb)}


if I change the #trigger command slightly to
Code:

#trigger "" $spell {#SUB {$spell} {$spell ($abrv)}} {Sorcerer Spells|Spell Alias}


then it seems to fool it a little. It creates a trigger with the correct pattern, but now the #sub command does not expand the local variables, resulting in
Code:

#SUB $spell {$spell ($abrv)}


Of course, I need the result to be a combination of the two. Any suggestions?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sun Aug 31, 2008 3:43 am   
 
Looks like your #SUB syntax is wrong.

#SUB {replacement string} <-- use it this way when #SUB is inside a trigger, the #SUB will change the trigger pattern to the replacement string

#SUB pattern {replacement string} <-- use it this way from the command line or non-trigger setting. This is the same as #TRIGGER {pattern} {#SUB {replacement string}}
_________________
EDIT: I didn't like my old signature
Reply with quote
miconnor
Newbie


Joined: 27 Aug 2008
Posts: 5

PostPosted: Sun Aug 31, 2008 3:56 am   
 
Well, thanks for that syntax correction, but I still have the same problem. Instead of creating the command

#SUB {bigbys clenched fist (bb)}

I get

#SUB {$spell ($abrv)}

inside the trigger
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Sun Aug 31, 2008 3:57 am   
 
Of course, this has been answered in the past, and the answer is still the same. :) Makes it a lot easier, too.

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <alias name="new_spell" copy="yes">
    <value>#EXEC %concat( "#ALIAS ", %1, " {cast '", %-2, "' %-1} {Sorcerer Spells}")
#EXEC %concat( "#TRIGGER {", %-2, "} {#SUB {", %-2, " (", %1, ")}} {Sorcerer Spells|Spell Alias}")</value>
  </alias>
</cmud>


Copy/paste that into Package Editor. I cleaned it up quite a bit, too, since you don't need the $locals in there, really. Tested on my system, works great. :P

Charneus
Reply with quote
miconnor
Newbie


Joined: 27 Aug 2008
Posts: 5

PostPosted: Sun Aug 31, 2008 4:02 am   
 
That works great, thanks a lot.
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