Skip to content
Merged
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
37 changes: 16 additions & 21 deletions lua/entities/gmod_wire_expression2/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,26 @@ end

local fixDefault = E2Lib.fixDefault

function ENT:UpdateOverlay(clear)
function ENT:PrepareOverlayData()
local selfTbl = self:GetTable()
local context = selfTbl.context

if clear then
self:SetOverlayData({
txt = "(none)",
error = selfTbl.error,
prfbench = 0,
prfcount = 0,
timebench = 0
})
else
local context = selfTbl.context

if context then
self:SetOverlayData({
txt = selfTbl.name, -- name/error
error = selfTbl.error, -- error bool
prfbench = context.prfbench,
prfcount = context.prfcount,
timebench = context.timebench
})
else
self:SetOverlayData({
txt = "(none)",
error = selfTbl.error,
prfbench = 0,
prfcount = 0,
timebench = 0
})
end
end

Expand All @@ -83,7 +82,6 @@ function ENT:Initialize()
self.Outputs = WireLib.CreateOutputs(self, {})

self.error = true
self:UpdateOverlay(true)
self:SetColor(Color(255, 0, 0, self:GetColor().a))

local owner = self.player
Expand Down Expand Up @@ -132,8 +130,6 @@ function ENT:UpdatePerf(selfTbl)

if context.prfcount < 0 then context.prfcount = 0 end

self:UpdateOverlay()

context.prf = 0
context.time = 0
end
Expand All @@ -144,6 +140,7 @@ function ENT:Execute(script, context)
script = script or selfTbl.script
if not context or selfTbl.error or context.resetting then return end

local bench = SysTime()
self:PCallHook("preexecute")

context.stackdepth = context.stackdepth + 1
Expand All @@ -152,8 +149,6 @@ function ENT:Execute(script, context)
self:Error("Expression 2 (" .. selfTbl.name .. "): stack quota exceeded", "stack quota exceeded")
end

local bench = SysTime()

local ok, msg = pcall(script, context)

if not ok then
Expand Down Expand Up @@ -204,7 +199,8 @@ function ENT:Execute(script, context)
end
end

context.time = context.time + (SysTime() - bench)
local bench_end = SysTime()
context.time = context.time + (bench_end - bench)

if context.prfcount + context.prf - e2_softquota > e2_hardquota then
local trace = context.trace
Expand Down Expand Up @@ -274,7 +270,8 @@ function ENT:ExecuteEvent(evt, args)
end
end

context.time = context.time + (SysTime() - bench)
local bench_end = SysTime()
context.time = context.time + (bench_end - bench)

if context.prfcount + context.prf - e2_softquota > e2_hardquota then
local trace = context.trace
Expand All @@ -299,8 +296,6 @@ function ENT:Think()

if context.prfcount < 0 then context.prfcount = 0 end

self:UpdateOverlay()

context.prf = 0
context.time = 0

Expand Down
Loading