Skip to content

Commit 735ced6

Browse files
committed
OnReload event added
1 parent ab7080c commit 735ced6

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ RedLua uses the [**Easylogging++**](https://github.com/amrayn/easyloggingpp#conf
3535

3636
## Scripting
3737

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`. 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/).
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/).
3939

4040
Example:
4141
```lua

src/constants.hpp

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

33
#define REDLUA_NAME "RedLua"
4-
#define REDLUA_VERSION "v0.2.0"
5-
#define REDLUA_VERSION_NUM 020
4+
#define REDLUA_VERSION "v0.2.1"
5+
#define REDLUA_VERSION_NUM 021
66
#define REDLUA_FULLNAME REDLUA_NAME " " REDLUA_VERSION
77

88
#define REDLUA_TAGS_URL "https://api.github.com/repos/igor725/RedLua/tags"

src/redlua.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,12 @@ class LuaScript {
9999
}
100100

101101
bool Load(void) {
102-
if(m_modref != LUA_REFNIL) luaL_unref(L, LUA_REGISTRYINDEX, m_modref);
102+
if(m_modref != LUA_REFNIL) {
103+
if(LookForFunc("OnReload") && !CallFunc(0, 0, false))
104+
return false;
105+
106+
luaL_unref(L, LUA_REGISTRYINDEX, m_modref);
107+
}
103108
if(luaL_loadfile(L, m_path.c_str()) != 0) {
104109
LogLuaError();
105110
return false;

0 commit comments

Comments
 (0)