Alias setting an alias with multiple commands

Posted by Winddancer on Sat 05 Nov 2022 12:23 AM — 9 posts, 20,429 views.

#0
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>'
Amended on Sat 05 Nov 2022 12:24 AM by Winddancer
Australia Forum Administrator #1
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).
#2
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 '='
Amended on Sat 05 Nov 2022 09:33 AM by Winddancer
#3
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.
Australia Forum Administrator #4
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.
#5
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.
Amended on Mon 07 Nov 2022 08:47 PM by Winddancer
#6
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.
#7
replaced the

end if

with
end -- if

Problem persists
Australia Forum Administrator #8
Quote:


temp = @myspecialname



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


temp = "@myspecialname"