Comments (6)
While we might add more os
library methods/IO/dynamic modules in the future specifically for luau build as an executable, right now we don't have this on our roadmap.
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)
from luau.
Same problem here, different use case. I'm looking into using Luau in a music player addon. I want to allow users to quickly automate tasks without needing to write a custom C++ addon.
Writing files (and requiring native modules) are common tasks. I can write my own functions for this, but it would be nice to have a starting point. Even if Lua's existing libraries where simply modernized enough for Luau to function.
from luau.
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.
from luau.
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?
from luau.
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.)
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.
The lack of IO functions is not as critical as the lack of ability to dynamically load native code (compiled C/C++/any language) libraries to expand the capabilities of your scripts... And Luau does not support dynamic loading of theese libraries.
from luau.
Wait, are you using the luau CLI utility?
I'm using the luau.exe file from the luau-lang.org website. I'm finding it really hard (and annoying) to build luajit. As they say "only source code" is available and you have to build the luajit.exe yourself.
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.
from luau.
Related Issues (20)
- Setting a key to nil in a table errors in the new solver
- Can't define function in lua script after calling luaL_sandbox in host HOT 2
- `buffer` library doesn't accept `buffer`s in new type solver's non-strict mode HOT 3
- `any` as generic `T` incompatible with `{T}` in new type solver's strict mode
- Variable's type sometimes unions with `nil` due to `if` statement with new type solver's strict mode HOT 1
- For loop variable types not inferred from generic iterator with new type solver
- `and` `or` expression causes type pack error with new type solver's strict mode
- `table.freeze` returns type `{+ +}` with new solver's strict mode HOT 1
- failed assert in script file crashes repl HOT 1
- Stack overflow in parser HOT 3
- `buffer` library `TypeError` when buffer is function parameter with new solver's non-strict mode
- Cyclic union with upvalue not reducing `TypeError` with new solver's strict mode
- TypeError: Type pack '...any' could not be converted into 'a...' in new solver's strict mode
- Comment in lgc.h wrongly describes the GC invariant? HOT 1
- Test doesn't do what it says it does HOT 2
- TypeError when indexing table with union/intersection type of identical types
- Variables pack not inferred correctly for `__iter` metamethod
- Add type checking to `Luau.Web.js`
- Incorrect type widening with multiple arguments to generic `T` with new solver HOT 4
- String keys are not checked against table indexer
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from luau.