Page 1 of 1

Start aliases from Mudlet Buttons

Posted: Sat Feb 04, 2023 6:41 pm
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

Re: Start aliases from Mudlet Buttons

Posted: Sat Feb 04, 2023 7:09 pm
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

Re: Start aliases from Mudlet Buttons

Posted: Sat Feb 04, 2023 8:38 pm
by oshumed
Thank you!

Re: Start aliases from Mudlet Buttons

Posted: Sat Feb 04, 2023 10:47 pm
by demonnic
Happy to help =)