[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]  testing for empty table
Home  |  Users  |  Search  |  FAQ
Register forum user name
Forgotten password?

testing for empty table

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

Posted by Lethethar   (7 posts)  [Biography] bio
Date Mon 28 Jul 2014 05:54 PM (UTC)
Run-time error
World: test
Function/Sub: Prompt called by trigger
Reason: processing trigger "Prompt"
[string "Script file"]:6: bad argument #1 to 'next' (table expected, got nil)
stack traceback:
[C]: in function 'next'
[string "Script file"]:6: in function <[string "Script file"]:1>
Error context in script:

this error resulted when testing for empty table with this code

function Prompt (thename, theoutput, wildcards, line)
iHP = wildcards [1]
iMovement = wildcards [2]
iCoins = wildcards [3]
if next(mobs) == nil then
mobsRemaining ()
[Go to top] top

Posted by Fiendish   USA  (1,774 posts)  [Biography] bio   Global Moderator
Date Reply #1 on Mon 28 Jul 2014 06:46 PM (UTC)

Amended on Mon 28 Jul 2014 06:50 PM (UTC) by Fiendish

[string "Script file"]:6: bad argument #1 to 'next'


argument #1 to next is mobs
(table expected, got nil)

So next must be passed a table. You passed it mobs, which is apparently nil and not a table.

[Go to top] top

Posted by Nick Gammon   Australia  (21,651 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Mon 28 Jul 2014 08:21 PM (UTC)
Maybe test for nil first (ie. no table) and then next (mobs) to see if it is a table, but an empty one.

- Nick Gammon

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

Posted by Lethethar   (7 posts)  [Biography] bio
Date Reply #3 on Tue 29 Jul 2014 01:23 AM (UTC)
Thanks, Testing for nil then testing for empty table worked.
[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.


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.


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]