Is there a pre-made function to do that, and if not how to do it ?
Thanks
Check garrysmod\gamemodes\sandbox\gamemode\editor_player.lua, the dmodelpanel in question is mdl to get you on the right path.
I'm getting this error :
[ERROR] addons/gabwiel_has/lua/autorun/client/cl_shop.lua:116: bad argument #1 to 'SetAngles' (Angle expected, got nil)
Using this code :
function ModelPanel:DragMousePress()
self.PressX, self.PressY = gui.MousePos()
self.Pressed = true
end
function ModelPanel:DragMouseRelease()
self.Pressed = false
end
function ModelPanel:LayoutEntity( ent )
if ( self.Pressed ) then
local mx, my = gui.MousePos()
self.Angles = self.Angles - Angle( ( self.PressY or my ) - my, ( self.PressX or mx ) - mx, 0 )
self.PressX, self.PressY = gui.MousePos()
end
ent:SetAngles( self.Angles ) <- The error is here
end
self.Angles is nil because it is not being set at the time of the method running(it's only set for the first time when self.Pressed == true), You need to add
mdl.Angles = Angle( 0, 0, 0 )
where you initialize your DModelPanel, so that the first update doesn't see mdl.Angles as nil. This is done as seen in garrysmod\gamemodes\sandbox\gamemode\editor_player.lua
Thanks !
Sorry, you need to Log In to post a reply to this thread.