From 5c47da4077deb8cd94ba961f37adff44a347cdc2 Mon Sep 17 00:00:00 2001 From: legokidlogan <26103433+legokidlogan@users.noreply.github.com> Date: Thu, 26 Feb 2026 11:09:41 -0600 Subject: [PATCH 1/4] Add clientside variants to applicable starfall functions --- lua/entities/sent_prop2mesh/cl_init.lua | 148 +++++++++++++++++++----- lua/starfall/libs_cl/prop2mesh.lua | 123 ++++++++++++++++++++ lua/starfall/libs_sv/prop2mesh.lua | 11 ++ 3 files changed, 256 insertions(+), 26 deletions(-) diff --git a/lua/entities/sent_prop2mesh/cl_init.lua b/lua/entities/sent_prop2mesh/cl_init.lua index 6beea15..23d1ee9 100644 --- a/lua/entities/sent_prop2mesh/cl_init.lua +++ b/lua/entities/sent_prop2mesh/cl_init.lua @@ -37,6 +37,7 @@ local Ent_SetColor = entMeta.SetColor local Ent_GetTable = entMeta.GetTable local Ent_DrawModel = entMeta.DrawModel local Ent_GetAngles = entMeta.GetAngles +local Ent_GetParent = entMeta.GetParent local Ent_SetParent = entMeta.SetParent local Ent_SetAngles = entMeta.SetAngles local Ent_SetMaterial = entMeta.SetMaterial @@ -396,6 +397,39 @@ local function drawMesh(self) return meshes and meshes.basic or empty end +local function refreshSetColor(infoEnt, col) + local isOpaque = col.a == 255 + + Ent_SetColor(infoEnt, col) + Ent_SetRenderMode(infoEnt, isOpaque and RENDERMODE_NORMAL or RENDERMODE_TRANSCOLOR) + infoEnt.RenderGroup = isOpaque and RENDERGROUP_OPAQUE or RENDERGROUP_BOTH +end + +local function refreshSetScale(infoEnt, scale) + if scale.x ~= 1 or scale.y ~= 1 or scale.z ~= 1 then + local matrix = Matrix() + matrix:SetScale(scale) + Ent_EnableMatrix(infoEnt, "RenderMultiply", matrix) + infoEnt.scale = scale + else + Ent_DisableMatrix(infoEnt, "RenderMultiply") + infoEnt.scale = nil + end +end + +local function refreshSetPosAng(infoEnt, info, p2mEnt) + local linkEnt = info.linkent + local parent = IsValid(linkEnt) and linkEnt or p2mEnt + local pos, ang = LocalToWorld(info.linkpos or vecZero, info.linkang or angZero, Ent_GetPos(parent), Ent_GetAngles(parent)) + + if parent ~= Ent_GetParent(infoEnt) then + Ent_SetParent(infoEnt, parent) + end + + Ent_SetPos(infoEnt, pos) + Ent_SetAngles(infoEnt, ang) +end + local function refresh(self, info) local infoEnt = info.ent @@ -411,33 +445,12 @@ local function refresh(self, info) info.ent = infoEnt end - local linkEnt = info.linkent - local parent = IsValid(linkEnt) and linkEnt or self - local pos, ang = LocalToWorld(info.linkpos or vecZero, info.linkang or angZero, Ent_GetPos(parent), Ent_GetAngles(parent)) - - Ent_SetParent(infoEnt, parent) - Ent_SetAngles(infoEnt, ang) - Ent_SetPos(infoEnt, pos) - local infoEntTable = Ent_GetTable(infoEnt) - local infoCol = info.col - local isOpaque = infoCol.a == 255 Ent_SetMaterial(infoEnt, info.mat) - Ent_SetColor(infoEnt, infoCol) - Ent_SetRenderMode(infoEnt, isOpaque and RENDERMODE_NORMAL or RENDERMODE_TRANSCOLOR) - infoEntTable.RenderGroup = isOpaque and RENDERGROUP_OPAQUE or RENDERGROUP_BOTH - - local infoScale = info.scale - if infoScale.x ~= 1 or infoScale.y ~= 1 or infoScale.z ~= 1 then - local matrix = Matrix() - matrix:SetScale(infoScale) - Ent_EnableMatrix(infoEnt, "RenderMultiply", matrix) - infoEnt.scale = info.scale - else - Ent_DisableMatrix(infoEnt, "RenderMultiply") - infoEnt.scale = nil - end + refreshSetColor(infoEnt, info.col) + refreshSetScale(infoEnt, info.scale) + refreshSetPosAng(infoEnt, info, self) local infoCrc = info.crc local infoUniqueID = info.uniqueID @@ -583,10 +596,92 @@ function ENT:GetDownloadProgress() end +local kvpass = {} +local function applyPropertyWithKVPass(ent, index, key, val) + local info = ent.prop2mesh_controllers[index] + if not info then return end + + local pass = kvpass[key] + + if pass then + pass(self, info, val) + val = info[key] -- Get the modified result + else + info[key] = val + end + + return val, info.ent +end + +function ENT:SetControllerCol(index, col) + local infoEnt + col, infoEnt = applyPropertyWithKVPass(self, index, "col", col) + if col == nil then return end + if not IsValid(infoEnt) then return end + + refreshSetColor(infoEnt, col) +end + +function ENT:SetControllerPos(index, linkpos) + local infoEnt + linkpos, infoEnt = applyPropertyWithKVPass(self, index, "linkpos", linkpos) + if linkpos == nil then return end + if not IsValid(infoEnt) then return end + + refreshSetPosAng(infoEnt, self.prop2mesh_controllers[index], self) +end + +function ENT:SetControllerAng(index, linkang) + local infoEnt + linkang, infoEnt = applyPropertyWithKVPass(self, index, "linkang", linkang) + if linkang == nil then return end + if not IsValid(infoEnt) then return end + + refreshSetPosAng(infoEnt, self.prop2mesh_controllers[index], self) +end + +function ENT:SetControllerMat(index, mat) + local infoEnt + mat, infoEnt = applyPropertyWithKVPass(self, index, "mat", mat) + if mat == nil then return end + if not IsValid(infoEnt) then return end + + Ent_SetMaterial(infoEnt, mat) +end + +function ENT:SetControllerUVS(index, uvs) + local infoEnt + uvs, infoEnt = applyPropertyWithKVPass(self, index, "uvs", uvs) + if uvs == nil then return end + if not IsValid(infoEnt) then return end + + infoEnt.uvs = uvs + infoEnt.uniqueID = self.prop2mesh_controllers[index].uniqueID +end + +function ENT:SetControllerBump(index, bump) + local infoEnt + bump, infoEnt = applyPropertyWithKVPass(self, index, "bump", bump) + if bump == nil then return end + if not IsValid(infoEnt) then return end + + infoEnt.bump = bump + infoEnt.uniqueID = self.prop2mesh_controllers[index].uniqueID +end + +function ENT:SetControllerScale(index, scale) + local infoEnt + scale, infoEnt = applyPropertyWithKVPass(self, index, "scale", scale) + if scale == nil then return end + if not IsValid(infoEnt) then return end + + refreshSetScale(infoEnt, scale) +end + + --[[ ]] -local kvpass = {} kvpass.crc = function(self, info, val) local crc = info.crc info.crc = val @@ -667,7 +762,8 @@ kvpass.mat = function(self, info, val) end kvpass.scale = function(self, info, val) - info.scale = Vector(unpack(val)) + if type(val) == "table" then val = Vector(unpack(val)) end + info.scale = val end kvpass.clips = function(self, info, val) diff --git a/lua/starfall/libs_cl/prop2mesh.lua b/lua/starfall/libs_cl/prop2mesh.lua index 63b919a..f1d6c07 100644 --- a/lua/starfall/libs_cl/prop2mesh.lua +++ b/lua/starfall/libs_cl/prop2mesh.lua @@ -32,9 +32,30 @@ return function( instance ) local ang_meta, aunwrap = instance.Types.Angle, instance.Types.Angle.Unwrap local vec_meta, vunwrap = instance.Types.Vector, instance.Types.Vector.Unwrap local col_meta, cwrap, cunwrap = instance.Types.Color, instance.Types.Color.Wrap, instance.Types.Color.Unwrap + local checkpermission = instance.player ~= SF.Superuser and SF.Permissions.check or function() end local recycle = prop2mesh.recycle + + local function getControllerInfo(ent, index) + CheckLuaType(index, TYPE_NUMBER) + + local controllers = ent.prop2mesh_controllers + if not controllers then + SF.Throw("This function is limited to sf controllers!", 3) + return false + end + + local info = controllers[index] + if not info then + SF.Throw(string.format("controller index %d does not exist on %s!", index, tostring(ent)), 3) + return false + end + + return info + end + + --- Manually sets controller info from a table clientside. It's important to note that this does not set the controller info serverside, so any modifications made to this P2M, dupe copying, etc. will not copy the inputted info -- @param number index index of controller -- @param table controllerData controller table to insert @@ -59,4 +80,106 @@ return function( instance ) prop2mesh.handleDownload(dataCRC, controllerDataComp) prop2mesh.refresh(ent, controller) end + + function ents_methods:p2mGetCount() + CheckType(self, ents_metatable) + local ent = unwrap(self) + local controllers = ent.prop2mesh_controllers + if not controllers then SF.Throw("This function is limited to sf controllers!", 2) end + + return #controllers + end + + function ents_methods:p2mSetColor(index, color) + CheckType(self, ents_metatable) + local ent = unwrap(self) + if not getControllerInfo(ent, index) then return end + checkpermission(instance, ent, "entities.setRenderProperty") + + ent:SetControllerCol(index, cunwrap(color)) + end + + function ents_methods:p2mGetColor(index) + CheckType(self, ents_metatable) + local ent = unwrap(self) + + return cwrap(getControllerInfo(ent, index).col) + end + + function ents_methods:p2mSetAlpha(index, alpha) + CheckType(self, ents_metatable) + CheckLuaType(alpha, TYPE_NUMBER) + local ent = unwrap(self) + local info = getControllerInfo(ent, index) + if not info then return end + checkpermission(instance, ent, "entities.setRenderProperty") + + info.col.a = alpha + ent:SetControllerCol(index, info.col) + end + + function ents_methods:p2mSetPos(index, pos) + CheckType(self, ents_metatable) + local ent = unwrap(self) + if not getControllerInfo(ent, index) then return end + checkpermission(instance, ent, "entities.setRenderProperty") + + ent:SetControllerPos(index, vunwrap(pos)) + end + + function ents_methods:p2mSetAng(index, ang) + CheckType(self, ents_metatable) + local ent = unwrap(self) + if not getControllerInfo(ent, index) then return end + checkpermission(instance, ent, "entities.setRenderProperty") + + ent:SetControllerAng(index, aunwrap(ang)) + end + + function ents_methods:p2mSetMaterial(index, mat) + CheckType(self, ents_metatable) + CheckLuaType(mat, TYPE_STRING) + local ent = unwrap(self) + if not getControllerInfo(ent, index) then return end + checkpermission(instance, ent, "entities.setRenderProperty") + + ent:SetControllerMat(index, mat) + end + + function ents_methods:p2mGetMaterial(index) + CheckType(self, ents_metatable) + local ent = unwrap(self) + + return getControllerInfo(ent, index).mat + end + + function ents_methods:p2mSetUV(index, uvs) + CheckType(self, ents_metatable) + CheckLuaType(uvs, TYPE_NUMBER) + local ent = unwrap(self) + if not getControllerInfo(ent, index) then return end + checkpermission(instance, ent, "entities.setRenderProperty") + + uvs = math.Clamp(math.floor(math.abs(uvs)), 0, 512) + ent:SetControllerUVS(index, uvs) + end + + function ents_methods:p2mSetBump(index, bump) + CheckType(self, ents_metatable) + CheckLuaType(bump, TYPE_BOOL) + local ent = unwrap(self) + if not getControllerInfo(ent, index) then return end + checkpermission(instance, ent, "entities.setRenderProperty") + + ent:SetControllerBump(index, bump) + end + + function ents_methods:p2mSetScale(index, scale) + CheckType(self, ents_metatable) + local ent = unwrap(self) + if not getControllerInfo(ent, index) then return end + checkpermission(instance, ent, "entities.setRenderProperty") + + ent:SetControllerScale(index, vunwrap(scale)) + end end diff --git a/lua/starfall/libs_sv/prop2mesh.lua b/lua/starfall/libs_sv/prop2mesh.lua index 2aaa202..3aad17f 100644 --- a/lua/starfall/libs_sv/prop2mesh.lua +++ b/lua/starfall/libs_sv/prop2mesh.lua @@ -386,6 +386,7 @@ return function( instance ) end --- Gets the number of prop2mesh controllers + -- @shared -- @return number count function ents_methods:p2mGetCount() CheckType( self, ents_metatable ) @@ -399,6 +400,7 @@ return function( instance ) end --- Gets the color of the controller + -- @shared -- @param number index -- @return Color the color function ents_methods:p2mGetColor( index ) @@ -415,6 +417,7 @@ return function( instance ) end --- Sets the position of the controller + -- @shared -- @param number index -- @param Vector position function ents_methods:p2mSetPos( index, pos ) @@ -430,6 +433,7 @@ return function( instance ) end --- Sets the angle of the controller + -- @shared -- @param number index -- @param Angle angle function ents_methods:p2mSetAng( index, ang ) @@ -445,6 +449,7 @@ return function( instance ) end --- Sets the color of the controller + -- @shared -- @param number index -- @param Color color function ents_methods:p2mSetColor( index, color ) @@ -461,6 +466,7 @@ return function( instance ) end --- Sets the alpha of the controller + -- @shared -- @param number index -- @param number alpha function ents_methods:p2mSetAlpha( index, alpha ) @@ -479,6 +485,7 @@ return function( instance ) end --- Gets the material of the controller + -- @shared -- @param number index -- @return string material name function ents_methods:p2mGetMaterial( index ) @@ -495,6 +502,7 @@ return function( instance ) end --- Sets the material of the controller + -- @shared -- @param number index -- @param string mat material name function ents_methods:p2mSetMaterial( index, mat ) @@ -512,6 +520,7 @@ return function( instance ) end --- Sets the scale of the controller + -- @shared -- @param number index -- @param Vector scale function ents_methods:p2mSetScale( index, scale ) @@ -527,6 +536,7 @@ return function( instance ) end --- Sets the UVs of the controller + -- @shared -- @param number index -- @param number uvs function ents_methods:p2mSetUV( index, uvs ) @@ -544,6 +554,7 @@ return function( instance ) end --- Enables or disables bumpmaps on the controller + -- @shared -- @param number index -- @param boolean bump function ents_methods:p2mSetBump( index, bump ) From 85c9aae6f93490381a1e06d09af6d6ce35856809 Mon Sep 17 00:00:00 2001 From: legokidlogan <26103433+legokidlogan@users.noreply.github.com> Date: Thu, 26 Feb 2026 11:12:14 -0600 Subject: [PATCH 2/4] Don't replicate UV/Bump, they could desync uniqueID improperly --- lua/entities/sent_prop2mesh/cl_init.lua | 20 -------------------- lua/starfall/libs_cl/prop2mesh.lua | 21 --------------------- lua/starfall/libs_sv/prop2mesh.lua | 2 -- 3 files changed, 43 deletions(-) diff --git a/lua/entities/sent_prop2mesh/cl_init.lua b/lua/entities/sent_prop2mesh/cl_init.lua index 23d1ee9..d2f229d 100644 --- a/lua/entities/sent_prop2mesh/cl_init.lua +++ b/lua/entities/sent_prop2mesh/cl_init.lua @@ -649,26 +649,6 @@ function ENT:SetControllerMat(index, mat) Ent_SetMaterial(infoEnt, mat) end -function ENT:SetControllerUVS(index, uvs) - local infoEnt - uvs, infoEnt = applyPropertyWithKVPass(self, index, "uvs", uvs) - if uvs == nil then return end - if not IsValid(infoEnt) then return end - - infoEnt.uvs = uvs - infoEnt.uniqueID = self.prop2mesh_controllers[index].uniqueID -end - -function ENT:SetControllerBump(index, bump) - local infoEnt - bump, infoEnt = applyPropertyWithKVPass(self, index, "bump", bump) - if bump == nil then return end - if not IsValid(infoEnt) then return end - - infoEnt.bump = bump - infoEnt.uniqueID = self.prop2mesh_controllers[index].uniqueID -end - function ENT:SetControllerScale(index, scale) local infoEnt scale, infoEnt = applyPropertyWithKVPass(self, index, "scale", scale) diff --git a/lua/starfall/libs_cl/prop2mesh.lua b/lua/starfall/libs_cl/prop2mesh.lua index f1d6c07..8db6867 100644 --- a/lua/starfall/libs_cl/prop2mesh.lua +++ b/lua/starfall/libs_cl/prop2mesh.lua @@ -153,27 +153,6 @@ return function( instance ) return getControllerInfo(ent, index).mat end - function ents_methods:p2mSetUV(index, uvs) - CheckType(self, ents_metatable) - CheckLuaType(uvs, TYPE_NUMBER) - local ent = unwrap(self) - if not getControllerInfo(ent, index) then return end - checkpermission(instance, ent, "entities.setRenderProperty") - - uvs = math.Clamp(math.floor(math.abs(uvs)), 0, 512) - ent:SetControllerUVS(index, uvs) - end - - function ents_methods:p2mSetBump(index, bump) - CheckType(self, ents_metatable) - CheckLuaType(bump, TYPE_BOOL) - local ent = unwrap(self) - if not getControllerInfo(ent, index) then return end - checkpermission(instance, ent, "entities.setRenderProperty") - - ent:SetControllerBump(index, bump) - end - function ents_methods:p2mSetScale(index, scale) CheckType(self, ents_metatable) local ent = unwrap(self) diff --git a/lua/starfall/libs_sv/prop2mesh.lua b/lua/starfall/libs_sv/prop2mesh.lua index 3aad17f..da781b6 100644 --- a/lua/starfall/libs_sv/prop2mesh.lua +++ b/lua/starfall/libs_sv/prop2mesh.lua @@ -536,7 +536,6 @@ return function( instance ) end --- Sets the UVs of the controller - -- @shared -- @param number index -- @param number uvs function ents_methods:p2mSetUV( index, uvs ) @@ -554,7 +553,6 @@ return function( instance ) end --- Enables or disables bumpmaps on the controller - -- @shared -- @param number index -- @param boolean bump function ents_methods:p2mSetBump( index, bump ) From 8eb750cc8e32430b09382f413b675d9097eed49c Mon Sep 17 00:00:00 2001 From: legokidlogan <26103433+legokidlogan@users.noreply.github.com> Date: Thu, 26 Feb 2026 11:13:12 -0600 Subject: [PATCH 3/4] Improve docstring --- lua/starfall/libs_sv/prop2mesh.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/starfall/libs_sv/prop2mesh.lua b/lua/starfall/libs_sv/prop2mesh.lua index da781b6..987f391 100644 --- a/lua/starfall/libs_sv/prop2mesh.lua +++ b/lua/starfall/libs_sv/prop2mesh.lua @@ -416,7 +416,7 @@ return function( instance ) return cwrap( ent:GetControllerCol( index ) ) end - --- Sets the position of the controller + --- Sets the local position of the controller -- @shared -- @param number index -- @param Vector position @@ -432,7 +432,7 @@ return function( instance ) ent:SetControllerLinkPos( index, vunwrap( pos ) ) end - --- Sets the angle of the controller + --- Sets the local angle of the controller -- @shared -- @param number index -- @param Angle angle From 249abaf9930b2951da71d788492aa78819be800a Mon Sep 17 00:00:00 2001 From: legokidlogan <26103433+legokidlogan@users.noreply.github.com> Date: Thu, 26 Feb 2026 11:33:21 -0600 Subject: [PATCH 4/4] Add e2 and sf getters for pos and ang --- .../core/custom/prop2mesh.lua | 16 +++++++++ lua/entities/sent_prop2mesh/init.lua | 20 +++++++++++ lua/starfall/libs_cl/prop2mesh.lua | 22 ++++++++++-- lua/starfall/libs_sv/prop2mesh.lua | 36 +++++++++++++++++-- 4 files changed, 90 insertions(+), 4 deletions(-) diff --git a/lua/entities/gmod_wire_expression2/core/custom/prop2mesh.lua b/lua/entities/gmod_wire_expression2/core/custom/prop2mesh.lua index 15bddac..c38f851 100644 --- a/lua/entities/gmod_wire_expression2/core/custom/prop2mesh.lua +++ b/lua/entities/gmod_wire_expression2/core/custom/prop2mesh.lua @@ -449,6 +449,22 @@ e2function vector4 entity:p2mGetColor(index) local info = this.prop2mesh_controllers[index] return {info.col.r, info.col.g, info.col.b, info.col.a} end +e2function vector entity:p2mGetPos(index) + if not checkvalid(self, this, nil, index, nil) then + return {0,0,0} + end + local linkpos = this.prop2mesh_controllers[index].linkpos + if not linkpos then return {0,0,0} end + return {linkpos.x, linkpos.y, linkpos.z} +end +e2function angle entity:p2mGetAng(index) + if not checkvalid(self, this, nil, index, nil) then + return {0,0,0} + end + local linkang = this.prop2mesh_controllers[index].linkang + if not linkang then return {0,0,0} end + return {linkang.p, linkang.y, linkang.r} +end e2function string entity:p2mGetMaterial(index) if not checkvalid(self, this, nil, index, nil) then return "" diff --git a/lua/entities/sent_prop2mesh/init.lua b/lua/entities/sent_prop2mesh/init.lua index b4f5264..482c05f 100644 --- a/lua/entities/sent_prop2mesh/init.lua +++ b/lua/entities/sent_prop2mesh/init.lua @@ -438,6 +438,16 @@ function ENT:SetControllerLinkPos(index, val) end end +function ENT:GetControllerLinkPos(index) + local info = self.prop2mesh_controllers[index] + if not info then return end + + local linkpos = info.linkpos + if not linkpos then return Vector() end + + return Vector(linkpos.x, linkpos.y, linkpos.z) +end + function ENT:SetControllerLinkAng(index, val) local info = self.prop2mesh_controllers[index] if (info and isangle(val)) then @@ -453,6 +463,16 @@ function ENT:SetControllerLinkAng(index, val) end end +function ENT:GetControllerLinkAng(index) + local info = self.prop2mesh_controllers[index] + if not info then return end + + local linkang = info.linkang + if not linkang then return Angle() end + + return Angle(linkang.p, linkang.y, linkang.r) +end + function ENT:SetControllerName(index, val) local info = self.prop2mesh_controllers[index] if (info and isstring(val)) and (info.name ~= val) then diff --git a/lua/starfall/libs_cl/prop2mesh.lua b/lua/starfall/libs_cl/prop2mesh.lua index 8db6867..038d244 100644 --- a/lua/starfall/libs_cl/prop2mesh.lua +++ b/lua/starfall/libs_cl/prop2mesh.lua @@ -29,8 +29,8 @@ return function( instance ) local p2m_library = instance.Libraries.p2m local owrap, ounwrap = instance.WrapObject, instance.UnwrapObject local ents_methods, wrap, unwrap = instance.Types.Entity.Methods, instance.Types.Entity.Wrap, instance.Types.Entity.Unwrap - local ang_meta, aunwrap = instance.Types.Angle, instance.Types.Angle.Unwrap - local vec_meta, vunwrap = instance.Types.Vector, instance.Types.Vector.Unwrap + local ang_meta, awrap, aunwrap = instance.Types.Angle, instance.Types.Angle.Wrap, instance.Types.Angle.Unwrap + local vec_meta, vwrap, vunwrap = instance.Types.Vector, instance.Types.Vector.Wrap, instance.Types.Vector.Unwrap local col_meta, cwrap, cunwrap = instance.Types.Color, instance.Types.Color.Wrap, instance.Types.Color.Unwrap local checkpermission = instance.player ~= SF.Superuser and SF.Permissions.check or function() end @@ -127,6 +127,15 @@ return function( instance ) ent:SetControllerPos(index, vunwrap(pos)) end + function ents_methods:p2mGetPos(index) + CheckType(self, ents_metatable) + local ent = unwrap(self) + local info = getControllerInfo(ent, index) + if not info then return end + + return vwrap(info.linkpos or Vector()) + end + function ents_methods:p2mSetAng(index, ang) CheckType(self, ents_metatable) local ent = unwrap(self) @@ -136,6 +145,15 @@ return function( instance ) ent:SetControllerAng(index, aunwrap(ang)) end + function ents_methods:p2mGetAng(index) + CheckType(self, ents_metatable) + local ent = unwrap(self) + local info = getControllerInfo(ent, index) + if not info then return end + + return awrap(info.linkang or Angle()) + end + function ents_methods:p2mSetMaterial(index, mat) CheckType(self, ents_metatable) CheckLuaType(mat, TYPE_STRING) diff --git a/lua/starfall/libs_sv/prop2mesh.lua b/lua/starfall/libs_sv/prop2mesh.lua index 987f391..bc4e77d 100644 --- a/lua/starfall/libs_sv/prop2mesh.lua +++ b/lua/starfall/libs_sv/prop2mesh.lua @@ -141,8 +141,8 @@ return function( instance ) local p2m_library = instance.Libraries.p2m local owrap, ounwrap = instance.WrapObject, instance.UnwrapObject local ents_methods, wrap, unwrap = instance.Types.Entity.Methods, instance.Types.Entity.Wrap, instance.Types.Entity.Unwrap - local ang_meta, aunwrap = instance.Types.Angle, instance.Types.Angle.Unwrap - local vec_meta, vunwrap = instance.Types.Vector, instance.Types.Vector.Unwrap + local ang_meta, awrap, aunwrap = instance.Types.Angle, instance.Types.Angle.Wrap, instance.Types.Angle.Unwrap + local vec_meta, vwrap, vunwrap = instance.Types.Vector, instance.Types.Vector.Wrap, instance.Types.Vector.Unwrap local col_meta, cwrap, cunwrap = instance.Types.Color, instance.Types.Color.Wrap, instance.Types.Color.Unwrap instance:AddHook( "initialize", function() @@ -432,6 +432,22 @@ return function( instance ) ent:SetControllerLinkPos( index, vunwrap( pos ) ) end + --- Gets the local position of the controller + -- @shared + -- @param number index + -- @return Vector local position + function ents_methods:p2mGetPos( index ) + CheckType( self, ents_metatable ) + local ent = unwrap( self ) + + CheckLuaType( index, TYPE_NUMBER ) + if not checkValid( instance.player, ent, _POS, index, nil ) then + return + end + + return vwrap( ent:GetControllerLinkPos( index ) ) + end + --- Sets the local angle of the controller -- @shared -- @param number index @@ -448,6 +464,22 @@ return function( instance ) ent:SetControllerLinkAng( index, aunwrap( ang ) ) end + --- Gets the local angle of the controller + -- @shared + -- @param number index + -- @return Angle local angle + function ents_methods:p2mGetAng( index ) + CheckType( self, ents_metatable ) + local ent = unwrap( self ) + + CheckLuaType( index, TYPE_NUMBER ) + if not checkValid( instance.player, ent, _ANG, index, nil ) then + return + end + + return awrap( ent:GetControllerLinkAng( index ) ) + end + --- Sets the color of the controller -- @shared -- @param number index