[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]  trying to set up a script and ran into an error
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

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] Refresh page


Posted by Dragonlord   (24 posts)  [Biography] 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
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] 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
[Go to top] top

Posted by Dragonlord   (24 posts)  [Biography] 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
[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: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
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] 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
[Go to top] top

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