Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ General ➜ Alias setting an alias with multiple commands

Alias setting an alias with multiple commands

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Winddancer   (26 posts)  Bio
Date Sat 05 Nov 2022 12:23 AM (UTC)

Amended on Sat 05 Nov 2022 12:24 AM (UTC) by Winddancer

Message
Sorry to be a bother again...
What I want to accomplish:
a) triggering a list of commands upon an attack message
b) setting up variations for the list of commands

E.g. Upon the message that I hit my opponent, I want to execute a list of special attacks, depending on a variable I set before.
When doing normal combat I want to use the specials impale, elbow, knee, headbutt and kick. This sequence of specials I would call "simpale".
When doing combat in heavy armour, e.g. I don't want to do leg attacks, as I may fail, fall to the ground and be a tempting target. Therefore my list of specials would only be impale, elbow and headbutt. This different sequence of specials I would call "snlimpale"

These sequences shall be triggered by "You smash*", "You thrust*" and "You swing*".


  <alias
   match="simpale"
   enabled="y"
   expand_variables="y"
   group="specials"
   send_to="12"
   sequence="100"
  >
  <send>SetVariable("myspecialname" , "v_simpale")
</send>
</alias>
  <alias
   match="simpale"
   enabled="y"
   expand_variables="y"
   group="specials"
   send_to="12"
   sequence="100"
  >
  <send>SetVariable("myspecialname" , "v_snlimpale")
</send>
</alias>
  <alias
   match="callSpecial"
   enabled="y"
   expand_variables="y"
   group="specials"
   send_to="12"
   sequence="100"
  >
  <send>temp = GetVariable("@myspecialname")
if (temp = "v_simpale") then
  Send("impale")
  Send("elbow")
  Send("knee")
  Send("headbutt")
  Send("kick")
end if
if (temp = "v_snlimpale") then
  Send("impale")
  Send("elbow")
  Send("headbutt")
end if
</send>
</alias>
<trigger
   enabled="y"
   group="Specials"
   match="You thrust*"
   send_to="12"
   sequence="100"
  >
  <send>callSpecial</send>
</trigger>
<trigger
   enabled="y"
   group="Specials"
   match="You smash*"
   send_to="12"
   sequence="100"
  >
  <send>callSpecial</send>
</trigger>
<trigger
   enabled="y"
   group="Specials"
   match="You swing*"
   send_to="12"
   sequence="100"
  >
  <send>callSpecial</send>
</trigger>

And I am getting the following error message:

[string "Trigger: "]:1: '=' expected near '<eof>'
Top

Posted by Nick Gammon   Australia  (23,070 posts)  Bio   Forum Administrator
Date Reply #1 on Sat 05 Nov 2022 01:39 AM (UTC)
Message
First, if you are expanding variables you don't need the "@" sign.

Quote:


temp = GetVariable("@myspecialname")



Either do:


temp = "@myspecialname"


Or:


temp = GetVariable("myspecialname")





Second, to call an alias from another alias you "send to execute" (10) not "send to script" (12).

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Winddancer   (26 posts)  Bio
Date Reply #2 on Sat 05 Nov 2022 09:09 AM (UTC)

Amended on Sat 05 Nov 2022 09:33 AM (UTC) by Winddancer

Message
Must be still doing something wrong.

Set the alias "callSpecial" to send to execute, as suggested, but getting this outpit instead:


You smash your short wooden spear at the furry blue male gremlin's head and bruise his head severely, leaving an open wound. -- here the trigger calls the callSpecial alias.
temp = v_simpale
Note ("Found myspecialname " .. "v_simpale")
if (temp = "v_simpale") then
Send("impale")
Send("elbow")
Send("knee")
Send("headbutt")
Send("kick")
end if
if (temp = "v_snlimpale") then
Send("impale")
Send("elbow")
Send("headbutt")
end if -- all 14 lines of the callSpecial alias are displayed as userinput, even though I did set the alias to send to execute as suggested.

The furry blue male gremlin's wounds stopped bleeding.

The furry blue male gremlin died.
You killed the furry blue male gremlin.
What?
What?
What?
What?
What?
What?
What?
What?
What?
What?
What?
What?
What?
What? -- 14 times, once for each line in the callSpecial alias



Oh, and here the relevant trigger/alias entries, just to verify ..

  <trigger
   enabled="y"
   group="Specials"
   match="You smash your*"
   send_to="10"
   sequence="100"
  >
  <send>callSpecial</send>
  </trigger>

  <alias
   match="simpale"
   enabled="y"
   expand_variables="y"
   group="specials"
   send_to="12"
   sequence="100"
  >
  <send>SetVariable("myspecial" , "impale")
SetVariable("myspecialname" , "v_simpale")
</send>
  </alias>

  <alias
   match="callSpecial"
   enabled="y"
   expand_variables="y"
   group="specials"
   send_to="10"
   sequence="100"
  >
  <send>temp = @myspecialname
Note ("Found myspecialname " .. "@myspecialname")
if (temp = "v_simpale") then
Send("impale")
Send("elbow")
Send("knee")
Send("headbutt")
Send("kick")
end if
if (temp = "v_snlimpale") then
Send("impale")
Send("elbow")
Send("headbutt")
end if
</send>
  </alias>


Did I set the "send to execute" in the wrong object?
Because, when I set the "callSpecial" alias to sent to script I get this indead:

You thrust your short wooden spear at the big-eared blue female gremlin's head and drill it very deep into her head, causing a nasty, deep wound.
Compile error
World: Geas_Kylar
Immediate execution
[string "Alias: "]:3: ')' expected near '='
Top

Posted by AdInfinitum   (74 posts)  Bio
Date Reply #3 on Mon 07 Nov 2022 07:24 PM (UTC)
Message
Winddancer said:

Must be still doing something wrong.

if (temp = "v_simpale") then
...
if (temp = "v_snlimpale") then


Did I set the "send to execute" in the wrong object?
Because, when I set the "callSpecial" alias to sent to script I get this indead:

You thrust your short wooden spear at the big-eared blue female gremlin's head and drill it very deep into her head, causing a nasty, deep wound.
Compile error
World: Geas_Kylar
Immediate execution
[string "Alias: "]:3: ')' expected near '='



When you are comparing values, you must use "==" and not "=". A single "=" means you are setting the value. "==" is comparing values.
Top

Posted by Nick Gammon   Australia  (23,070 posts)  Bio   Forum Administrator
Date Reply #4 on Mon 07 Nov 2022 07:32 PM (UTC)
Message
The alias which just consists of "callSpecial" is the one which should send-to-execute.

The one with Lua code in it should still be send to script, because it is a script.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Winddancer   (26 posts)  Bio
Date Reply #5 on Mon 07 Nov 2022 08:31 PM (UTC)

Amended on Mon 07 Nov 2022 08:47 PM (UTC) by Winddancer

Message
Ok... callSpecial is send-to-script, and the You smash trigger is send-to-execute.

  <trigger
   enabled="y"
   group="Specials"
   match="You smash your*"
   send_to="10"
   sequence="100"
  >
  <send>callSpecial</send>
  </trigger>

  <alias
   match="callSpecial"
   enabled="y"
   expand_variables="y"
   group="specials"
   send_to="12"
   sequence="100"
  >
  <send>temp = @myspecialname
Note ("Found myspecialname " .. "@myspecialname")
if (temp == "v_simpale") then
Send("impale")
Send("elbow")
Send("knee")
Send("headbutt")
Send("kick")
end -- if
if (temp == "v_snlimpale") then
Send("impale")
Send("elbow")
Send("headbutt")
end -- if
</send>
  </alias>


Still getting a Compile error:

Compile error
World: Geas_Kylar
Immediate execution
[string "Alias: "]:10: unexpected symbol near 'if'

Seems the first if is handled fine, the second is not.
Top

Posted by AdInfinitum   (74 posts)  Bio
Date Reply #6 on Mon 07 Nov 2022 08:39 PM (UTC)
Message
Winddancer said:


 end if



'end if' is not valid in Lua syntax. It simply is just 'end'. If you are wanting to comment that it's the end of the if block, you can do: end -- if.
Top

Posted by Winddancer   (26 posts)  Bio
Date Reply #7 on Mon 07 Nov 2022 09:25 PM (UTC)
Message
replaced the

end if

with
end -- if

Problem persists
Top

Posted by Nick Gammon   Australia  (23,070 posts)  Bio   Forum Administrator
Date Reply #8 on Tue 08 Nov 2022 06:18 AM (UTC)
Message
Quote:


temp = @myspecialname



Assuming myspecialname contains some kind of name, you should be quoting it:


temp = "@myspecialname"

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


8,939 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.