feat(lua): expose the self class and add new menu events (#2656)
This commit is contained in:
@ -80,6 +80,28 @@ namespace lua::event
|
||||
// end)
|
||||
// ```
|
||||
|
||||
// Lua API: Field
|
||||
// Table: menu_event
|
||||
// Field: MenuUnloaded: integer
|
||||
// Event that is triggered when we unload YimMenu.
|
||||
// **Example Usage:**
|
||||
// ```lua
|
||||
// event.register_handler(menu_event.MenuUnloaded, function ()
|
||||
// log.info("Menu unloaded.")
|
||||
// end)
|
||||
// ```
|
||||
|
||||
// Lua API: Field
|
||||
// Table: menu_event
|
||||
// Field: ScriptsReloaded: integer
|
||||
// Event that is triggered when we reload the Lua scripts.
|
||||
// **Example Usage:**
|
||||
// ```lua
|
||||
// event.register_handler(menu_event.ScriptsReloaded, function ()
|
||||
// log.info("Scripts reloaded.")
|
||||
// end)
|
||||
// ```
|
||||
|
||||
// Lua API: Table
|
||||
// Name: event
|
||||
// Table for responding to various events. The list of events is available in the menu_event table.
|
||||
@ -107,6 +129,8 @@ namespace lua::event
|
||||
{"PlayerMgrShutdown", menu_event::PlayerMgrShutdown},
|
||||
{"ChatMessageReceived", menu_event::ChatMessageReceived},
|
||||
{"ScriptedGameEventReceived", menu_event::ScriptedGameEventReceived},
|
||||
{"MenuUnloaded", menu_event::MenuUnloaded},
|
||||
{"ScriptsReloaded", menu_event::ScriptsReloaded},
|
||||
});
|
||||
|
||||
|
||||
|
43
src/lua/bindings/self.cpp
Normal file
43
src/lua/bindings/self.cpp
Normal file
@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
#include "self.hpp"
|
||||
|
||||
namespace lua_self = self;
|
||||
|
||||
namespace lua::self
|
||||
{
|
||||
static Ped get_ped()
|
||||
{
|
||||
return lua_self::ped;
|
||||
}
|
||||
|
||||
static Player get_id()
|
||||
{
|
||||
return lua_self::id;
|
||||
}
|
||||
|
||||
static Vector3 get_pos()
|
||||
{
|
||||
return lua_self::pos;
|
||||
}
|
||||
|
||||
static Vector3 get_rot()
|
||||
{
|
||||
return lua_self::rot;
|
||||
}
|
||||
|
||||
static Vehicle get_veh()
|
||||
{
|
||||
return lua_self::veh;
|
||||
}
|
||||
|
||||
void bind(sol::state& state)
|
||||
{
|
||||
auto ns = state["self"].get_or_create<sol::table>();
|
||||
|
||||
ns["get_ped"] = get_ped;
|
||||
ns["get_id"] = get_id;
|
||||
ns["get_pos"] = get_pos;
|
||||
ns["get_rot"] = get_rot;
|
||||
ns["get_veh"] = get_veh;
|
||||
}
|
||||
}
|
6
src/lua/bindings/self.hpp
Normal file
6
src/lua/bindings/self.hpp
Normal file
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
namespace lua::self
|
||||
{
|
||||
void bind(sol::state& state);
|
||||
}
|
Reference in New Issue
Block a user