Reputation: 789
Using luac5.1.exe is there anyway to pass it a string to create a binary file or does anyone know of any module that could create a syntax checked binary file, what I'm looking to do is create a settings file that can be loaded again by require.
Upvotes: 0
Views: 967
Reputation: 72312
Perhaps try this:
function compile(source,file)
io.open(file,"wb")
:write(string.dump(assert(loadstring(source,""))))
:close()
end
Upvotes: 1
Reputation: 41180
Note that require
loads lua source files or dynamic libraries. Yu might be better off with a custom loader if you really need binary data.
Two libraries that do this are Roberto's struct and lhf's lpack.
If you really want require
then you could convert your binary data to strings, but since presumably that are userdata
, you'll need a C function to translate the userdata
to a Lua accessible type such as string
or number
.
Upvotes: 2