Calling an Alias

Post Reply
BrandNew
Posts: 21
Joined: Mon Sep 14, 2009 1:23 am

Calling an Alias

Post by BrandNew »

I've dug around the manual and forums but can't find anything relating to my problem.

I've got my prompt trigger which looks has this statement:

Code: Select all

if (maxhealth - 800 > health and sparkbalance == 1) then
send(spark)
end
and then this alias:

Code: Select all

Alias name: sparkAlias
Pattern: ^spark$

send("outr sparkleberry;eat sparkleberry")
but, while I will drink health I won't eat sparkleberry. I'd
Attachments
talkan.xml
(1.93 KiB) Downloaded 444 times

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Calling an Alias

Post by Heiko »

It's send("spark"). send(spark) would send the text contained in the variable spark if there is one, otherwise it would result in an error.

In your attached script I could see the function execute( ... ) which doesn't exist in the Mudlet API and isn't defined in the xml file that you've attached to your posting so I think that this is what you are after.

send("spark") will send the clear text "spark" to the MUD directly via the underlying socket layer. This function will not invoke the alias expansion and input trigger system. If you want to invoke your alias system to process the command that you want to send to the MUD you can call the function expandAlias("spark"). If you have defined an alias (=input trigger) that triggers on the pattern "spark" the respective script will be executed. Note that using expandAlias("spark") from within an alias script that is triggered on the input pattern "spark" may lead to infinite recursion and thus hang Mudlet unless you take special precautions to prevent this e.g. via on/off switch variables etc.. Using expandAlias("spark") from triggers, timers etc. is usually safe.

BrandNew
Posts: 21
Joined: Mon Sep 14, 2009 1:23 am

Re: Calling an Alias

Post by BrandNew »

send("spark") never did work, but expandAlias("spark") did the trick. Thanks!

Post Reply