feat: optimize broadcastState function to conditionally include recipe tables based on config changes

This commit is contained in:
MayaTheShy
2026-03-25 22:42:45 -04:00
parent ea29136f25
commit 66ac81de65

View File

@@ -39,7 +39,6 @@ local ok, err = xpcall(function()
-- Override dofile to load modules into our _ENV so they inherit
-- Opus's require/package (CC:Tweaked dofile uses _G instead).
local _ccDofile = dofile
local function dofile(path) -- luacheck: ignore
local fn, err = loadfile(path, nil, _ENV)
if fn then return fn()
@@ -148,9 +147,12 @@ local function broadcastState()
-- Keep ctx in sync so display.lua can check ctx.craftTurtleOk directly
ctx.craftTurtleOk = payload.craftTurtleOk
-- Only include recipe tables when config has changed (they're large).
if state.configDirty then
payload.smeltable = cfg.SMELTABLE
payload.craftable = cfg.CRAFTABLE
state.configDirty = false
end
ctx.networkModem.transmit(cfg.BROADCAST_CHANNEL, cfg.ORDER_CHANNEL, payload)
state.lastBroadcastVersion = state.stateVersion