diff --git a/3rd/lua/Lib/lua-5.4.3.lib b/3rd/lua/Lib/lua-5.4.3.lib deleted file mode 100644 index e56acda..0000000 Binary files a/3rd/lua/Lib/lua-5.4.3.lib and /dev/null differ diff --git a/3rd/lua/Lib/lua.lib b/3rd/lua/Lib/lua.lib new file mode 100644 index 0000000..e3ed82c Binary files /dev/null and b/3rd/lua/Lib/lua.lib differ diff --git a/README.md b/README.md index 4d48933..3421686 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,27 @@ -# War3 Lua - 1.1.0 +# War3 Lua - 1.1.1 [![build](https://github.com/Ev3nt/war3_lua/actions/workflows/build.yml/badge.svg)](https://github.com/Ev3nt/war3_lua/actions/workflows/build.yml) War3 Lua is a modification that allows you to run lua scripts at the JASS level. Lua does not replace the original scripting system in the game, but only expands its capabilities. - +Some natives doesn't work (thx jass for beautiful VM). ![](https://github.com/Ev3nt/war3_lua/blob/master/war3_lua.png) - - --- ### Installation requirements * Warcraft III - TFT 1.26 * [Visual C++ Redistributable for Visual Studio 2015](https://www.microsoft.com/en-US/download/details.aspx?id=48145) -* [Microsoft .NET Framework 4 (Standalone Installer)](https://www.microsoft.com/en-US/download/details.aspx?id=17718) + +--- +### Instruction +* Move the folder Scripts, Maps and war3_lua.mix to the game folder +* Run the game +* Open the map with war3map.lua file inside --- ### Recommended build parameters * Configuration **Release** * Windows platform **x86** -* Platform **8.1** +* Platform **10.0.19041.0** * Build tools **Visual Studio 2015 (v140)** diff --git a/Src/LuaMachine.h b/Src/LuaMachine.h index 15d7c5f..ba61d30 100644 --- a/Src/LuaMachine.h +++ b/Src/LuaMachine.h @@ -3,7 +3,7 @@ #include #include -#pragma comment(lib, "lua-5.4.3.lib") +#pragma comment(lib, "lua.lib") typedef int LUA; diff --git a/Src/LuaRegister.cpp b/Src/LuaRegister.cpp index 47f99af..f6aa8dd 100644 --- a/Src/LuaRegister.cpp +++ b/Src/LuaRegister.cpp @@ -1,8 +1,11 @@ #include "LuaRegister.h" +#include "Variables.h" #include "Warcraft.h" #include "JassNatives.h" +#define lua_registerJassNative(L, n, f) (lua_pushstring(L, (n)), lua_pushcclosure(L, (f), 1), lua_setglobal(L, (n))) + LUA lua_jCall(lua_State* l) { LPCSTR name = lua_tostring(l, lua_upvalueindex(1)); @@ -10,8 +13,6 @@ LUA lua_jCall(lua_State* l) if (!native.is_valid()) { - printf("[LUA] Warning: Jass function with name %s doesn't exist.\n", name); - return 0; } @@ -96,31 +97,11 @@ LUA lua_jCall(lua_State* l) return native.get_rettype() != TYPE_NOTHING ? 1 : 0; } -LUA lua_get(lua_State* l) -{ - lua_pushstring(l, lua_tostring(l, 2)); - lua_pushcclosure(l, lua_jCall, 1); - - return 1; -} - -LUA lua_opennatives(lua_State* l) -{ - lua_newtable(l); - lua_newtable(l); - - lua_pushstring(l, "__index"); - lua_pushcclosure(l, lua_get, 0); - lua_rawset(l, -3); - - lua_setmetatable(l, -2); - - return 1; -} - //------------------------------------------------------------- void lua_open_jassnatives(lua_State* l) { - lua_preload(l, "jass.natives", lua_opennatives); + for (const auto& native : jassnatives) { + lua_registerJassNative(l, native.first, lua_jCall); + } } \ No newline at end of file diff --git a/Src/Variables.h b/Src/Variables.h index 2bbb99f..b620db9 100644 --- a/Src/Variables.h +++ b/Src/Variables.h @@ -8,7 +8,7 @@ #define WAR3_LUA_MAJOR "1" #define WAR3_LUA_MINOR "1" -#define WAR3_LUA_RELEASE "0" +#define WAR3_LUA_RELEASE "1" #define WAR3_LUA_VERSION WAR3_LUA_MAJOR "." WAR3_LUA_MINOR "." WAR3_LUA_RELEASE #define WAR3_LUA "War3 Lua " WAR3_LUA_VERSION diff --git a/war3_lua.sln b/war3_lua.sln index 2523dc2..791f2ba 100644 --- a/war3_lua.sln +++ b/war3_lua.sln @@ -1,24 +1,18 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31205.134 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31912.275 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "war3_lua", "war3_lua.vcxproj", "{9E1903DF-815D-4B82-A6DA-E0D40674769A}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 - Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {9E1903DF-815D-4B82-A6DA-E0D40674769A}.Debug|x64.ActiveCfg = Debug|x64 - {9E1903DF-815D-4B82-A6DA-E0D40674769A}.Debug|x64.Build.0 = Debug|x64 {9E1903DF-815D-4B82-A6DA-E0D40674769A}.Debug|x86.ActiveCfg = Debug|Win32 {9E1903DF-815D-4B82-A6DA-E0D40674769A}.Debug|x86.Build.0 = Debug|Win32 - {9E1903DF-815D-4B82-A6DA-E0D40674769A}.Release|x64.ActiveCfg = Release|x64 - {9E1903DF-815D-4B82-A6DA-E0D40674769A}.Release|x64.Build.0 = Release|x64 {9E1903DF-815D-4B82-A6DA-E0D40674769A}.Release|x86.ActiveCfg = Release|Win32 {9E1903DF-815D-4B82-A6DA-E0D40674769A}.Release|x86.Build.0 = Release|Win32 EndGlobalSection diff --git a/war3_lua.vcxproj b/war3_lua.vcxproj index 2f9abad..53ab78e 100644 --- a/war3_lua.vcxproj +++ b/war3_lua.vcxproj @@ -23,7 +23,7 @@ Win32Proj {9e1903df-815d-4b82-a6da-e0d40674769a} war3lua - 8.1 + 10.0.19041.0 @@ -40,17 +40,17 @@ MultiByte - Application + DynamicLibrary true - v142 - Unicode + v140 + MultiByte - Application + DynamicLibrary false - v142 + v140 true - Unicode + MultiByte @@ -72,21 +72,27 @@ true - $(SolutionDir)Build\bin\$(Configuration)\$(Platform)\ - $(SolutionDir)Build\obj\$(Configuration)\$(Platform)\ + $(SolutionDir)Build\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)Build\obj\$(Platform)\$(Configuration)\ .mix false - $(SolutionDir)Build\bin\$(Configuration)\$(Platform)\ - $(SolutionDir)Build\obj\$(Configuration)\$(Platform)\ + $(SolutionDir)Build\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)Build\obj\$(Platform)\$(Configuration)\ .mix true + $(SolutionDir)Build\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)Build\obj\$(Platform)\$(Configuration)\ + .mix false + $(SolutionDir)Build\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)Build\obj\$(Platform)\$(Configuration)\ + .mix @@ -94,12 +100,12 @@ true WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - $(SolutiondDir)3rd\StormLib\Include;$(SolutiondDir)3rd\lua\Include;%(AdditionalIncludeDirectories) + $(SolutionDir)3rd\StormLib\include;$(SolutionDir)3rd\lua\include Console true - $(SolutiondDir)3rd\StormLib\Build\bin\Release\Win32;$(SolutiondDir)3rd\lua\Lib;%(AdditionalLibraryDirectories) + $(SolutionDir)3rd\StormLib\Build\bin\Release\Win32;$(SolutionDir)3rd\lua\lib;%(AdditionalLibraryDirectories) @@ -110,14 +116,14 @@ true WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true - $(SolutiondDir)3rd\StormLib\Include;$(SolutiondDir)3rd\lua\Include;%(AdditionalIncludeDirectories) + $(SolutionDir)3rd\StormLib\include;$(SolutionDir)3rd\lua\include Console true true true - $(SolutiondDir)3rd\StormLib\Build\bin\Release\Win32;$(SolutiondDir)3rd\lua\Lib;%(AdditionalLibraryDirectories) + $(SolutionDir)3rd\StormLib\Build\bin\Release\Win32;$(SolutionDir)3rd\lua\lib;%(AdditionalLibraryDirectories) @@ -126,10 +132,12 @@ true _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true + $(SolutionDir)3rd\StormLib\include;$(SolutionDir)3rd\lua\include Console true + $(SolutionDir)3rd\StormLib\Build\bin\Release\Win32;$(SolutionDir)3rd\lua\lib;%(AdditionalLibraryDirectories) @@ -140,12 +148,14 @@ true NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true + $(SolutionDir)3rd\StormLib\include;$(SolutionDir)3rd\lua\include Console true true true + $(SolutionDir)3rd\StormLib\Build\bin\Release\Win32;$(SolutionDir)3rd\lua\lib;%(AdditionalLibraryDirectories)