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, confirm your email, resolve issues, 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.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Lua ➜ Help with a table script in lua 5.1+ mushclient

Help with a table script in lua 5.1+ mushclient

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


Posted by Edwin_r   (6 posts)  Bio
Date Mon 23 Jul 2012 05:25 PM (UTC)
Message
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!!!
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Wed 25 Jul 2012 02:58 AM (UTC)
Message
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

- Nick Gammon

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

Posted by Edwin_r   (6 posts)  Bio
Date Reply #2 on Wed 25 Jul 2012 03:04 AM (UTC)
Message
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
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #3 on Wed 25 Jul 2012 03:14 AM (UTC)
Message
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>


- Nick Gammon

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

Posted by Edwin_r   (6 posts)  Bio
Date Reply #4 on Wed 25 Jul 2012 03:50 AM (UTC)
Message
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
Top

Posted by Edwin_r   (6 posts)  Bio
Date Reply #5 on Wed 25 Jul 2012 05:16 AM (UTC)
Message
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!!! :-)
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.


15,563 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.