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 ➜ trying to set up a script and ran into an error

trying to set up a script and ran into an error

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


Posted by Dragonlord   (24 posts)  Bio
Date Fri 25 Mar 2016 06:04 PM (UTC)

Amended on Fri 25 Mar 2016 08:40 PM (UTC) by Nick Gammon

Message

<aliases>
  <alias
   match="players_equipment"
   enabled="y"
   regexp="y"
   send_to="12"
   ignore_case="y"
   sequence="100"
  >
  <send>PC_Equipment = "an eye of a Kraken|a ring of wizardry|the ring of the serpent|the Overlord's necklace of protection|a holy symbol of 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
  Send ("remove all\.", PC_Equipment)
  Send ("wear 'a pair of brass spectacles'")
  send ("wear ", PC_Equipment)
end -- for</send>
  </alias>
</aliases>



The error is those:


Run-time error
World: Materia Magica GMCP
Immediate execution
[string "Alias: "]:3: bad argument #1 to 'gmatch' (string expected, got nil)
stack traceback:
        [C]: in function 'gmatch'
        [string "Alias: "]:3: in main chunk
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Fri 25 Mar 2016 08:42 PM (UTC)
Message
You have a couple of typos:


PC_Equipment = "an eye of a Kraken ...


That should be:


PC_Equipments = "an eye of a Kraken ...



Also the final "send" should be "Send".

- Nick Gammon

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

Posted by Dragonlord   (24 posts)  Bio
Date Reply #2 on Fri 25 Mar 2016 10:23 PM (UTC)

Amended on Sat 26 Mar 2016 05:57 AM (UTC) by Nick Gammon

Message
thank you it helped. I added a wait.time script to it


<aliases>
  <alias
   match="players_equipment"
   regexp="y"
   send_to="12"
   ignore_case="y"
   sequence="100"
  >
  <send>PC_Equipments = "an eye of a Kraken|a ring of wizardry|the ring of the serpent|the Overlord's necklace of protection|a holy symbol of 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</send>
  </alias>
</aliases>


for some reason it got caught in a endless loop. any idea what i did to cause it
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #3 on Sat 26 Mar 2016 06:05 AM (UTC)
Message
Your splitting up of the string is a bit strange anyway. This seemed to work for me:


<aliases>
  <alias
   match="players_equipment"
   enabled="y"
   regexp="y"
   send_to="12"
   ignore_case="y"
   sequence="100"
  >
  <send>

PC_Equipments = "an eye of a Kraken|a ring of wizardry|the ring of the serpent|the Overlord's necklace of protection|a holy symbol of 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 ()

Send ("remove all")

for k, v in ipairs (utils.split (PC_Equipments, "|")) do
  Send ("wear ", v)
  wait.time (1)
end -- for

end) -- function

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


- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #4 on Sat 26 Mar 2016 06:10 AM (UTC)
Message
A simpler approach is to not use a lengthy string in the first place. Like this:


<aliases>
  <alias
   match="players_equipment"
   enabled="y"
   regexp="y"
   send_to="12"
   ignore_case="y"
   sequence="100"
  >
  <send>

PC_Equipments = 
  {
  "an eye of a Kraken",
  "a ring of wizardry",
  "the ring of the serpent",
  "the Overlord's necklace of protection",
  "a holy symbol of 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 ()

Send ("remove all")

for k, v in ipairs (PC_Equipments) do
  Send ("wear ", v)
  wait.time (1)
end -- for

end) -- function
</send>
  </alias>
</aliases>


- Nick Gammon

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

Posted by Dragonlord   (24 posts)  Bio
Date Reply #5 on Sat 26 Mar 2016 05:29 PM (UTC)
Message
Thank you that did it
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.


19,600 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.