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

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Help with a table script in lua 5.1+ mushclient

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: Help with a table script in lua 5.1+ mushclient
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please).
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Posted by Edwin_r   (6 posts)  [Biography] bio
Date Wed 25 Jul 2012 05:16 AM (UTC)  quote  ]
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!!! :-)
[Go to top] top

Posted by Edwin_r   (6 posts)  [Biography] bio
Date Wed 25 Jul 2012 03:50 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Nick Gammon   Australia  (18,772 posts)  [Biography] bio   Forum Administrator
Date Wed 25 Jul 2012 03:14 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Edwin_r   (6 posts)  [Biography] bio
Date Wed 25 Jul 2012 03:04 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Nick Gammon   Australia  (18,772 posts)  [Biography] bio   Forum Administrator
Date Wed 25 Jul 2012 02:58 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Edwin_r   (6 posts)  [Biography] bio
Date Mon 23 Jul 2012 05:25 PM (UTC)  quote  ]
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!!!
[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.


931 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

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

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]