[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]  Functions inside a lua table
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Functions inside a lua table

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


Posted by Ksajal   (17 posts)  [Biography] 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?
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] 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
[Go to top] top

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

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

Posted by Ksajal   (17 posts)  [Biography] 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!
[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.


3,949 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]