Strict module and built-in functions

Posted by Tspivey on Fri 09 Apr 2010 08:57 PM — 3 posts, 18,148 views.

Canada #0
How can I get the strict module working with MC's built-in
functions, such as Note? Using this very simple
script file generates an error:


require "strict"
Note("test")


And the error generated is:

Error number: 0
Event:        Run-time error
Description:  [string "Script file"]:2: variable 'Note' is not declared

stack traceback:

	[C]: in function 'error'

	C:\Program Files\MUSHclient\lua\strict.lua:31: in function <C:\Program Files\MUSHclient\lua\strict.lua:29>

	[string "Script file"]:2: in main chunk
Called by:    Immediate execution

USA #1
Have you tried "world.Note" instead? I don't know if it would work, and it's not exactly ideal if it does, but maybe it'll help. I don't really use strict.lua, either.
Australia Forum Administrator #2
Twisol is right. world.Note works.

This is because Note is not actually in global script space, it is implemented via a metatable entry in the global script space. This keeps all the world functions from cluttering the global space, which really should be kept quite compact if possible.