-
Notifications
You must be signed in to change notification settings - Fork 338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add io.read and io.write capabilities. #1169
Comments
All I/O support has been removed to provide sandboxing capabilities. There are certain problems with the fact that several unsafe luau scripts will consume input from different threads at the same time, for example, or if the native application that embeds luau needs that input. Additionally, both io.read() and io.write() can cause the thread to block until the operation completes or new data is received, which is not always acceptable. If your task really requires terminal I/O and you understand all the implications, you can wrap the C getchar()/putchar() functions quite easily and add the wrapped functions to a global table. It won't take more than 10-20 lines of C/C++ code. |
I was hoping it would be easier to take input, as I would assume most people who use Roblox or luau haven't done much C/C++ or know how to wrap lua with it (this includes me.) And it would make sense pausing a thread until I/O actions are completed. Could you provide a resource for me to look through with regards to this though? |
Wait, are you using the luau CLI utility? I think it would make a little more sense to have these functions included with the CLI... But at the same time, this can lead to some confusion, because the embedded luau does not have such functions. Anyway, back to your situation. If you find it difficult to work with C/C++ code and the LUA C API, I would suggest using regular lua or luajit. |
And embedded luau doesn't need IO support, which I agree, but it generally is rather useful. Python is multipurpose and has IO, I wished it was faster though. Is there a public luajit.exe file? I'm getting errors trying to build from source and it would be way simpler using an exe. |
While we might add more Like it was mentioned, users building Luau from source can add any methods they need to the global environment. You can also look at this project that already extends default Luau environment with IO features and other things: https://github.com/lune-org/lune (note, this is not a project managed/supported by the Luau org) |
I know lua has io.read and io.write, but luau, being rebuilt from scratch it seems, doesn't. Roblox doesn't need io perhaps but it is much better looking at luau which is faster than base lua.
Currently, it's not possible to take user input through the terminal/console. And I would love if this was added.
The text was updated successfully, but these errors were encountered: