Help with a table script in lua 5.1+ mushclient

Posted by Edwin_r on Mon 23 Jul 2012 05:25 PM — 6 posts, 21,068 views.

#0
Hello

I'm a completely newbie in Lua, and i woud appreciate if someone could sumbit a code to make an alias for this:

[cast] {"haste", "sanctuary", "evil protection"}

where the spells should be into a table, i guess

The idea is when i execute the alias, automatically cast haste, then cast sanctuary, then cast 'evil protection'.
Note the simply quotes in 'evil protection.

Another example of what i'm lookin for :
[cast antifire] {"boots", "cap", "gloves"}

-------------------------------------
The other code i need it's one to antifire objects by the number of these. E.g:
(7) sanctuary potion

i would like to type: antif sanctuary 7

and the "alias" antif (cast antifire) should cast antifire to the 7 potions of sanctuary: 1.sanctuary, then 2.sanctuary... up to 7th potion


thank you so much for your answers!!!
Australia Forum Administrator #1
The simple thing would be to make an alias that just sends multiple lines. Do you need more complexity? eg. Send:


cast haste
cast sanctuary
cast evil protection
#2
Nick Gammon said:

The simple thing would be to make an alias that just sends multiple lines. Do you need more complexity? eg. Send:


cast haste
cast sanctuary
cast evil protection



--------------------
Yes Nick. I actually use some variables containing several objects and spells (~30 each one), so i would like to invoke variables or tables from inside a code like:

Send("cast '@castingspell'")

...matching every contents of the table, thank you so much
Australia Forum Administrator #3
Read up on Lua tables. Here's an example:


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

wanted = {"haste", "sanctuary", "evil protection"}

for k, v in ipairs (wanted) do
  Send ("cast ", v)
end -- for

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

#4
Nick Gammon said:

Read up on Lua tables. Here's an example:


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

wanted = {"haste", "sanctuary", "evil protection"}

for k, v in ipairs (wanted) do
  Send ("cast ", v)
end -- for

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



------------------------

Thank YOU!!! Nick.

The other code i need it's one to antifire objects by the number of these. E.g:
(7) sanctuary potion

i would like to type: antif sanctuary 7

and the "alias" antif (cast antifire) should cast antifire to the 7 potions of sanctuary: 1.sanctuary, then 2.sanctuary... up to 7th potion

I'll trouble you no more, promess
#5
Edwin_r said:

Nick Gammon said:

Read up on Lua tables. Here's an example:


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

wanted = {"haste", "sanctuary", "evil protection"}

for k, v in ipairs (wanted) do
  Send ("cast ", v)
end -- for

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



------------------------

Thank YOU!!! Nick.

The other code i need it's one to antifire objects by the number of these. E.g:
(7) sanctuary potion

i would like to type: antif sanctuary 7

and the "alias" antif (cast antifire) should cast antifire to the 7 potions of sanctuary: 1.sanctuary, then 2.sanctuary... up to 7th potion

I'll trouble you no more, promess


-------------------------
Thanks to your hint, i've done this code by my self:

alias: antif (\w*) (\w*)
for i = 1, %2 do Send ("cast antif ",(i),".%1")
end -- for
(send to script)

now i type: antif sanctuary 2
and lua sends to world:
"cast antif 1.sanctuary
cast antif 2.sanctuary"

hehehe, thank you so much Nick!!! :-)