Start aliases from Mudlet Buttons

Share your scripts and packages with other Mudlet users.
Post Reply
oshumed
Posts: 2
Joined: Sat Feb 04, 2023 6:37 pm

Start aliases from Mudlet Buttons

Post by oshumed »

Hi.

Sometimes i code some alias in mudlet for clessidra (italian mud).
I want to start one of these aliases from a button.
How can i start an alias from a button (i don't want to replicate code)?
Thanks.

Andrea

User avatar
demonnic
Posts: 884
Joined: Sat Dec 05, 2009 3:19 pm

Re: Start aliases from Mudlet Buttons

Post by demonnic »

You should put the code from the alias into a function in a Script, and then call that function from both the alias and the button. For example, if the alias does
Code: [show] | [select all] lua
send("cast 'armor' " .. matches[2])
Then you could put a function like this in a script
Code: [show] | [select all] lua
function castArmor(target)
  send("cast 'armor' " .. target)
end
And use castArmor(matches[2]) in the alias, and castArmor("Ted") or whatever in the button.

There is a function called expandAlias you can use to call an alias, but there are several reasons not to, as outlined HERE

oshumed
Posts: 2
Joined: Sat Feb 04, 2023 6:37 pm

Re: Start aliases from Mudlet Buttons

Post by oshumed »

Thank you!

User avatar
demonnic
Posts: 884
Joined: Sat Dec 05, 2009 3:19 pm

Re: Start aliases from Mudlet Buttons

Post by demonnic »

Happy to help =)

Post Reply