Merge pull request #52 from marchc1/controller-setpos-setang

Individual controller position & angle control
This commit is contained in:
shadowscion 2023-07-18 11:33:18 -05:00 committed by GitHub
commit 0460b6f7df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 0 deletions

View File

@ -479,6 +479,18 @@ end
]]
__e2setcost(10)
e2function void entity:p2mSetPos(number index, vector pos)
if checkvalid(self, this, _POS, index) then
this:SetControllerLinkPos(index, Vector(pos[1], pos[2], pos[3]))
end
end
e2function void entity:p2mSetAng(number index, angle ang)
if checkvalid(self, this, _ANG, index) then
this:SetControllerLinkAng(index, Angle(ang[1], ang[2], ang[3]))
end
end
e2function void entity:p2mSetAlpha(number index, number alpha)
if checkvalid(self, this, _ALPHA, index) then
this:SetControllerAlpha(index, alpha)

View File

@ -390,6 +390,36 @@ return function( instance )
return cwrap( ent:GetControllerCol( index ) )
end
--- Sets the position of the controller
-- @param number index
-- @param Vector position
function ents_methods:p2mSetPos( index, pos )
CheckType( self, ents_metatable )
local ent = unwrap( self )
CheckLuaType( index, TYPE_NUMBER )
if not checkValid( instance.player, ent, _POS, index, nil ) then
return
end
ent:SetControllerLinkPos( index, vunwrap( pos ) )
end
--- Sets the angle of the controller
-- @param number index
-- @param Angle angle
function ents_methods:p2mSetAng( index, ang )
CheckType( self, ents_metatable )
local ent = unwrap( self )
CheckLuaType( index, TYPE_NUMBER )
if not checkValid( instance.player, ent, _ANG, index, nil ) then
return
end
ent:SetControllerLinkAng( index, aunwrap( ang ) )
end
--- Sets the color of the controller
-- @param number index
-- @param Color color