Hello. I want to make some sort of program. I'm relatively new to C++, but I'm more experienced with Lua. But, there isn't any way I know to be able to compile and run a .lua file like you would a .cpp file. In the .cpp file, would I somehow have to link C++ functions( like int main() ) to be used in Lua? If so, how would that be done? I know this is possible to do, as Source Engine games like Garry's Mod have done it, but I'm wondering how I could use Lua to program a file that I later convert into a .exe to run.... any help is appreciated!
Note: I don't want to use some sort of library someone's already made to do this, I want to do all the programming myself to allow Lua.
Use modules if you want to run C++/C code in Lua. (For example [url=https://github.com/leafo/lua-enet]lua-enet[/url] is a module.)
To create applications in Lua you might want to start with a framework like Love2D (which supports using modules).
I'm probably going to get bashed for this but Roblox is actually a good way to learn Lua.
edit: i didnt read the fucking thread rate this post with boxes asap
I've always used this when compiling Lua to a standalone application (and changed the Lua header tag).
[url]https://github.com/qtnc/lua2exe[/url]
There is a windows app called AutoPlay Media Studios, it was first created to make autoplay exe's but then turned in to much more, it uses LUA for all this scripting but gives you access to a windows objects you can make some really epic programs in it without people knowing its using lua.
To OP:
You're almost correct. Lua is actually supposed to be embedded in C applications, not the other way around. It's accomplished using the Lua C API, which you can read about here: [url]http://www.lua.org/pil/24.html[/url]
I have also made a YouTube tutorial if you don't like reading a bunch of jargon: [url]https://www.youtube.com/watch?v=ZysdYWuPwJU[/url]
Btw... if you [i]really[/i] don't want to use C, there's Terra ([url]https://github.com/zdevito/terra[/url]). But keep in mind this only came out like a year ago, while Lua has existed since the 90's and C since the 70's. C and Lua have quite a bit of track record on Terra. The creator of Terra might decide to abandon it tomorrow for all we know... something to keep in mind. It seems pretty cool though.
or use luajit and do everything you can do in C but in lua
Sorry, you need to Log In to post a reply to this thread.