user1929868
user1929868

Reputation:

Include lua scripts into executable

Hi this question seems to be answered but answers don't resolve my problem. I try to include lua script into executable by copying it into exe

copy -b a.exe+test.lua output.exe

but when i launch output.exe luaL_dofile() cannot find lua script. I dont want to use any third party apps to achieve this.

Copying files seems to work because Love2D projects works and I copy files in the same way but i treats them as zip archive (for sake of file hierarchy).

Upvotes: 1

Views: 390

Answers (1)

lhf
lhf

Reputation: 72422

You can append a Lua script to your .exe but you'll need some way to load it into your program. The main problem is how to find the Lua script at the end of the .exe. srlua appends a small signature that contains the size of the Lua script so that the program can read the script at the right offset in the .exe file. Fortunately, the Lua API provides a function to load scripts from arbitrary sources. The convenience function luaL_dofile uses that function. You can use the same technique in your own program.

Upvotes: 1

Related Questions