[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  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] Refresh page


Posted by Winddancer   (26 posts)  [Biography] 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>'
[Go to top] top

Posted by Nick Gammon   Australia  (22,966 posts)  [Biography] 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
[Go to top] top

Posted by Winddancer   (26 posts)  [Biography] 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 '='
[Go to top] top

Posted by AdInfinitum   (74 posts)  [Biography] 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.
[Go to top] top

Posted by Nick Gammon   Australia  (22,966 posts)  [Biography] 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
[Go to top] top

Posted by Winddancer   (26 posts)  [Biography] 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.
[Go to top] top

Posted by AdInfinitum   (74 posts)  [Biography] 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.
[Go to top] top

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

end if

with
end -- if

Problem persists
[Go to top] top

Posted by Nick Gammon   Australia  (22,966 posts)  [Biography] 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
[Go to top] 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.


5,856 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]