alias inside an alias

Posted by Val on Sat 03 Nov 2012 10:24 PM — 10 posts, 33,880 views.

#0
Hi

I've had a look as the faq item 38 where it describes adding an alias into an alias, unfortunately I don't get it. I did try checking the send to: Execute at the bottom section of the alias box, but that did not seem to work.

I have an alias where I memorise a spell, and I want to add an alias which I have that sends out an emote of them finishing

so by typing ms fireball the alias will send "memorize fireball" then sends "closes his book and stands"

This is what I wrote

<aliases>
  <alias
   match="ms *"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

Send ("memorize %1")

DoAfter (2,"emotebook")

</send>
  </alias>
</aliases>


Thanks as always

Val
Amended on Sat 03 Nov 2012 10:30 PM by Val
Australia Forum Administrator #1
You need to send "emotebook" to execute, like this:


<aliases>
  <alias
   match="ms *"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

Send ("memorize %1")

DoAfterSpecial (2, "emotebook", sendto.execute)

</send>
  </alias>
</aliases>



Template:function=DoAfterSpecial
DoAfterSpecial

The documentation for the DoAfterSpecial script function is available online. It is also in the MUSHclient help file.



"Execute" re-evaluates aliases (which I presume emotebook is) whereas Send (or DoAfter) does not evaluate aliases.
Amended on Sat 03 Nov 2012 10:31 PM by Nick Gammon
#2
Thank you!

Val
#3
A follow on question if you will

one of my alias has a random function, inside that I want to delay its response by a few seconds.

I can get it to work without a delay, but as the output is quick it looks strange.

Currently I have this


<aliases>
  <alias
   match="standbook"
   enabled="y"
   expand_variables="y"
   send_to="12"
   sequence="100"
  >
  <send>things = {"slowly", "stretches then stands", "picks himself up", "glances at his book before tucking it away and standing"}


colour = {"%^GREEN%^", "%^BOLD%^%^WHITE%^", "%^YELLOW%^", "%^BOLD%^%^BLUE%^", "%^BOLD%^%^CYAN%^"}

SetVariable ("colour", colour [math.random (1, #things)])

local colour = GetVariable("colour")

Send ("emote " .. colour,"places the book to one side and ", things [math.random(1, #things)], " stands")</send>
  </alias>
</aliases>


what I would like is something like this


<aliases>
  <alias
   match="standbook"
   enabled="y"
   expand_variables="y"
   send_to="12"
   sequence="100"
  >
  <send>things = {"slowly", "stretches then stands", "picks himself up", "glances at his book before tucking it away //r//n DoAfter (2, "stand slowly")"}


colour = {"%^GREEN%^", "%^BOLD%^%^WHITE%^", "%^YELLOW%^", "%^BOLD%^%^BLUE%^", "%^BOLD%^%^CYAN%^"}

SetVariable ("colour", colour [math.random (1, #things)])

local colour = GetVariable("colour")

Send ("emote " .. colour,"places the book to one side and ", things [math.random(1, #things)], " stands")</send>
  </alias>
</aliases>


In this cast the stand is a normal social emote for the mud, but I may want to add in my own alias there instead.

Can you advise me how to make it work?

Thanks

Val
Australia Forum Administrator #4
How do you want it to look? Can you just show an example? eg.


Nick places the book to one side and stretches then stands.

< 2 second pause>

Nick stands.


Is that what you mean?
#5
yes

just like that

Val
Australia Forum Administrator #6
Something like what you had with DoAfter in it:


<aliases>
  <alias
   match="standbook"
   enabled="y"
   expand_variables="y"
   send_to="12"
   sequence="100"
  >
  <send>

things = {"slowly", "stretches then stands", "picks himself up", "glances at his book before tucking it away and standing"}


colour = {"%^GREEN%^", "%^BOLD%^%^WHITE%^", "%^YELLOW%^", "%^BOLD%^%^BLUE%^", "%^BOLD%^%^CYAN%^"}

SetVariable ("colour", colour [math.random (1, #things)])

local colour = GetVariable("colour")

Send ("emote " .. colour,"places the book to one side and ", things [math.random(1, #things)])

DoAfter (2, "stands")
</send>
  </alias>
</aliases>

#7
Hi

The only problem I had with that was it sent 'stand' for all of them. I was hoping it may be possible to somehow have it for just one item in the list which is why I tried to place DoAfter inside the things list.

The last one in the list reads
'glances at his book before tucking it away and standing',

but should read
'glances at his book before tucking'
followed by the two second delay before 'stand' is sent.

The rest of the list is fine without sending the stand command by itself.

Hope you can follow that

Thanks

Val
Australia Forum Administrator #8
Well, something like this then:


<aliases>
  <alias
   match="standbook"
   enabled="y"
   expand_variables="y"
   send_to="12"
   sequence="100"
  >
  <send>

things = {
   {now = "slowly"},
   {now = "stretches then stands"},
   {now = "picks himself up"},

   {now = "glances at his book before tucking it away", 
    soon = "stands"},


-- more here
  } -- end of things


colour = {"%^GREEN%^", "%^BOLD%^%^WHITE%^", "%^YELLOW%^", "%^BOLD%^%^BLUE%^", "%^BOLD%^%^CYAN%^"}

SetVariable ("colour", colour [math.random (1, #colour)])

local colour = GetVariable("colour")
local which = math.random(1, #things)
Send ("emote " .. colour,"places the book to one side and ", things [which].now)

if things [which].soon then
  DoAfter (2, things [which].soon)
end -- if
</send>
  </alias>
</aliases>



I've changed your table to have things done "now" and "soon" (a table within a table).

It does the "now" stuff first, and then after two seconds the "soon" stuff (if any).
Amended on Mon 05 Nov 2012 11:04 PM by Nick Gammon
#9
Works a treat.

Thanks for your time

Val