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 ➜ Newb Lua Question

Newb Lua Question

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


Posted by JoeScripter   (12 posts)  Bio
Date Sun 05 Nov 2006 07:06 AM (UTC)
Message
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?
Top

Posted by Onoitsu2   USA  (248 posts)  Bio
Date Reply #1 on Sun 05 Nov 2006 09:31 AM (UTC)
Message
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
Top

Posted by JoeScripter   (12 posts)  Bio
Date Reply #2 on Sun 05 Nov 2006 02:44 PM (UTC)
Message
ah hah! That makes perfect sense now.. thank you!
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #3 on Sun 05 Nov 2006 07:51 PM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by JoeScripter   (12 posts)  Bio
Date Reply #4 on Sun 05 Nov 2006 08:12 PM (UTC)
Message
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!
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.


16,224 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.