From cd9fde5d2897473dca5f8dbf99e6dc831a275a74 Mon Sep 17 00:00:00 2001 From: Lee <31358036+11Lee1@users.noreply.github.com> Date: Sun, 2 Jun 2019 09:46:31 -0400 Subject: [PATCH] Update vox_lua_bridge.cpp here --- source/vox_lua_bridge.cpp | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/source/vox_lua_bridge.cpp b/source/vox_lua_bridge.cpp index ca0994d..681a76a 100644 --- a/source/vox_lua_bridge.cpp +++ b/source/vox_lua_bridge.cpp @@ -46,22 +46,13 @@ Vector elua_getVector(lua_State* state, int index) { //Can't figure out how to push vectors without crashing the game when they get GC'd void elua_pushVector(lua_State* state, Vector v) { - LUA->PushSpecial(SPECIAL_GLOB); - LUA->GetField(-1, "Vector"); - LUA->Remove(-2); - LUA->PushNumber(v.x); - LUA->PushNumber(v.y); - LUA->PushNumber(v.z); - LUA->Call(3, 1); - - /* - GarrysMod::Lua::UserData* ud = (UserData*)(LUA->NewUserdata(sizeof(UserData))); - ud->type = Type::VECTOR; - ud->data = new Vector(v); - - LUA->CreateMetaTableType("Vector", Type::VECTOR); - LUA->SetMetaTable(-2); - */ + void* _UserData = (void*)LUA->NewUserData(20); + *(char*)((unsigned int)_Userdata + 0x4) = Type::VECTOR; + ***(unsigned int***)_UserData = (**(unsigned int**)_UserData + 0x8); + if (LUA->PushMetaTable(Type::VECTOR)) + LUA->SetMetaTable(-2); + + **(Vector**)_UserData = v; } bool config_bool(lua_State* state, const char* name, bool default_value) { @@ -692,4 +683,4 @@ void init_lua(lua_State* state, const char* version_string) { runBootstrap(state); LUA->Pop(); -} \ No newline at end of file +}