feat(lua): Add entities.get_all_vehicles_as_handles() Add entities.get_all_peds_as_handles() Add entities.get_all_objects_as_handles() (#1795)

This commit is contained in:
Quentin
2023-07-21 21:21:51 +02:00
committed by GitHub
parent c686fde0ec
commit 093abc72da
6 changed files with 96 additions and 3 deletions

View File

@ -0,0 +1,46 @@
#pragma once
#include "entities.hpp"
#include "util/pools.hpp"
namespace lua::entities
{
// Lua API: Table
// Name: entities
// Table for manipulating GTA entities.
// Lua API: Function
// Table: entities
// Name: get_all_vehicles_as_handles
// Returns: table<int, int>: Returns all vehicles as script handles
static std::vector<Entity> get_all_vehicles_as_handles()
{
return big::pools::get_all_vehicles_array();
}
// Lua API: Function
// Table: entities
// Name: get_all_peds_as_handles
// Returns: table<int, int>: Returns all peds as script handles
static std::vector<Entity> get_all_peds_as_handles()
{
return big::pools::get_all_peds_array();
}
// Lua API: Function
// Table: entities
// Name: get_all_objects_as_handles
// Returns: table<int, int>: Returns all objects as script handles
static std::vector<Entity> get_all_objects_as_handles()
{
return big::pools::get_all_props_array();
}
void bind(sol::state& state)
{
auto ns = state["entities"].get_or_create<sol::table>();
ns["get_all_vehicles_as_handles"] = get_all_vehicles_as_handles;
ns["get_all_peds_as_handles"] = get_all_peds_as_handles;
ns["get_all_objects_as_handles"] = get_all_objects_as_handles;
}
}

View File

@ -0,0 +1,7 @@
#pragma once
#include "lua/sol.hpp"
namespace lua::entities
{
void bind(sol::state& state);
}

View File

@ -1,10 +1,12 @@
#include "lua_module.hpp"
#include "bindings/command.hpp"
#include "bindings/entities.hpp"
#include "bindings/event.hpp"
#include "bindings/global_table.hpp"
#include "bindings/globals.hpp"
#include "bindings/gui.hpp"
#include "bindings/imgui.hpp"
#include "bindings/locals.hpp"
#include "bindings/log.hpp"
#include "bindings/memory.hpp"
@ -13,7 +15,6 @@
#include "bindings/script.hpp"
#include "bindings/tunables.hpp"
#include "bindings/vector.hpp"
#include "bindings/imgui.hpp"
#include "file_manager.hpp"
#include "script_mgr.hpp"
@ -217,5 +218,6 @@ namespace big
lua::vector::bind(state);
lua::global_table::bind(state);
lua::imgui::bind(state, state.globals());
lua::entities::bind(state);
}
}