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
ReedN
Wizard


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Tue Jan 06, 2009 6:18 pm   

Differences between calling an alias and triggering a command trigger
 
I need a little refresher on how aliases and command triggers can be called from within an alias.

If I'm in an alias and I want to call an alias and the name of the alias is inside a variable, I think I can do the following to call the alias:

#var function_name function1
@function_name

However, if instead of having an alias named function1 I have a 'command' type trigger with "^function1" as the trigger text, the trigger doesn't fire.

Is there any way for text output from an executing alias to trigger a 'command' trigger?
Reply with quote
Arde
Enchanter


Joined: 09 Sep 2007
Posts: 605

PostPosted: Tue Jan 06, 2009 6:52 pm   
 
You forget about "Start line with command" requirement in CMUD. Your @function_name alone should not work.
Write it as #EXEC @function_name - it will call an alias with name of "function1" or trigger Command Input trigger with "^function1" pattern - it depends on what setting you have.
Reply with quote
ReedN
Wizard


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Tue Jan 06, 2009 7:39 pm   
 
What settings does it depend upon for triggering the command input trigger?
Reply with quote
Arde
Enchanter


Joined: 09 Sep 2007
Posts: 605

PostPosted: Tue Jan 06, 2009 8:04 pm   
 
I meant that if you have the function1 alias, then "#EXEC @function_name" will call it; if you have Command Input trigger with input pattern "^function1", then "#EXEC @function_name" will cause it to fire. Just use "#EXEC @function_name" in any case. Sorry if I hadn't write my previous post clear.
_________________
My personal bug|wish list:
-Wrong Priority when copy-paste setting
-1 prompt trigger for Mapper, Session and General Options, not 3 different!
-#SECTION can terminate threads
-Buttons can't start threads
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Tue Jan 06, 2009 8:53 pm   
 
If all you're trying to do is get a trigger to fire, though, you might find it easier to move the code from the trigger into something else (alias, function, event) to save having to go through the trigger engine. Calling the script directly will always be faster than running a regex.
_________________
Rorso's syntax colouriser.

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


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Tue Jan 06, 2009 8:59 pm   
 
I'd love to change it, but I thought this was the best way to accomplish it. What I'm doing is using the command input trigger to match when any of the directions are used, ie "n|ne|e|se|s|sw|w|nw|in|out" and if they are then I set some variables so I know in my own code that I'm moving. Since I want the same thing to run when any of those 10 things are input, I used a command input trigger "^\s*(n|ne|e|se|s|sw|w|nw|in|out)" and then I only have to write the code once. If I switched this to aliases then I'd have to create 10 aliases.

Is there a better way to accomplish this?
Reply with quote
ReedN
Wizard


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Tue Jan 06, 2009 9:01 pm   
 
Arde wrote:
I meant that if you have the function1 alias, then "#EXEC @function_name" will call it; if you have Command Input trigger with input pattern "^function1", then "#EXEC @function_name" will cause it to fire. Just use "#EXEC @function_name" in any case. Sorry if I hadn't write my previous post clear.


I've been struggling with this because when I do #EXEC @function_name, it will display the code to the screen and send it to the Mud, but the command Input Trigger with "^function1" will not fire.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue Jan 06, 2009 9:33 pm   
 
Maybe try #send instead of #exec?
Reply with quote
Arde
Enchanter


Joined: 09 Sep 2007
Posts: 605

PostPosted: Tue Jan 06, 2009 10:03 pm   
 
ReedN wrote:
Arde wrote:
I meant that if you have the function1 alias, then "#EXEC @function_name" will call it; if you have Command Input trigger with input pattern "^function1", then "#EXEC @function_name" will cause it to fire. Just use "#EXEC @function_name" in any case. Sorry if I hadn't write my previous post clear.


I've been struggling with this because when I do #EXEC @function_name, it will display the code to the screen and send it to the Mud, but the command Input Trigger with "^function1" will not fire.


Its strange, because I've ran several tests in the untitled session before posting here. Confused
Reply with quote
ReedN
Wizard


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Tue Jan 06, 2009 11:10 pm   
 
I'll investigate further to see if I can figure out the discrepancy.
Reply with quote
ReedN
Wizard


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Wed Jan 07, 2009 3:32 pm   
 
It should and does fire the command input trigger (in a mocked up example), but somehow in my event it is not. It may be a bug in Cmud or something really strange I have going on, but it isn't firing in mine like it should. I've tried debugging this, but I ran into a whole other set of bugs so it may be a while until I can properly untwist this one.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Jan 07, 2009 9:10 pm   
 
From what you've described in the other postings, your package(s) have gotten really mucked up. Once that happens, almost anything could happen. You might have to copy your code into new packages.
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Thu Jan 08, 2009 6:26 am   
 
ReedN wrote:
I'd love to change it, but I thought this was the best way to accomplish it. What I'm doing is using the command input trigger to match when any of the directions are used, ie "n|ne|e|se|s|sw|w|nw|in|out" and if they are then I set some variables so I know in my own code that I'm moving. Since I want the same thing to run when any of those 10 things are input, I used a command input trigger "^\s*(n|ne|e|se|s|sw|w|nw|in|out)" and then I only have to write the code once. If I switched this to aliases then I'd have to create 10 aliases.

Is there a better way to accomplish this?


I do the same thing.

I use almost the same command input trigger:

Code:
^(?>[ns][ew]?|[ew]|in|out|[ud])$


By the way, this thread is kind of confusing naming an alias a function? To call a function you use #call @function().
Reply with quote
ReedN
Wizard


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Thu Jan 08, 2009 7:25 am   
 
That's a really complex way to match cardinal directions. Very Happy

Is the '?>' equivalent to the '?:'?
Reply with quote
Arde
Enchanter


Joined: 09 Sep 2007
Posts: 605

PostPosted: Thu Jan 08, 2009 8:41 am   
 
ReedN wrote:
Is the '?>' equivalent to the '?:'?

It's an atomic group - '(?>)'
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