diff --git a/scripts/autorun/libs/debug.lua b/scripts/autorun/libs/debug.lua index 85bd44cb..51813be9 100644 --- a/scripts/autorun/libs/debug.lua +++ b/scripts/autorun/libs/debug.lua @@ -11,3 +11,15 @@ function debug.DrawRect(layerIndex, rect, lifetime) } }) end + +function debug.DrawText(layerIndex, text, lifetime) + match.CreateEntity({ + Type = "entity_debug_text", + LayerIndex = layerIndex, + Position = text:GetPosition(), + Properties= { + lifetime = lifetime or 0, + text = text + } + }) +end diff --git a/scripts/entities/debug_text.lua b/scripts/entities/debug_text.lua new file mode 100644 index 00000000..2d189b1b --- /dev/null +++ b/scripts/entities/debug_text.lua @@ -0,0 +1,26 @@ +RegisterClientScript() + +local entity = ScriptedEntity({ + IsNetworked = true, + Properties = { + {Name = "text", Type = PropertyType.string , shared = true}, + {Name = "Lifetime", Type = PropertyType.Float , shared = true} + } +}) + +if (not EDITOR) then + entity:On("init", function(self) + local lifetime = self:GetProperty("Lifetime") + if (lifetime > 0) then + self:SetLifeTime(lifetime) + end + end) +end + + +if (CLIENT) then + entity:On("init", function(self) + local text = self:GetProperty("text") + local color = {r=85 , g=15 , b= 15, a = 100 } + local textWidth = 5 + )