Skip to content

Commit

Permalink
Add text length limit to egp objects (#3269)
Browse files Browse the repository at this point in the history
  • Loading branch information
thegrb93 authored Feb 18, 2025
1 parent dbed3cf commit 03162ba
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lua/entities/gmod_wire_expression2/core/egpfunctions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,15 @@ end
--------------------------------------------------------
e2function egpobject wirelink:egpText( number index, string text, vector2 pos )
if (!EGP:IsAllowed( self, this )) then return NULL_EGPOBJECT end
if #text>256 then text = string.sub(text, 1, 256) end
local bool, obj = egp_create("Text", { index = index, text = text, x = pos[1], y = pos[2] }, this)
if (bool) then EGP:DoAction( this, self, "SendObject", obj ) Update(self,this) end
return obj
end

e2function egpobject wirelink:egpTextLayout( number index, string text, vector2 pos, vector2 size )
if (!EGP:IsAllowed( self, this )) then return NULL_EGPOBJECT end
if #text>256 then text = string.sub(text, 1, 256) end
local bool, obj = egp_create("TextLayout", { index = index, text = text, x = pos[1], y = pos[2], w = size[1], h = size[2] }, this)
if (bool) then EGP:DoAction( this, self, "SendObject", obj ) Update(self,this) end
return obj
Expand All @@ -193,6 +195,7 @@ __e2setcost(10)
----------------------------
e2function void wirelink:egpSetText( number index, string text )
if (!EGP:IsAllowed( self, this )) then return end
if #text>256 then text = string.sub(text, 1, 256) end
local bool, k, v = hasObject(this, index)
if (bool) then
if v:EditObject({ text = text }) then EGP:DoAction( this, self, "SendObject", v ) Update(self,this) end
Expand Down

0 comments on commit 03162ba

Please sign in to comment.