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 ➜ 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  (23,133 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.


17,474 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.