does any of you know how to create a memory mapped file in Lua? I have a program that writes code in Lua. I now want to execute the code without saving it to file, but writing it to a "memory" file and then executing it from memory directly. But I did not find a way to do this. I am now writing a file like this:
file:write(instruction..'\n')
then loading and running it as:
file = loadfile("filename")
file()
Does anyone know how to write the file to memory or to execute it from memory without saving it to disk?
Use loadstring:
chunk = loadstring("return ..., 1+2, 'hi'")
assert(chunk)
a, b, c = chunk(123) -- you can call many times
print (a,b,c) -- prints 123 3 hi
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With