3 ms·
As eval() was removed from Lua, you must reimplement it: ``` function eval(s) load(s)() end ```
by veqq 2y ago
As eval() was removed from Lua, you must reimplement it:
```
function eval(s)
load(s)()
end
```
- aeonik 2y agoFor those who don't know Lua very well (like me), here is a link to the reference manual. https://www.lua.org/manual/5.4/manual.html#pdf-load https://www.lua.org/manual/5.4/manual.html#pdf-load A simple example that I tested: local chunk = "return 2 + 2" local func = load(chunk) print(func()) -- Output: 4
- CapsAdmin 2y agoloadstring lwas replaced with load, and dostring was removed, but it's basically just assert(loadstring(code))(...) load is the replacement. i assume the grandparent meant dostring and not eval?