I'm brand new to Lua, and have written a simple function to load information from a file. It works when I run it from Crimson Editor but seems to fail if I try using the script file in MUSHclient.
The lines in question are:
[snip]
function loaddirs (file)
dirs = {}
io.input (file)
[/snip]
It fails on the io.input line with:
[string "Script file"]:3: attempt to index global `io' (a nil value)
stack traceback:
[string "Script file"]:3: in function `loaddirs'
[string "Script file"]:21: in main chunk
Can anyone help me as to why io isn't recognizable within my function in mushclient?
File IO is disabled via the "Sandbox" in MUSHclient, look in the Global Options Dialog, from file menu, and it gives instructions on disabling it, or if it is a plugin, you can add it to the trusted list, or just that particular world file. There are many options to allow that to not be set to nil.
Hope that helps :)
Laterzzz,
Onoitsu2
ah hah! That makes perfect sense now.. thank you!
This seems to trap someone about once a week. How would this be? If instead of simply setting things like io to nil, the sandbox replaced them with a function to warn about the sandbox? Something like this:
/f = io.open ("foo", "r")
-->
Run-time error
World: SMAUG
Immediate execution
[string "Command line"]:1: Function 'io.open' disabled in Lua sandbox - see MUSHclient global preferences
This makes it clearer that the function is intentionally disabled, and how to go about fixing it.
I think this would be an excellent change Nick! It stumped me until I found the Lua sandboxing section, then it all made sense.. giving someone a nudge in that direction may help for all those users who think they know everything and don't need to look at docs - like me! :)
p.s. It's long overdue, but I've just registered my copy of mushclient! After playing around and seeing how powerful Lua will allow my scripting to be, it seems like I've got a new (old?) project in automating my favorite mud :) Thanks again for such great software!