From 66ac81de65baa6828272844795fa5bfe48055c14 Mon Sep 17 00:00:00 2001 From: MayaTheShy Date: Wed, 25 Mar 2026 22:42:45 -0400 Subject: [PATCH] feat: optimize broadcastState function to conditionally include recipe tables based on config changes --- inventoryManager.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/inventoryManager.lua b/inventoryManager.lua index 24426f4..3f917a2 100644 --- a/inventoryManager.lua +++ b/inventoryManager.lua @@ -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 - payload.smeltable = cfg.SMELTABLE - payload.craftable = cfg.CRAFTABLE - state.configDirty = false + -- 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