Skip to content

Commit 0edcab3

Browse files
author
thegrb93
authored
Merge pull request #1958 from wiremod/text-screen-fix
Limited text screen size and rate
2 parents db3ba0a + 37c1188 commit 0edcab3

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lua/entities/gmod_wire_textscreen.lua

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ function ENT:Initialize()
217217
self:SetMoveType( MOVETYPE_VPHYSICS )
218218
self:SetSolid( SOLID_VPHYSICS )
219219

220+
self.doSendText = false
221+
self.doSendConfig = false
220222
self.Inputs = WireLib.CreateSpecialInputs(self, { "String", "Font", "FGColor", "BGColor" }, { "STRING", "STRING", "VECTOR", "VECTOR" })
221223
self:InitializeShared()
222224
end
@@ -230,14 +232,13 @@ function ENT:Setup(DefaultText, chrPerLine, textJust, valign, tfont, fgcolor, bg
230232
self.tfont = tfont or "Arial"
231233
self:SendConfig()
232234

233-
self.text = DefaultText or ""
234-
self:TriggerInput("String", self.text)
235+
self:TriggerInput("String", DefaultText or "")
235236
end
236237

237238
function ENT:TriggerInput(iname, value)
238239
if iname == "String" then
239-
self.text = tostring(value)
240-
self:SendText()
240+
self.text = string.sub(tostring(value), 1, 1024)
241+
self.doSendText = true
241242
elseif iname == "Font" then
242243
self.tfont = tostring(value)
243244
self.doSendConfig = true
@@ -255,6 +256,7 @@ local function formatText(text)
255256
end
256257

257258
function ENT:SendText(ply)
259+
self.doSendText = false
258260
WireLib.netStart(self)
259261
net.WriteBit(false) -- Sending Text
260262
net.WriteString(formatText(self.text))
@@ -265,10 +267,13 @@ function ENT:Think()
265267
if self.doSendConfig then
266268
self:SendConfig()
267269
end
270+
if self.doSendText then
271+
self:SendText()
272+
end
268273
end
269274

270275
function ENT:SendConfig(ply)
271-
self.doSendConfig = nil
276+
self.doSendConfig = false
272277
WireLib.netStart(self)
273278
net.WriteBit(true) -- Sending Config
274279
net.WriteUInt(self.chrPerLine, 4)

0 commit comments

Comments
 (0)