for example,
require "wait"
require "check"
the function 'time' in the wait.lua is called whith 'wait.time()' in lua script.
but
the function 'check' in the check.lua is called with
'check()' in lua script.
why do the two functions be called in different way?
I am new to lua and mc,
Help would be appreciated. Thanks!
wait is a module. It has subcomponents to it that are stored in a table. There's wait.make, wait.time, etc. Look up "module" in the Programming in Lua book (http://www.lua.org/PiL)
check is just a snippet of code that defines a function. The function gets returned to the Global namespace (_G). You don't need to use require to get it to work. dofile() would work just as well.
To be fair, there's also no reason you couldn't dofile() a module. require() is just a bulked-up dofile() with a search path, and caching of the return value from each file (generally a table) into package.loaded. module() just happens to set the package.loaded entry itself, so require() notices and says "Oh, nevermind."
(I might be slightly wrong on the mechanics in that last sentence, but I'm fairly certain the rest is right.)
I've got it,
and thank very much for you both!
BTW, the "check" function is now built into MUSHclient script space. You don't need to require it at all.