caught in am endless loop

Posted by Dragonlord on Fri 25 Mar 2016 11:04 PM — 4 posts, 18,400 views.

#0
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.
USA Global Moderator #1
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?
Amended on Sat 26 Mar 2016 12:32 AM by Fiendish
Australia Forum Administrator #2
Cross-posted here:

http://www.gammon.com.au/forum/?id=13371&reply=2#reply2
Australia Forum Administrator #3
@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.