Skip to content

Commit 9a9826a

Browse files
committed
Version 0.6.1
* Fix about menu for GTA V build * Minor changes to build script * Fix indent in some places
1 parent 2847c0d commit 9a9826a

File tree

7 files changed

+79
-51
lines changed

7 files changed

+79
-51
lines changed

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
# Lua scripting mod for RDR2/GTAV [![Build Status](https://github.com/igor725/RedLua/actions/workflows/release.yml/badge.svg)](https://github.com/igor725/RedLua/actions/workflows/release.yml)
1+
<p align='center'>
2+
<a href='https://github.com/igor725/RedLua/actions/workflows/release.yml'>
3+
<img src='https://github.com/igor725/RedLua/actions/workflows/release.yml/badge.svg' />
4+
</a>
5+
<a href='https://github.com/igor725/RedLua/releases'>
6+
<img src='https://img.shields.io/github/downloads/igor725/RedLua/total.svg' />
7+
</a>
8+
<a href='https://github.com/igor725/RedLua/pulse'>
9+
<img src='https://img.shields.io/github/commit-activity/m/igor725/RedLua' />
10+
</a>
11+
</p>
12+
13+
# Lua scripting mod for RDR2/GTAV
214

315
RedLua is a AB's ScriptHook library that simplifies the game modding process.
416

@@ -7,7 +19,7 @@ RedLua is a AB's ScriptHook library that simplifies the game modding process.
719
Download the latest [release](https://github.com/igor725/RedLua/releases) and extract the archive contents into your game folder (must be writeable). **Note that the RedLua won't work without the ScriptHook[RDR2](https://www.dev-c.com/rdr2/scripthookrdr2/)/[V](http://www.dev-c.com/gtav/scripthookv/) library!**
820

921
## Usage
10-
In **RDR2** press **F7**, in **GTAV** default bind is **F4** (you can change the default hotkey in `<Your game directory>\RedLua\Settings.json` file, keycodes available [here](https://cherrytree.at/misc/vk.htm)) to open the RedLua menu. Here you can load/reload/stop/unload scripts, reload the NativeDB and change library settings.
22+
In **RDR2** press **F7**, in **GTAV** default bind is **F4** (you can change the default hotkey in `<Your game directory>\RedLua\Settings.json` file, keycodes available [here](https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes)) to open the RedLua menu. Here you can load/reload/stop/unload scripts, reload the NativeDB and change library settings.
1123

1224
RedLua uses the [**Easylogging++**](https://github.com/amrayn/easyloggingpp#configuration) library, so if you want to configure the logger, just navigate to `<Your game directory>\RedLua\` and create a file called `Log.conf` with following contents:
1325
```conf
@@ -35,7 +47,7 @@ RedLua uses the [**Easylogging++**](https://github.com/amrayn/easyloggingpp#conf
3547

3648
## Scripting
3749

38-
RedLua searches for scripts in the `<Your game directory>\RedLua\Scripts\`. Each script located in this folder will be loaded automatically (If the `Autorun feature` is enabled). Every script should return a `table` (can be empty) with functions `OnLoad`, `OnTick`, `OnStop`, `OnReload`. Almost every function of the RDR2's RAGE is described [here](https://alloc8or.re/rdr3/nativedb/) and [here](https://www.rdr2mods.com/nativedb/index/builtin/).
50+
RedLua searches for scripts in the `<Your game directory>\RedLua\Scripts\`. Each script located in this folder will be loaded automatically (If the `Autorun feature` is enabled). Every script should return a `table` (can be empty) with functions `OnLoad`, `OnTick`, `OnStop`, `OnReload`. Almost every function of the RDR2's RAGE is described [here](https://alloc8or.re/rdr3/nativedb/).
3951

4052
Example:
4153
```lua

build.bat

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
@echo off
22
IF NOT "%VSCMD_ARG_TGT_ARCH%"=="x64" (
3-
ECHO Unsupported architecture
3+
ECHO This script must be executed with Miscrosoft Visual Studio C++ ^(x64^) environment loaded
44
EXIT /B 1
55
)
6-
setlocal enableextensions enabledelayedexpansion
6+
7+
SETLOCAL ENABLEDELAYEDEXPANSION
78
SET RL_GTAV=0
89
SET RL_STANDALONE=0
910

@@ -16,25 +17,25 @@ GOTO argparse
1617

1718
:argdone
1819
SET RL_LUAJIT_SOURCE_DIR=.\src\thirdparty\LuaJIT\src
19-
IF NOT EXIST "%RL_LUAJIT_SOURCE_DIR%\lua51.lib" (
20-
PUSHD %RL_LUAJIT_SOURCE_DIR%
20+
IF NOT EXIST "!RL_LUAJIT_SOURCE_DIR!\lua51.lib" (
21+
PUSHD !RL_LUAJIT_SOURCE_DIR!
2122
CALL .\msvcbuild.bat
22-
IF NOT "!ERRORLEVEL!"=="0" (
23+
IF !ERRORLEVEL! NEQ 0 (
2324
ECHO Failed to compile LuaJIT
24-
EXIT /b 1
25+
EXIT /B 1
2526
)
2627
POPD
2728
)
2829

2930
SET RL_OUT_BIN=RedLua.asi
3031
SET RL_LIBS=user32.lib shell32.lib Wininet.lib lua51.lib
3132
SET RL_SOURCES=src\*.cpp src\thirdparty\*.cpp src\menus\*.cpp
32-
SET RL_LDFLAGS=/DLL /INCREMENTAL /LIBPATH:"%RL_LUAJIT_SOURCE_DIR%"
33+
SET RL_LDFLAGS=/DLL /INCREMENTAL /LIBPATH:"!RL_LUAJIT_SOURCE_DIR!"
3334
SET RL_CFLAGS=/DELPP_NO_DEFAULT_LOG_FILE /DELPP_DISABLE_LOG_FILE_FROM_ARG ^
3435
/DELPP_THREAD_SAFE /DWIN32_LEAN_AND_MEAN /D_CRT_SECURE_NO_WARNINGS /FC /W2 ^
3536
/Isrc\ /EHsc /MP /DLL
3637

37-
IF "%RL_GTAV%"=="1" (
38+
IF !RL_GTAV! EQU 1 (
3839
SET RL_OUT_PATH="D:\Games\Grand Theft Auto V"
3940
SET RL_SCRIPTHOOK_VARIANT=V
4041
SET RL_CFLAGS=!RL_CFLAGS! /DREDLUA_GTAV
@@ -45,7 +46,7 @@ IF "%RL_GTAV%"=="1" (
4546

4647
SET RL_SCRIPTHOOK_SDK_DIR=.\src\thirdparty\ScriptHook!RL_SCRIPTHOOK_VARIANT!
4748

48-
IF "%RL_STANDALONE%"=="1" (
49+
IF !RL_STANDALONE! EQU 1 (
4950
SET RL_OUT_PATH=".\objs\output!RL_SCRIPTHOOK_VARIANT!"
5051
SET RL_CFLAGS=!RL_CFLAGS! /DREDLUA_STANDALONE /Zi /MTd
5152
SET RL_CFLAGS=!RL_CFLAGS! /Fd!RL_OUT_PATH!\ /DEBUG
@@ -63,12 +64,12 @@ IF NOT EXIST !RL_OUT_PATH! (
6364
SET RL_OUT_PATH=".\objs\output!RL_SCRIPTHOOK_VARIANT!"
6465
MKDIR !RL_OUT_PATH! 2> NUL
6566
)
66-
IF NOT "%RL_STANDALONE%"=="1" IF NOT EXIST "!RL_OUT_PATH!\lua51.dll" (
67-
COPY %RL_LUAJIT_SOURCE_DIR%\lua51.dll %RL_OUT_PATH% 2> NUL
67+
IF !RL_STANDALONE! NEQ 1 IF NOT EXIST "!RL_OUT_PATH!\lua51.dll" (
68+
COPY !RL_LUAJIT_SOURCE_DIR!\lua51.dll !RL_OUT_PATH! 2> NUL
6869
)
6970
CL !RL_CFLAGS! /Fe!RL_OUT_PATH!\!RL_OUT_BIN! !RL_SOURCES! /link !RL_LDFLAGS! !RL_LIBS!
70-
IF NOT "%ERRORLEVEL%"=="0" (
71+
IF !ERRORLEVEL! NEQ 0 (
7172
endlocal
72-
EXIT /b 1
73+
EXIT /B 1
7374
)
7475
endlocal

src/constants.hpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
#pragma once
22

33
#define REDLUA_NAME "RedLua"
4-
#define REDLUA_VERSION "v0.6.0"
5-
#define REDLUA_VERSION_NUM 060
4+
#define REDLUA_VERSION_MAJOR 0
5+
#define REDLUA_VERSION_MINOR 6
6+
#define REDLUA_VERSION_PATCH 1
7+
8+
#define _VERTOSTR(MA, MI, PA) "v" #MA "." #MI "." #PA
9+
#define REDLUA_VERSION _VERTOSTR(REDLUA_VERSION_MAJOR, \
10+
REDLUA_VERSION_MINOR, REDLUA_VERSION_PATCH)
11+
#define REDLUA_VERSION_NUM (REDLUA_VERSION_MAJOR * 100) + \
12+
(REDLUA_VERSION_MINOR * 10) + REDLUA_VERSION_PATCH
613
#define REDLUA_FULLNAME REDLUA_NAME " " REDLUA_VERSION
714

815
#ifdef REDLUA_GTAV

src/luanative.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,28 +64,29 @@ static int native_new(lua_State *L) {
6464
}
6565

6666
#ifdef REDLUA_GTAV
67-
#define VTN(idx) (float)lua_tonumber(L, idx), 0
67+
# define VTN(idx) (float)lua_tonumber(L, idx), 0
6868
#else
69-
#define VTN(idx) (float)lua_tonumber(L, idx)
69+
# define VTN(idx) (float)lua_tonumber(L, idx)
7070
#endif
71+
7172
static int native_vector(lua_State *L) {
7273
Vector3 pos = {VTN(1), VTN(2), VTN(3)};
7374
push_uncached_fullcopy(L, NTYPE_VECTOR3, (NativeData *)&pos);
7475
return 1;
7576
}
7677

7778
#ifndef REDLUA_STANDALONE
78-
#define WORLDGETALL(T, TN) { \
79-
auto no = (NativeObject *)luaL_checkudata(L, 1, LUANATIVE_OBJECT); \
80-
luaL_argcheck(L, no->hdr.type != T, 1, "not a" #TN " pool"); \
81-
lua_pushinteger(L, worldGetAll##TN((int *)NATIVEOBJECT_GETPTR(no), no->hdr.count)); \
82-
return 1; \
83-
}
79+
# define WORLDGETALL(T, TN) { \
80+
auto no = (NativeObject *)luaL_checkudata(L, 1, LUANATIVE_OBJECT); \
81+
luaL_argcheck(L, no->hdr.type != T, 1, "not a" #TN " pool"); \
82+
lua_pushinteger(L, worldGetAll##TN((int *)NATIVEOBJECT_GETPTR(no), no->hdr.count)); \
83+
return 1; \
84+
}
8485
#else
85-
#define WORLDGETALL(T, TN) {lua_pushinteger(L, 0); return 1;}
86-
#define getGlobalPtr rl_ptrnullsub
87-
#define getScriptHandleBaseAddress rl_ptrnullsub
88-
static PUINT64 rl_ptrnullsub(int) {return NULL;}
86+
# define WORLDGETALL(T, TN) {lua_pushinteger(L, 0); return 1;}
87+
# define getGlobalPtr rl_ptrnullsub
88+
# define getScriptHandleBaseAddress rl_ptrnullsub
89+
static PUINT64 rl_ptrnullsub(int) {return NULL;}
8990
#endif
9091

9192
static int native_allobjs(lua_State *L) WORLDGETALL(NTYPE_OBJECT, Objects)

src/menus/about.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@ MenuBase *CreateAbout(MenuController *controller) {
99

1010
menu->AddItem(new MenuItemLink("RedLua: igor725", "https://github.com/igor725/RedLua"));
1111
menu->AddItem(new MenuItemLink("LuaJIT: Mike Pall", "https://github.com/LuaJIT/LuaJIT"));
12-
menu->AddItem(new MenuItemLink("UI/ScriptHook: Alexander Blade", "https://www.dev-c.com/rdr2/scripthookrdr2/"));
13-
menu->AddItem(new MenuItemLink("NativeDB: alloc8or", "https://github.com/alloc8or/rdr3-nativedb-data"));
12+
# ifdef REDLUA_GTAV
13+
menu->AddItem(new MenuItemLink("UI/ScriptHook: Alexander Blade", "http://www.dev-c.com/gtav/scripthookv/"));
14+
menu->AddItem(new MenuItemLink("NativeDB: alloc8or", "https://github.com/alloc8or/gta5-nativedb-data"));
15+
# else
16+
menu->AddItem(new MenuItemLink("UI/ScriptHook: Alexander Blade", "https://www.dev-c.com/rdr2/scripthookrdr2/"));
17+
menu->AddItem(new MenuItemLink("NativeDB: alloc8or", "https://github.com/alloc8or/rdr3-nativedb-data"));
18+
# endif
1419
menu->AddItem(new MenuItemLink("JSON parser: Niels Lohmann", "https://github.com/nlohmann/json"));
15-
menu->AddItem(new MenuItemLink("Logging: abumusamq", "https://github.com/amrayn/easyloggingpp"));
20+
menu->AddItem(new MenuItemLink("EasyLogging++: abumusamq", "https://github.com/amrayn/easyloggingpp"));
1621

1722
return menu;
1823
}

src/scripthook.hpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
#pragma once
22

33
#ifdef REDLUA_GTAV
4-
#include "thirdparty\ScriptHookV\inc\main.h"
5-
#ifdef REDLUA_STANDALONE
6-
# include "emu\native.hpp"
7-
#endif
8-
#include "thirdparty\ScriptHookV\inc\nativeCaller.h"
9-
#include "thirdparty\ScriptHookV\inc\types.h"
4+
# include "thirdparty\ScriptHookV\inc\main.h"
5+
# ifdef REDLUA_STANDALONE
6+
# include "emu\native.hpp"
7+
# endif
8+
9+
# include "thirdparty\ScriptHookV\inc\nativeCaller.h"
10+
# include "thirdparty\ScriptHookV\inc\types.h"
1011
#else
11-
#include "thirdparty\ScriptHookRDR2\inc\main.h"
12-
#ifdef REDLUA_STANDALONE
13-
# include "emu\native.hpp"
14-
#endif
15-
#include "thirdparty\ScriptHookRDR2\inc\nativeCaller.h"
16-
#include "thirdparty\ScriptHookRDR2\inc\types.h"
12+
# include "thirdparty\ScriptHookRDR2\inc\main.h"
13+
# ifdef REDLUA_STANDALONE
14+
# include "emu\native.hpp"
15+
# endif
16+
17+
# include "thirdparty\ScriptHookRDR2\inc\nativeCaller.h"
18+
# include "thirdparty\ScriptHookRDR2\inc\types.h"
1719
#endif

src/thirdparty/scriptmenu.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,12 @@ class MenuInput
231231
}
232232
static void MenuInputBeep()
233233
{
234-
#ifdef REDLUA_GTAV
235-
NATIVES::PLAY_SOUND_FRONTEND("NAV_UP_DOWN", "HUD_FRONTEND_DEFAULT_SOUNDSET", 0);
236-
#else
237-
NATIVES::STOP_SOUND_FRONTEND("NAV_RIGHT", "HUD_SHOP_SOUNDSET");
238-
NATIVES::PLAY_SOUND_FRONTEND("NAV_RIGHT", "HUD_SHOP_SOUNDSET", 1, 0);
239-
#endif
234+
# ifdef REDLUA_GTAV
235+
NATIVES::PLAY_SOUND_FRONTEND("NAV_UP_DOWN", "HUD_FRONTEND_DEFAULT_SOUNDSET", 0);
236+
#else
237+
NATIVES::STOP_SOUND_FRONTEND("NAV_RIGHT", "HUD_SHOP_SOUNDSET");
238+
NATIVES::PLAY_SOUND_FRONTEND("NAV_RIGHT", "HUD_SHOP_SOUNDSET", 1, 0);
239+
# endif
240240
}
241241
};
242242

0 commit comments

Comments
 (0)