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
➜ testing for empty table
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Lethethar
(7 posts) Bio
|
Date
| Mon 28 Jul 2014 05:54 PM (UTC) |
Message
| 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 () | Top |
|
Posted by
| Fiendish
USA (2,535 posts) 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
|
Message
|
Quote: [string "Script file"]:6: bad argument #1 to 'next'
argument #1 to next is mobs
Quote: (table expected, got nil)
So next must be passed a table. You passed it mobs, which is apparently nil and not a table. |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #2 on Mon 28 Jul 2014 08:21 PM (UTC) |
Message
| 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 | Top |
|
Posted by
| Lethethar
(7 posts) Bio
|
Date
| Reply #3 on Tue 29 Jul 2014 01:23 AM (UTC) |
Message
| Thanks, Testing for nil then testing for empty table worked. | 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.
12,199 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top