Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lua/entities/gmod_wire_digitalscreen/cl_init.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include("shared.lua")


local dsRate = GetConVar("wire_digitalscreen_rate")

function ENT:SendData()
net.Start("wire_interactiveprop_action")
Expand Down Expand Up @@ -143,7 +143,7 @@ end

function ENT:Think()
if self.buffer[1] ~= nil then
local maxtime = SysTime() + RealFrameTime() * 0.05 -- do more depending on client FPS. Higher fps = more work
local maxtime = SysTime() + RealFrameTime() * (0.05*dsRate:GetFloat()) -- do more depending on client FPS. Higher fps = more work

while SysTime() < maxtime and self.buffer[1] do
if not self.co or coroutine.status(self.co) == "dead" then
Expand Down Expand Up @@ -320,7 +320,7 @@ function ENT:Draw(flags)

if self.NeedRefresh then
self.NeedRefresh = false
local maxtime = SysTime() + RealFrameTime() * 0.01
local maxtime = SysTime() + RealFrameTime() * (0.01*dsRate:GetFloat())

self.GPU:RenderToGPU(function()
local idx = 0
Expand Down
17 changes: 15 additions & 2 deletions lua/entities/gmod_wire_digitalscreen/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ DEFINE_BASECLASS( "base_wire_entity" )

ENT.WireDebugName = "DigitalScreen"

local dsRate = CreateConVar("wire_digitalscreen_rate", 1, { FCVAR_REPLICATED, FCVAR_ARCHIVE })
local dsRateValue = dsRate:GetFloat()

function ENT:InitInteractive()
local model = self:GetModel()
Expand Down Expand Up @@ -128,6 +130,7 @@ function ENT:ReadCell(Address)
Address = math.floor(Address)
if Address < 0 then return nil end
if Address >= 1048577 then return nil end
if (Address==1048576) then return dsRateValue end -- report its rate

return self.Memory[Address] or 0
end
Expand Down Expand Up @@ -170,9 +173,19 @@ end
----------------------------------------------------
-- Processing limiters and global bandwidth limiters
local maxProcessingTime = engine.TickInterval() * 0.9
local defaultMaxBandwidth = 10000 -- 10k per screen max limit - is arbitrary. needs to be smaller than the global limit.
local defaultMaxGlobalBandwidth = 20000 -- 20k is a good global limit in my testing. higher than that seems to cause issues

local defaultMaxBandwidth = 100000 * dsRateValue -- 10k per screen max limit - is arbitrary. needs to be smaller than the global limit.
local defaultMaxGlobalBandwidth = 200000 * dsRateValue -- 20k is a good global limit in my testing. higher than that seems to cause issues
local maxBandwidth = defaultMaxBandwidth

local function updateBW()
dsRateValue = dsRate:GetFloat()

@thegrb93 thegrb93 Jul 31, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't get the updated value. Need to use function params. updateBW(cvar, old, new) new = tonumber(new) or default

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:Get* functions already return updated value in change callbacks

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did gmod devs fix that? Cuz I did a refactor recently to get around that issue.


defaultMaxBandwidth = 100000 * dsRateValue
defaultMaxGlobalBandwidth = 200000 * dsRateValue
end
cvars.AddChangeCallback("wire_digitalscreen_rate", updateBW)

local globalBandwidthLookup = {}
local function calcGlobalBW()
maxBandwidth = defaultMaxGlobalBandwidth
Expand Down
Loading