Пользователь
боюсь он навряд ли что нибудь поймет тут1488:m_state.new_usertype< vec3_t >( xorstr_( "vector" ), sol::constructors< vec3_t( ), vec3_t( float, float, float ) >( ), std::string_view{ xorstr_( "x" ) }, &vec3_t::x, std::string_view{ xorstr_( "y" ) }, &vec3_t::y, std::string_view{ xorstr_( "z" ) }, &vec3_t::z, std::string_view{ xorstr_( "length" ) }, &vec3_t::length, std::string_view{ xorstr_( "lengthsqr" ) }, &vec3_t::length_sqr, std::string_view{ xorstr_( "length2d" ) }, &vec3_t::length_2d, std::string_view{ xorstr_( "length2dsqr" ) }, &vec3_t::length_2d_sqr, std::string_view{ xorstr_( "normalize" ) }, &vec3_t::normalize, std::string_view{ xorstr_( "normalized" ) }, &vec3_t::normalized ); m_state.new_usertype< valve::cvar_t >( xorstr_( "convar" ), std::string_view{ xorstr_( "get_int" ) }, &valve::cvar_t::get_int, std::string_view{ xorstr_( "get_float" ) }, &valve::cvar_t::get_float, std::string_view{ xorstr_( "get_string" ) }, &valve::cvar_t::get_str, std::string_view{ xorstr_( "set_int" ) }, &valve::cvar_t::set_int, std::string_view{ xorstr_( "set_float" ) }, &valve::cvar_t::set_float, std::string_view{ xorstr_( "set_string" ) }, &valve::cvar_t::set_str ); m_state.new_usertype< lua_user_cmd_t >( xorstr_( "lua_user_cmd" ), std::string_view{ xorstr_( "chokedcommands" ) }, &lua_user_cmd_t::m_choked_cmds, std::string_view{ xorstr_( "command_number" ) }, &lua_user_cmd_t::m_cmd_number, std::string_view{ xorstr_( "pitch" ) }, &lua_user_cmd_t::m_pitch, std::string_view{ xorstr_( "yaw" ) }, &lua_user_cmd_t::m_yaw, std::string_view{ xorstr_( "forwardmove" ) }, &lua_user_cmd_t::m_fwd_move, std::string_view{ xorstr_( "sidemove" ) }, &lua_user_cmd_t::m_side_move, std::string_view{ xorstr_( "move_yaw" ) }, &lua_user_cmd_t::m_move_yaw, std::string_view{ xorstr_( "allow_send_packet" ) }, &lua_user_cmd_t::m_allow_send_packet, #define ADD_FLAG( var ) std::string_view{ xorstr_( #var ) }, &lua_user_cmd_t::m_##var ADD_FLAG( in_attack ), ADD_FLAG( in_jump ), ADD_FLAG( in_duck ), ADD_FLAG( in_forward ), ADD_FLAG( in_back ), ADD_FLAG( in_use ), ADD_FLAG( in_cancel ), ADD_FLAG( in_left ), ADD_FLAG( in_right ), ADD_FLAG( in_move_left ), ADD_FLAG( in_move_right ), ADD_FLAG( in_attack2 ), ADD_FLAG( in_run ), ADD_FLAG( in_reload ), ADD_FLAG( in_alt1 ), ADD_FLAG( in_alt2 ), ADD_FLAG( in_score ), ADD_FLAG( in_speed ), ADD_FLAG( in_walk ), ADD_FLAG( in_zoom ), ADD_FLAG( in_weapon1 ), ADD_FLAG( in_weapon2 ), ADD_FLAG( in_bullrush ), ADD_FLAG( in_grenade1 ), ADD_FLAG( in_grenade2 ), ADD_FLAG( in_attack3 ), #undef ADD_FLAG std::string_view{ xorstr_( "weaponselect" ) }, &lua_user_cmd_t::m_weaponselect, std::string_view{ xorstr_( "weaponsubtype" ) }, &lua_user_cmd_t::m_weaponsubtype ); { auto entity = m_state.create_table( ); entity[ xorstr_( "get_all" ) ] = [ ] ( const char* class_name ) entity[ xorstr_( "get_players" ) ] = [] ( const bool enemies_only ) entity[ xorstr_( "get_classname" ) ] = [ ] ( const int index ) entity[ xorstr_( "get_local_player" ) ] = [ ] ( ) entity[ xorstr_( "get_origin" ) ] = [ ] ( const int index ) entity[ xorstr_( "get_player_name" ) ] = [] ( const int index ) }; entity[ xorstr_( "is_alive" ) ] = [] ( const int index ) { entity[ xorstr_( "is_dormant" ) ] = [] ( const int index ) entity[ xorstr_( "is_enemy" ) ] = [] ( const int index ) entity[ xorstr_( "set_prop" ) ] = [ ] ( const int index, const char* prop_name, const std::variant< vec3_t, int, float >& value, const std::size_t array_index = 0u ) entity[ xorstr_( "get_prop" ) ] = [ ] ( const int index, const char* prop_name, const std::size_t array_index = 0u ) }; m_state[ xorstr_( "entity" ) ] = entity; } { auto globals = m_state.create_table( ); globals[ xorstr_( "absoluteframetime" ) ] = [ ] ( ) globals[ xorstr_( "chokedcommands" ) ] = [ ] ( ) globals[ xorstr_( "commandack" ) ] = [ ] ( ) { r globals[ xorstr_( "curtime" ) ] = [ ] ( ) globals[ xorstr_( "framecount" ) ] = [ ] ( ) globals[ xorstr_( "frametime" ) ] = [ ] ( ) globals[ xorstr_( "lastoutgoingcommand" ) ] = [ ] ( ) globals[ xorstr_( "mapname" ) ] = [ ] ( ) globals[ xorstr_( "maxplayers" ) ] = [ ] ( ) globals[ xorstr_( "oldcommandack" ) ] = [ ] ( ) globals[ xorstr_( "realtime" ) ] = [ ] ( ) globals[ xorstr_( "tickcount" ) ] = [ ] ( ) globals[ xorstr_( "tickinterval" ) ] = [ ] ( ) m_state[ xorstr_( "globals" ) ] = globals; } { auto client = m_state.create_table( ); client[ xorstr_( "camera_angles" ) ] = [ ] ( ) { client[ xorstr_( "camera_position" ) ] = [ ] ( ) client[ xorstr_( "color_log" ) ] = [ ] ( const std::uint8_t r, const std::uint8_t g, const std::uint8_t b, const char* str client[ xorstr_( "create_interface" ) ] = [ ] ( const char* module_name, const char* interface_name ) client[ xorstr_( "delay_call" ) ] = [ ] ( const int delay, const sol::protected_function& fn, const sol::variadic_args& args ) { client[ xorstr_( "error_log" ) ] = [ ] ( const char* str ) client[ xorstr_( "exec" ) ] = [ ] ( const char* cmd ) client[ xorstr_( "eye_position" ) ] = [ ] ( ) client[ xorstr_( "log" ) ] = [ ] ( const char* str ) client[ xorstr_( "latency" ) ] = [ ] ( ) client[ xorstr_( "random_float" ) ] = [ ] ( const float min, const float max ) client[ xorstr_( "random_int" ) ] = [ ] ( const int min, const int max ) client[ xorstr_( "scale_damage" ) ] = [ ] ( const int ent_index, const int hitgroup, const int dmg ) client[ xorstr_( "userid_to_entindex" ) ] = [ ] ( const int uid ; client[ xorstr_( "set_event_callback" ) ] = [ & ] ( const char* event_name, const sol::protected_function& callback ); }; client[ xorstr_( "find_signature" ) ] = [ ] ( const char* module_name, const char* seq ) ; m_state[ xorstr_( "client" ) ] = client; } { auto cvar = m_state.create_table( ); cvar[ xorstr_( "find" ) ] = [ ] ( const char* name ) ; m_state[ xorstr_( "cvar" ) ] = cvar; } m_events[ xorstr_( "setup_command" ) ] = {}; m_events[ xorstr_( "net_update_start" ) ] = {}; m_events[ xorstr_( "net_update_end" ) ] = {};
на апи