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

Gammon Forum

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

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  caught in am endless loop
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

caught in am endless loop

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


Posted by Dragonlord   (24 posts)  [Biography] bio
Date Fri 25 Mar 2016 11:04 PM (UTC)
Message
PC_Equipments = "an eye of a Kraken|a ring of wizardry|the ring of the serpent|the Overlord\'s necklace of protection|holy symbol Ithrilis|a set of overlord armor|the leggings of an elder dragon|a pair of golden-spurred boots|the lieutenant\'s gauntlets|a pair of green dragonscale sleeves|a battered iron shield|Yourban\'s soul|a spectral aura|the belt of the master craftsman|a magical belt pouch|a bracelet set with white moonstones|a bracelet of the elements|an Eldmarian Slayer"

require "wait"
wait.make (function ()
for PC_Equipment in string.gmatch (PC_Equipments, "%a+") do
Send ("remove all.", PC_Equipment)
wait.time(1)
Send ("wear 'a pair of brass spectacles'")
wait.time(1)
Send ("wear ", PC_Equipment)

end -- forend -- for
end) -- function

For some reason after I added the wait function, I was caught in a endless loop, or it seemed endless. any idea on what i can do to fix it? The reason I need a wait function is because it will kick me out of the game and reconnect me.
[Go to top] top

Posted by Fiendish   USA  (1,641 posts)  [Biography] bio   Global Moderator
Date Reply #1 on Sat 26 Mar 2016 12:25 AM (UTC)

Amended on Sat 26 Mar 2016 12:32 AM (UTC) by Fiendish

Message
First, this:

PC_Equipments = "an eye of a Kraken|a ring of wizardry|the ring of the serpent|the Overlord\'s necklace of protection|holy symbol Ithrilis|a set of overlord armor|the leggings of an elder dragon|a pair of golden-spurred boots|the lieutenant\'s gauntlets|a pair of green dragonscale sleeves|a battered iron shield|Yourban\'s soul|a spectral aura|the belt of the master craftsman|a magical belt pouch|a bracelet set with white moonstones|a bracelet of the elements|an Eldmarian Slayer"
...
for PC_Equipment in string.gmatch (PC_Equipments, "%a+") do
is terrible Lua. It looks like maybe you're trying to mimic a data format from zMUD without knowing how it translates into Lua yet?

Also, in a string wrapped in "", \' is an invalid escape sequence and is guaranteed to either be ignored or to do the wrong thing. If you want to send a slash, you need to have \ instead of just \, and if you don't, you don't need it at all. In my version below, I've removed them. Up to you.

Do this instead:

PC_Equipments = {
  "an eye of a Kraken",
  "a ring of wizardry",
  "the ring of the serpent",
  "the Overlord's necklace of protection",
  "holy symbol Ithrilis",
  "a set of overlord armor",
  "the leggings of an elder dragon",
  "a pair of golden-spurred boots",
  "the lieutenant's gauntlets",
  "a pair of green dragonscale sleeves",
  "a battered iron shield",
  "Yourban's soul",
  "a spectral aura",
  "the belt of the master craftsman",
  "a magical belt pouch",
  "a bracelet set with white moonstones",
  "a bracelet of the elements",
  "an Eldmarian Slayer"
}

require "wait"
wait.make (function ()
  for index,item in ipairs(PC_Equipments) do
    Send ("remove all.", item)
    wait.time(1)
    Send ("wear 'a pair of brass spectacles'")
    wait.time(1)
    Send ("wear ", item)
  end -- for
end) -- function


Also you only use single quotes around the item for "wear 'a pair of brass spectacles'". Why not for the other stuff?

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Sat 26 Mar 2016 06:11 AM (UTC)
Message
Cross-posted here:

http://www.gammon.com.au/forum/?id=13371&reply=2#reply2

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Sat 26 Mar 2016 06:12 AM (UTC)
Message
@Dragonlord - please start using code tags for your triggers/aliases.

Template:codetag To make your code more readable please use [code] tags as described here.

- 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.


2,266 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 FutureQuest]