0

I know how to do stuff with Lua states and what not but what i don't understand is how you would distribute the final program with a seperate lua file because say you have a .exe and a lua file in the same directory how would I make it so that it is all one executable like how Löve 2d uses

copy /b 

to append the lua file to the Löve 2d interpreter so it can be distributed. could someone possibly explain how this works.

many thanks Blazing

6
  • Are you asking how to combine the two files into one file? Or are you asking how to not do that and instead how to distribute two files and use the .lua file from the executable? Commented Apr 20, 2016 at 19:42
  • I'm asking how to combine them into one file similar to that of love2d so that when said application is distributed the user isn't tempted to poke around the .lua file and so that people implementing the c++ don't need to know it and can focus on just using lua Commented Apr 20, 2016 at 20:16
  • copy /b just merged the two files by stuffing one file on the end of the other file I think. So how to use that is a question of how to find the other file at the end of your file. I don't know if there's a specific way to do it but you could always just open yourself and read backwards from the end until you find your header/marker and then load it. Commented Apr 20, 2016 at 20:20
  • love2d.org/wiki/Game_Distribution like what is described under creating a Windows executable. Commented Apr 20, 2016 at 20:20
  • Yeah. Like I said I don't know how love is doing it specifically but at its simplest what I said should work I believe. Commented Apr 20, 2016 at 20:31

1 Answer 1

2

You could embed the lua code directly into your C++ source in a raw string literal like so:

const auto lua_code = R"lua(
...lua code here...
)lua";
Sign up to request clarification or add additional context in comments.

2 Comments

I understand that this is possible and i will use this if absolutely necessary but i would rather have the code in a seperate file so that it can be edited by people who aren't as proficient
@BlazingCode Then you should have a build system which converts your Lua file to C code and inserts it before compiling your executable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.