--[[https://onecompiler.com/lua/4598gvsn3]] --[[ mas_code_interpreter.lua - Whole Workspace Parser Recursively searches the workspace for logic blocks. Displays opcode content and visual wire connectors. Read-only with respect to the source data. ]] local HttpService = game:GetService("HttpService") local TweenService = game:GetService("TweenService") local VLib = loadstring(game:HttpGet("https://raw.githubusercontent.com/IcantAffordSynapse/vaehzlib/refs/heads/main/src.lua"))() local Window = VLib:CreateWindow({ Title = "MAS Code Interpreter", ToggleKey = Enum.KeyCode.RightShift, Accent = Color3.fromRGB(94, 115, 255), }) local VisualsTab = Window:CreateTab({Name = "Visuals", Icon = "eye"}) local function isGeneratedVisual(inst) local current = inst while current and current ~= workspace do if current.Name == "MAS_VisualWires" or current.Name:match("^WireConnector_") or current.Name:match("^MAS_WireAttachment") then return true end current = current.Parent end return false end local function findAllBasePartsRecursive(root) local parts = {} local function search(inst) if isGeneratedVisual(inst) then return end if inst:IsA("BasePart") then table.insert(parts, inst) end local ok, children = pcall(function() return inst:GetChildren() end) if ok then for _, child in ipairs(children) do search(child) end end end search(root or workspace) return parts end local function getData(part) if not part:IsA("BasePart") then return nil end local inserted = part:FindFirstChild("Inserted") if not inserted or not inserted:IsA("StringValue") then return nil end local ok, data = pcall(function() return HttpService:JSONDecode(inserted.Value) end) if ok then return data end return nil end local function parse(data) if type(data) ~= "table" then return tostring(data) end local opcode = tonumber(data[1]) if opcode == 1 then return "TouchEvent: source=" .. tostring(data[2] or 0) .. " target=" .. tostring(data[3] or 0) elseif opcode == 5 then return "DeathEvent: target=" .. tostring(data[2] or 0) elseif opcode == 6 then return "SpawnEvent: target=" .. tostring(data[2] or 0) elseif opcode == 7 then return ("PromptEvent: promptClass=%s fire=%s act=%s obj=%s maxDist=%s hold=%s cooldown=%s key=%s") :format(tostring(data[2] or 0), tostring(data[3] or 0), tostring(data[4] or ""), tostring(data[5] or ""), tostring(data[6] or 0), tostring(data[7] or 0), tostring(data[8] or 0), tostring(data[9] or "")) elseif opcode == 8 then return "ChatEvent: target=" .. tostring(data[2] or 0) elseif opcode == 101 then return "CommandExecutor: '" .. tostring(data[2] or "") .. "' uid=" .. tostring(data[3] or 0) elseif opcode == 102 then return "Delayer: delay=" .. tostring(data[2] or 1) .. "s target=" .. tostring(data[3] or 0) elseif opcode == 103 then local steps = {} if type(data[2]) == "table" then for index, step in ipairs(data[2]) do if type(step) == "table" then steps[#steps + 1] = tostring(step[1] or "0") .. "s->" .. tostring(step[2] or 0) else steps[#steps + 1] = tostring(step) end end end return "Sequencer: count=" .. tostring(data[3] or #steps) .. " [" .. table.concat(steps, ", ") .. "]" elseif opcode == 104 then return ("RateLimiter: signalTo=%s maxUses=%s window=%ss") :format(tostring(data[2] or 0), tostring(data[3] or 1), tostring(data[4] or 1)) elseif opcode == 105 then return "Randomizer: true->" .. tostring(data[2] or 0) .. " false->" .. tostring(data[3] or 0) .. " chance=" .. tostring(data[4] or 50) .. "%" elseif opcode == 108 then local mode = tonumber(data[5]) or 0 local operators = { [0] = ">=", [1] = "<=", [2] = "==", [3] = "~=" } local operator = operators[mode] or "?" return ("LogicGate: %s %s %s uid=%s true->%s false->%s") :format(tostring(data[2] or "var"), operator, tostring(data[3] or "val"), tostring(data[4] or 0), tostring(data[6] or 0), tostring(data[7] or 0)) end return "Opcode " .. tostring(data[1]) end local function countClassIds(part) local classId = part:GetAttribute("ClassId") if classId == nil then return 0 end if type(classId) == "table" then local count = #classId if count > 0 then return count end for _ in pairs(classId) do count = count + 1 end return count end if type(classId) == "string" then local ok, decoded = pcall(function() return HttpService:JSONDecode(classId) end) if ok and type(decoded) == "table" then local count = #decoded if count > 0 then return count end for _ in pairs(decoded) do count = count + 1 end return count end end return 1 end local function getClassIds(part) local classId = part:GetAttribute("ClassId") if classId == nil then return {} end if type(classId) == "string" then local ok, decoded = pcall(function() return HttpService:JSONDecode(classId) end) if ok then classId = decoded end end local ids = {} if type(classId) == "table" then for _, id in pairs(classId) do ids[#ids + 1] = tostring(id) end else ids[1] = tostring(classId) end return ids end local function getPortCounts(part, data) local opcode = type(data) == "table" and tonumber(data[1]) local classIdCount = countClassIds(part) if opcode == 1 then return 1, 1 elseif opcode == 5 or opcode == 6 or opcode == 8 then return 0, 1 elseif opcode == 7 then return 0, 1 elseif opcode == 101 then return classIdCount, 0 elseif opcode == 102 or opcode == 104 then return classIdCount, 1 elseif opcode == 103 then local steps = type(data[2]) == "table" and #data[2] or tonumber(data[3]) or 0 return classIdCount, steps elseif opcode == 105 then return classIdCount, 2 elseif opcode == 108 then return classIdCount, 2 end return 0, 0 end local function getOutputSignalIds(data) if type(data) ~= "table" then return {} end local opcode = tonumber(data[1]) local ids = {} local function add(id) if id ~= nil then ids[#ids + 1] = tostring(id) end end if opcode == 1 then add(data[3]) elseif opcode == 5 or opcode == 6 or opcode == 8 then add(data[2]) elseif opcode == 7 then add(data[3]) elseif opcode == 102 then add(data[3]) elseif opcode == 103 and type(data[2]) == "table" then for _, step in ipairs(data[2]) do if type(step) == "table" then add(step[2]) end end elseif opcode == 104 then add(data[2]) elseif opcode == 105 then add(data[2]) add(data[3]) elseif opcode == 108 then add(data[6]) add(data[7]) end return ids end local function findMatchingInputs(parts) local sourcesBySignal = {} for _, part in ipairs(parts) do local data = getData(part) for _, signalId in ipairs(getOutputSignalIds(data)) do sourcesBySignal[signalId] = sourcesBySignal[signalId] or {} table.insert(sourcesBySignal[signalId], part) end end local matches = {} for _, part in ipairs(parts) do matches[part] = {} for _, signalId in ipairs(getClassIds(part)) do local sources = sourcesBySignal[signalId] matches[part][#matches[part] + 1] = { signalId = signalId, source = sources and sources[1] or nil, } end end return matches end local function getClassIdText(part) local classId = part:GetAttribute("ClassId") if classId == nil then return nil end return "ClassId=" .. tostring(classId) end local COLORS = { [1] = Color3.new(1, 0, 0), [5] = Color3.new(1, 0, 0), [6] = Color3.new(0, 1, 0), [7] = Color3.new(1, 1, 0), [8] = Color3.new(0, 0, 1), [101] = Color3.new(1, 1, 0), [102] = Color3.new(1, 0, 1), [103] = Color3.new(0, 1, 1), [104] = Color3.new(1, 0.6, 0), [105] = Color3.new(0.8, 0, 1), [108] = Color3.new(0, 1, 1) } local function createGui(part, titleText, description, color) local existing = part:FindFirstChild("LogicBlockGui") if existing then existing:Destroy() end local billboard = Instance.new("BillboardGui") billboard.Name = "LogicBlockGui" billboard.Adornee = part billboard.Size = UDim2.new(4, 0, 1, 0) billboard.StudsOffset = Vector3.new(0, 2, 0) billboard.AlwaysOnTop = true local frame = Instance.new("Frame") frame.Size = UDim2.new(1, 0, 1, 0) frame.BackgroundColor3 = color or COLORS[1] frame.BackgroundTransparency = 0.5 frame.Parent = billboard local title = Instance.new("TextLabel") title.Size = UDim2.new(1, 0, 0.5, 0) title.BackgroundTransparency = 1 title.TextColor3 = Color3.new(1, 1, 1) title.TextScaled = true title.Font = Enum.Font.Code title.Text = titleText title.Parent = frame local detail = Instance.new("TextLabel") detail.Size = UDim2.new(1, 0, 0.5, 0) detail.Position = UDim2.new(0, 0, 0.5, 0) detail.BackgroundTransparency = 1 detail.TextColor3 = Color3.new(1, 1, 1) detail.TextScaled = true detail.Font = Enum.Font.Code detail.Text = description detail.Parent = frame billboard.Parent = part end local function clearConnectors(parts) local oldWires = workspace:FindFirstChild("MAS_VisualWires") if oldWires then oldWires:Destroy() end for _, part in ipairs(parts) do for _, child in ipairs(part:GetChildren()) do if child.Name:match("^WireConnector_") or child.Name:match("^MAS_WireAttachment") then child:Destroy() end end end end local function createAnimatedLinks(parts, sequencerWiresEnabled) local folder = Instance.new("Folder") folder.Name = "MAS_VisualWires" folder.Parent = workspace local linkIndex = 0 for _, source in ipairs(parts) do local sourceData = getData(source) local sourceOpcode = type(sourceData) == "table" and tonumber(sourceData[1]) if sourceData and (sourceOpcode ~= 103 or sequencerWiresEnabled) then local outputIds = getOutputSignalIds(sourceData) for outputIndex, outputId in ipairs(outputIds) do local targetInputIndex = 0 for _, target in ipairs(parts) do if target ~= source then local targetData = getData(target) local targetOpcode = type(targetData) == "table" and tonumber(targetData[1]) if targetData and (targetOpcode ~= 103 or sequencerWiresEnabled) then for inputIndex, inputId in ipairs(getClassIds(target)) do if inputId == outputId then targetInputIndex = inputIndex linkIndex += 1 local _, sourceOutputCount = getPortCounts(source, sourceData) local sourceOffset = (outputIndex - (sourceOutputCount + 1) / 2) * 0.5 local sourceOutputPosition = source.Position + source.CFrame.RightVector * sourceOffset + Vector3.new(0, 0.2, 0) local targetInputPosition = target.Position - Vector3.new(0, 0.2, 0) local sourceAttachment = Instance.new("Attachment") sourceAttachment.Name = "MAS_WireAttachment_Out_" .. linkIndex sourceAttachment.Position = source.CFrame:PointToObjectSpace(sourceOutputPosition) sourceAttachment.Parent = source local targetAttachment = Instance.new("Attachment") targetAttachment.Name = "MAS_WireAttachment_In_" .. linkIndex targetAttachment.Position = target.CFrame:PointToObjectSpace(targetInputPosition) targetAttachment.Parent = target local beam = Instance.new("Beam") beam.Name = "SignalWire_" .. linkIndex beam.Attachment0 = sourceAttachment beam.Attachment1 = targetAttachment beam.Width0 = 0.08 beam.Width1 = 0.08 beam.FaceCamera = true beam.LightEmission = 1 beam.Color = ColorSequence.new(Color3.fromRGB(0, 255, 255)) beam.Parent = folder local marker = Instance.new("Part") marker.Name = "MovingArrow_" .. linkIndex marker.Shape = Enum.PartType.Ball marker.Size = Vector3.new(0.3, 0.3, 0.3) marker.Color = Color3.fromRGB(0, 255, 255) marker.Material = Enum.Material.Neon marker.Transparency = 0 marker.Anchored = true marker.CanCollide = false marker.CanQuery = false marker.CanTouch = false marker.Position = sourceAttachment.WorldPosition marker.Parent = folder local billboard = Instance.new("BillboardGui") billboard.Size = UDim2.fromOffset(56, 56) billboard.AlwaysOnTop = true billboard.Adornee = marker billboard.Parent = marker local arrow = Instance.new("TextLabel") arrow.Size = UDim2.fromScale(1, 1) arrow.BackgroundTransparency = 1 arrow.Text = "➤" arrow.TextColor3 = Color3.fromRGB(0, 255, 255) arrow.TextStrokeColor3 = Color3.new(0, 0, 0) arrow.TextStrokeTransparency = 0 arrow.TextScaled = true arrow.Font = Enum.Font.Code arrow.Parent = billboard task.spawn(function() local startTime = os.clock() local cyan = Color3.fromRGB(0, 255, 255) local green = Color3.fromRGB(80, 255, 120) while beam.Parent and marker.Parent and arrow.Parent do local phase = (math.sin((os.clock() - startTime) * math.pi / 1.5 - math.pi / 2) + 1) / 2 local color = cyan:Lerp(green, phase) beam.Color = ColorSequence.new(color) marker.Color = color arrow.TextColor3 = color task.wait(0.03) end end) task.spawn(function() while marker.Parent and sourceAttachment.Parent and targetAttachment.Parent do marker.Position = sourceAttachment.WorldPosition local tween = TweenService:Create(marker, TweenInfo.new(1.5, Enum.EasingStyle.Linear), {Position = targetAttachment.WorldPosition}) tween:Play() tween.Completed:Wait() end end) end end end end end end end end end local function createConnectors(parts, sequencerWiresEnabled) clearConnectors(parts) local matchingInputs = findMatchingInputs(parts) for _, part in ipairs(parts) do local data = getData(part) if data then local inputCount, outputCount = getPortCounts(part, data) local isSequencer = tonumber(data[1]) == 103 if isSequencer and not sequencerWiresEnabled then inputCount, outputCount = 0, 0 end for index = 1, outputCount do local output = Instance.new("Part") local opcode = tonumber(data[1]) if opcode == 103 then output.Name = "WireConnector_Step_" .. index elseif opcode == 105 or opcode == 108 then output.Name = "WireConnector_" .. (index == 1 and "True" or "False") else output.Name = "WireConnector_Out_" .. index end output.Size = Vector3.new(0.2, 0.2, 0.2) output.Color = Color3.fromRGB(50, 200, 50) output.Material = Enum.Material.Neon output.Anchored = true output.CanCollide = false output.CanQuery = false local horizontalOffset = (index - (outputCount + 1) / 2) * 0.5 output.Position = part.Position + part.CFrame.RightVector * horizontalOffset + Vector3.new(0, 0.2, 0) output.Parent = part end local partInputs = matchingInputs[part] or {} for index = 1, inputCount do local match = partInputs[index] local input = Instance.new("Part") input.Name = "WireConnector_In_" .. index input.Shape = Enum.PartType.Ball input.Size = Vector3.new(0.4, 0.4, 0.4) input.Color = Color3.fromRGB(0, 255, 255) input.Material = Enum.Material.Neon input.Anchored = true input.CanCollide = false input.CanQuery = false input.Position = part.Position - Vector3.new(0, 0.2, 0) if match then input:SetAttribute("SignalId", match.signalId) input:SetAttribute("Matched", match.source ~= nil) if match.source then input:SetAttribute("SourceName", match.source:GetFullName()) end end input.Parent = part end end end createAnimatedLinks(parts, sequencerWiresEnabled) end local function setVisuals(wiresEnabled, guisEnabled, sequencerWiresEnabled) local parts = findAllBasePartsRecursive() clearConnectors(parts) if wiresEnabled then createConnectors(parts, sequencerWiresEnabled) end for _, part in ipairs(parts) do local existingGui = part:FindFirstChild("LogicBlockGui") if existingGui then existingGui:Destroy() end if guisEnabled then local data = getData(part) if data then local description = parse(data) local classIdText = getClassIdText(part) if classIdText then description = description .. "\n" .. classIdText end createGui(part, part.Name, description, COLORS[tonumber(data[1])] or Color3.new(1, 1, 1)) end end end end masInterpreter = {} masInterpreter.toggle = setVisuals local wiresEnabled = true local guisEnabled = true local sequencerWiresEnabled = true VisualsTab:CreateToggle({ Name = "Wire connectors", Default = wiresEnabled, Callback = function(enabled) wiresEnabled = enabled setVisuals(wiresEnabled, guisEnabled, sequencerWiresEnabled) end, }) VisualsTab:CreateToggle({ Name = "Logic block labels", Default = guisEnabled, Callback = function(enabled) guisEnabled = enabled setVisuals(wiresEnabled, guisEnabled, sequencerWiresEnabled) end, }) VisualsTab:CreateToggle({ Name = "Sequencer wires", Default = sequencerWiresEnabled, Callback = function(enabled) sequencerWiresEnabled = enabled setVisuals(wiresEnabled, guisEnabled, sequencerWiresEnabled) end, }) setVisuals(wiresEnabled, guisEnabled, sequencerWiresEnabled) local refreshVersion = 0 local function scheduleVisualRefresh() refreshVersion += 1 local scheduledVersion = refreshVersion -- Wait until a burst of game-side edits has finished before rebuilding. task.delay(0.6, function() if scheduledVersion ~= refreshVersion then return end local ok, err = pcall(function() setVisuals(wiresEnabled, guisEnabled, sequencerWiresEnabled) end) if not ok then warn("[MAS] Visual refresh failed: " .. tostring(err)) -- A transient workspace edit can interrupt a rebuild after old visuals -- have been cleared. Retry once if no newer edit has superseded it. task.delay(0.5, function() if scheduledVersion ~= refreshVersion then return end local retryOk, retryErr = pcall(function() setVisuals(wiresEnabled, guisEnabled, sequencerWiresEnabled) end) if not retryOk then warn("[MAS] Visual refresh retry failed: " .. tostring(retryErr)) end end) end end) end local watchedParts = setmetatable({}, {__mode = "k"}) local watchedInsertedValues = setmetatable({}, {__mode = "k"}) local function watchInsertedValue(inserted) if isGeneratedVisual(inserted) or watchedInsertedValues[inserted] then return end watchedInsertedValues[inserted] = true inserted.Changed:Connect(scheduleVisualRefresh) end local function watchPart(part) if isGeneratedVisual(part) or watchedParts[part] then return end watchedParts[part] = true part:GetAttributeChangedSignal("ClassId"):Connect(scheduleVisualRefresh) local inserted = part:FindFirstChild("Inserted") if inserted and inserted:IsA("StringValue") then watchInsertedValue(inserted) end end for _, instance in ipairs(workspace:GetDescendants()) do if instance:IsA("BasePart") then watchPart(instance) elseif instance.Name == "Inserted" and instance:IsA("StringValue") and instance.Parent and instance.Parent:IsA("BasePart") then watchInsertedValue(instance) end end workspace.DescendantAdded:Connect(function(instance) if isGeneratedVisual(instance) then return end if instance:IsA("BasePart") then watchPart(instance) if getData(instance) or instance:GetAttribute("ClassId") ~= nil then scheduleVisualRefresh() end elseif instance.Name == "Inserted" and instance:IsA("StringValue") and instance.Parent and instance.Parent:IsA("BasePart") then watchInsertedValue(instance) scheduleVisualRefresh() end end) workspace.DescendantRemoving:Connect(function(instance) if isGeneratedVisual(instance) then return end if instance:IsA("BasePart") then if getData(instance) or instance:GetAttribute("ClassId") ~= nil then scheduleVisualRefresh() end elseif instance.Name == "Inserted" and instance:IsA("StringValue") then scheduleVisualRefresh() end end) local count = 0 for _, part in ipairs(findAllBasePartsRecursive()) do if getData(part) then count = count + 1 end end print("MAS: displayed " .. count .. " logic blocks") print("MAS: wire connectors created")