Gammon Forum
Entire forum
MUSHclient
Lua
Functions inside a lua table
Functions inside a lua table
|
It is now over 60 days since the last post. This thread is closed.
  Refresh page
Posted by
| Ksajal
(17 posts) bio
|
Date
| Thu 01 Apr 2010 11:33 PM (UTC) Amended on Fri 02 Apr 2010 12:04 AM (UTC) by Ksajal
|
Message
| It's been driving me insane, I'm using the same way of declaring tables in other modules, but I've never got such an error.
Here it is:
if
not scan
then
scan = {}
end --if
function scan.salve ()
if
GetVariable ("salve") == "1" and
able.to ("apply") and
not flags.get ("applying_salve")
then
--stuff, I don't think it's really relevant
end --if
end --function
return scan
Here is where I get the error, at my prompt script (it's executed at the prompt):
package.loaded.scan = nil
require "scan"
function prompt (sName, sLine, wildcards)
--other stuff
scan.salve ()
end --function
The error I get is:
Function/Sub: prompt called by trigger
Reason: processing trigger "Prompt"
[string "Script file"]:5618: attempt to call field 'salve' (a nil value)
I think that somehow the function scan.salve () is not created, next (scan) returns nil
What am I doing wrong? | top |
|
Posted by
| David Haley
USA (3,881 posts) bio
|
Date
| Reply #1 on Thu 01 Apr 2010 11:36 PM (UTC) |
Message
| Well... where/how is your code calling 'elixir'? The word 'elixir' doesn't appear in any of the code you showed, just the error message. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | top |
|
Posted by
| Ksajal
(17 posts) bio
|
Date
| Reply #2 on Thu 01 Apr 2010 11:38 PM (UTC) |
Message
|
David Haley said:
Well... where/how is your code calling 'elixir'? The word 'elixir' doesn't appear in any of the code you showed, just the error message.
Darn, it's the same thing, I have two functions inside scan, one is elixir, the other is scan, they both return the same error message.
I'll edit my previous post | top |
|
Posted by
| Nick Gammon
Australia (22,973 posts) bio
Forum Administrator |
Date
| Reply #3 on Fri 02 Apr 2010 12:11 AM (UTC) |
Message
| It worked for me when I tried it so you must be doing something else, such as assigning something to scan, forgetting that it is a module. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
Posted by
| Ksajal
(17 posts) bio
|
Date
| Reply #4 on Fri 02 Apr 2010 08:22 AM (UTC) |
Message
|
Nick Gammon said:
It worked for me when I tried it so you must be doing something else, such as assigning something to scan, forgetting that it is a module.
You were right, I was resetting the scan table later in my script, and it didn't cross my mind to check.
Thank you! | 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.
15,423 views.
It is now over 60 days since the last post. This thread is closed.
  Refresh page
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.