Forum
CS2D Scripts Compile a Lua into DLLCompile a Lua into DLL
7 Antworten 1
Click here!
Hope it helps you!
1× editiert, zuletzt 31.01.15 23:43:56
You have to rewrite your lua code into c or cpp or any other language that compilers allow dll compilation.
Then you have to make a lua file that includes / binds your dll to cs2d and executes a specific "main function" inside your dll.
const char* mycode={...};
2. Now the .c file
1
2
3
4
5
6
7
2
3
4
5
6
7
#include"header.h"	// created header at above #include<lua.h> #include<lauxlib.h> int __declspec(dllexport) luaopen_example(lua_State* L) { 	luaL_dostring(L,mycode); }
3. In your script, load it like this
require("example")
or
assert(package.loadlib("exampledll.dll","luaopen_example"))()
Note: Method 2 is prefered if you don't want to change the package.cpath variable
Note2: CS2D Uses lua 5.1.4, so pick correct source code.
1