Skip to content

Commit

Permalink
Fixed some bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ev3nt committed Nov 30, 2021
1 parent 14450ca commit 258ab17
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 56 deletions.
Binary file removed 3rd/lua/Lib/lua-5.4.3.lib
Binary file not shown.
Binary file added 3rd/lua/Lib/lua.lib
Binary file not shown.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)**
2 changes: 1 addition & 1 deletion Src/LuaMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <Windows.h>

#include <lua.hpp>
#pragma comment(lib, "lua-5.4.3.lib")
#pragma comment(lib, "lua.lib")

typedef int LUA;

Expand Down
31 changes: 6 additions & 25 deletions Src/LuaRegister.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#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));
JASSNATIVE native = get_native(name);

if (!native.is_valid())
{
printf("[LUA] Warning: Jass function with name %s doesn't exist.\n", name);

return 0;
}

Expand Down Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion Src/Variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 2 additions & 8 deletions war3_lua.sln
Original file line number Diff line number Diff line change
@@ -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
Expand Down
40 changes: 25 additions & 15 deletions war3_lua.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{9e1903df-815d-4b82-a6da-e0d40674769a}</ProjectGuid>
<RootNamespace>war3lua</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0.19041.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
Expand All @@ -40,17 +40,17 @@
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Expand All @@ -72,34 +72,40 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)Build\bin\$(Configuration)\$(Platform)\</OutDir>
<IntDir>$(SolutionDir)Build\obj\$(Configuration)\$(Platform)\</IntDir>
<OutDir>$(SolutionDir)Build\bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)Build\obj\$(Platform)\$(Configuration)\</IntDir>
<TargetExt>.mix</TargetExt>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)Build\bin\$(Configuration)\$(Platform)\</OutDir>
<IntDir>$(SolutionDir)Build\obj\$(Configuration)\$(Platform)\</IntDir>
<OutDir>$(SolutionDir)Build\bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)Build\obj\$(Platform)\$(Configuration)\</IntDir>
<TargetExt>.mix</TargetExt>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)Build\bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)Build\obj\$(Platform)\$(Configuration)\</IntDir>
<TargetExt>.mix</TargetExt>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)Build\bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)Build\obj\$(Platform)\$(Configuration)\</IntDir>
<TargetExt>.mix</TargetExt>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutiondDir)3rd\StormLib\Include;$(SolutiondDir)3rd\lua\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)3rd\StormLib\include;$(SolutionDir)3rd\lua\include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(SolutiondDir)3rd\StormLib\Build\bin\Release\Win32;$(SolutiondDir)3rd\lua\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(SolutionDir)3rd\StormLib\Build\bin\Release\Win32;$(SolutionDir)3rd\lua\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
Expand All @@ -110,14 +116,14 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutiondDir)3rd\StormLib\Include;$(SolutiondDir)3rd\lua\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)3rd\StormLib\include;$(SolutionDir)3rd\lua\include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(SolutiondDir)3rd\StormLib\Build\bin\Release\Win32;$(SolutiondDir)3rd\lua\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(SolutionDir)3rd\StormLib\Build\bin\Release\Win32;$(SolutionDir)3rd\lua\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
Expand All @@ -126,10 +132,12 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)3rd\StormLib\include;$(SolutionDir)3rd\lua\include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(SolutionDir)3rd\StormLib\Build\bin\Release\Win32;$(SolutionDir)3rd\lua\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
Expand All @@ -140,12 +148,14 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)3rd\StormLib\include;$(SolutionDir)3rd\lua\include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(SolutionDir)3rd\StormLib\Build\bin\Release\Win32;$(SolutionDir)3rd\lua\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
Expand Down

0 comments on commit 258ab17

Please sign in to comment.