Skip to content

Commit

Permalink
Implement global Lua function GenerateLuaTypes (#625) (#664)
Browse files Browse the repository at this point in the history
* feat: Implement global Lua function GenerateLuaTypes (#625)
feat: Add mod nullptr check to Genera
docs: Add missing Dumpers global functions to Types.lua

* docs: Update changelog for #625 and #625

* refactor: Fix new lines after conflict resolving
  • Loading branch information
igromanru authored Oct 1, 2024
1 parent 229040b commit d0ebf12
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
17 changes: 16 additions & 1 deletion UE4SS/src/Mod/LuaMod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,7 @@ No overload found for function 'UnregisterHook'.
const Mod* mod = get_mod_ref(lua);
if (!mod)
{
lua.throw_error("Could not dump objects and properties because the pointer to 'Mod' was nullptr");
lua.throw_error("Couldn't dump objects and properties because the pointer to 'Mod' was nullptr");
}
UE4SSProgram::dump_all_objects_and_properties(mod->m_program.get_object_dumper_output_directory() + STR("\\") +
UE4SSProgram::m_object_dumper_file_name);
Expand All @@ -1449,11 +1449,26 @@ No overload found for function 'UnregisterHook'.

lua.register_function("GenerateSDK", []([[maybe_unused]] const LuaMadeSimple::Lua& lua) -> int {
const Mod* mod = get_mod_ref(lua);
if (!mod)
{
lua.throw_error("Couldn't generate SDK because the pointer to 'Mod' was nullptr");
}
File::StringType working_dir{mod->m_program.get_working_directory()};
mod->m_program.generate_cxx_headers(working_dir + STR("\\CXXHeaderDump"));
return 0;
});

lua.register_function("GenerateLuaTypes", []([[maybe_unused]] const LuaMadeSimple::Lua& lua) -> int {
const Mod* mod = get_mod_ref(lua);
if (!mod)
{
lua.throw_error("Couldn't generate lua types because the pointer to 'Mod' was nullptr");
}
File::StringType working_dir{mod->m_program.get_working_directory()};
UE4SSProgram::get_program().generate_lua_types(working_dir + STR("\\Mods\\shared\\types"));
return 0;
});

lua.register_function("GenerateUHTCompatibleHeaders", []([[maybe_unused]] const LuaMadeSimple::Lua& lua) -> int {
const Mod* mod = get_mod_ref(lua);
mod->m_program.generate_uht_compatible_headers();
Expand Down
5 changes: 4 additions & 1 deletion assets/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ Added search filter: `IncludeClassNames`. ([UE4SS #472](https://github.com/UE4SS
### UHT Dumper

### Lua API
Added global function `CreateInvalidObject`, which returns an invalid UObject. ([UE4SS #652](https://github.com/UE4SS-RE/RE-UE4SS/issues/652))

Added global function `CreateInvalidObject`, which returns an invalid UObject. ([UE4SS #652](https://github.com/UE4SS-RE/RE-UE4SS/issues/652))
Added GenerateLuaTypes function. ([UE4SS #664](https://github.com/UE4SS-RE/RE-UE4SS/pull/664))
Added global Dumpers functions to Types.lua. ([UE4SS #664](https://github.com/UE4SS-RE/RE-UE4SS/pull/664))

### C++ API
Key binds created with `UE4SSProgram::register_keydown_event` end up being duplicated upon mod hot-reload.
Expand Down
21 changes: 21 additions & 0 deletions assets/Mods/shared/Types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,27 @@ EInternalObjectFlags = {
---@return UObject
function CreateInvalidObject() end

---Dumps all objects and properties to UE4SS_ObjectDump.txt file
function DumpAllObjects() end

---Generates CXX Headers / CXXHeaderDump
function GenerateSDK() end

---Generates lua types in /Mods/shared/types
function GenerateLuaTypes() end

---Generates UHT Compatible Headers
function GenerateUHTCompatibleHeaders() end

---Dumps Static Meshes to *-ue4ss_static_mesh_data.csv file
function DumpStaticMeshes() end

---Dumps all current existing actors to *-ue4ss_actor_data.csv file
function DumpAllActors() end

--- Generates .usmap file
function DumpUSMAP() end

---@param ObjectName string
---@return UObject
function StaticFindObject(ObjectName) end
Expand Down

0 comments on commit d0ebf12

Please sign in to comment.