How to rotate text in gmod?

Hi, i’m trying to do what they did here:

http://forum.facepunch.com/showthread.php?t=1495061

Heres the code.

[LUA]
include(‘shared.lua’)

function ENT:Draw()
self:DrawModel()
local sSetTextPos = surface.SetTextPos;
local sDrawText = surface.DrawText;
local cPushModelMatrix = cam.PushModelMatrix;
local cPopModelMatrix = cam.PopModelMatrix;

local mat = Matrix();
local matAng = Angle(0, 0, 0);
local matTrans = Vector(0, 0, 0);
local matScale = Vector(0, 0, 0);

local function drawSpecialText(txt, posX, posY, scaleX, scaleY, ang)
matAng.y = ang;
mat:SetAngle(matAng);
matTrans.x = posX;
matTrans.y = posY;
mat:SetTranslation(matTrans);
matScale.x = scaleX;
matScale.y = scaleY;
mat:Scale(matScale);
sSetTextPos(0, 0);
cPushModelMatrix(mat);
sDrawText(txt);
cPopModelMatrix();
end
[/LUA]

Error by the way.

[ERROR] addons/bodypackerv7/lua/entities/entity_bodypacker/cl_init.lua:16: attempt to call method ‘SetAngle’ (a nil value)

  1. drawSpecialText - addons/bodypackerv7/lua/entities/entity_bodypacker/cl_init.lua:16
  2. unknown - addons/bodypackerv7/lua/entities/entity_bodypacker/cl_init.lua:31

I don’t get how the code works…

Its SetAngles

Just tried this.

[LUA]
include(‘shared.lua’)

function ENT:Draw()
self:DrawModel()
local sSetTextPos = surface.SetTextPos;
local sDrawText = surface.DrawText;
local cPushModelMatrix = cam.PushModelMatrix;
local cPopModelMatrix = cam.PopModelMatrix;

local mat = Matrix();
local matAng = Angle(0, 0, 0);
local matTrans = Vector(0, 0, 0);
local matScale = Vector(0, 0, 0);
local function drawSpecialText(txt, posX, posY, scaleX, scaleY, ang)
		matAng.y = ang;
		mat:SetAngle(matAng);
		matTrans.x = posX;
		matTrans.y = posY;
		mat:SetTranslation(matTrans);
		matScale.x = scaleX;
		matScale.y = scaleY;
		mat:Scale(matScale);
		sSetTextPos(0, 0);
		cPushModelMatrix(mat);
		sDrawText(hithere);
		cPopModelMatrix();

end
cam.Start3D2D(matTrans,MatAng,1)
draw.DrawText( “Hello there!”, “TargetID”,0,0, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER )
cam.End3D2D()
end
[/LUA]

Crashed the game. :confused:

[editline]27th November 2016[/editline]

I know im doing something cause i always do something wrong. :stuck_out_tongue:
:goodjob:

Dude, you still are using SetAngle, not SetAngles

You dont need to define your local function inside ENT:Draw()

Fixed. ty guys. :slight_smile: