diff --git a/example/src/client/systems/roombasHurt.luau b/example/src/client/systems/roombasHurt.luau index f8647ae4..1184e3d5 100644 --- a/example/src/client/systems/roombasHurt.luau +++ b/example/src/client/systems/roombasHurt.luau @@ -5,7 +5,7 @@ local Matter = require(ReplicatedStorage.Lib.Matter) local function roombasHurt(world) for _, _, model in world:query(Components.Roomba, Components.Model) do - for _, part in Matter.useEvent(model.model.PrimaryPart, "Touched") do + for _, part in Matter.useEvent(model.PrimaryPart, "Touched") do local touchedModel = part:FindFirstAncestorWhichIsA("Model") if not touchedModel then continue diff --git a/example/src/client/systems/spinSpinners.luau b/example/src/client/systems/spinSpinners.luau index 7170f4e7..03b23c21 100644 --- a/example/src/client/systems/spinSpinners.luau +++ b/example/src/client/systems/spinSpinners.luau @@ -11,11 +11,11 @@ local function spinSpinners(world, _, ui) local randomize = ui.button("Randomize colors!"):clicked() for _, model in world:query(Components.Model, Components.Spinner) do - model.model.PrimaryPart.CFrame = model.model.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(5), 0) - model.model.PrimaryPart.Transparency = transparency + model.PrimaryPart.CFrame = model.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(5), 0) + model.PrimaryPart.Transparency = transparency if randomize then - model.model.PrimaryPart.BrickColor = BrickColor.random() + model.PrimaryPart.BrickColor = BrickColor.random() end end end diff --git a/example/src/server/systems/mothershipsSpawnRoombas.luau b/example/src/server/systems/mothershipsSpawnRoombas.luau index 79890837..f2f0dabd 100644 --- a/example/src/server/systems/mothershipsSpawnRoombas.luau +++ b/example/src/server/systems/mothershipsSpawnRoombas.luau @@ -6,7 +6,7 @@ local function mothershipsSpawnRoombas(world) for id, model, lasering, transform in world:query(Components.Model, Components.Lasering, Components.Transform, Components.Mothership) do - model.model.Beam.Transparency = 1 - lasering.remainingTime + model.Beam.Transparency = 1 - lasering.remainingTime lasering = lasering:patch({ remainingTime = lasering.remainingTime - Matter.useDeltaTime(), diff --git a/example/src/server/systems/playersAreTargets.luau b/example/src/server/systems/playersAreTargets.luau index cf80b8cc..b8411f4d 100644 --- a/example/src/server/systems/playersAreTargets.luau +++ b/example/src/server/systems/playersAreTargets.luau @@ -6,12 +6,7 @@ local Matter = require(ReplicatedStorage.Lib.Matter) local function playersAreTargets(world) for _, player in ipairs(Players:GetPlayers()) do for _, character in Matter.useEvent(player, "CharacterAdded") do - world:spawn( - Components.Target(), - Components.Model({ - model = character, - }) - ) + world:spawn(Components.Target(), Components.Model(character)) end end diff --git a/example/src/server/systems/removeMissingModels.luau b/example/src/server/systems/removeMissingModels.luau index 349f9dd7..6ec5b73c 100644 --- a/example/src/server/systems/removeMissingModels.luau +++ b/example/src/server/systems/removeMissingModels.luau @@ -4,21 +4,21 @@ local Matter = require(ReplicatedStorage.Lib.Matter) local function removeMissingModels(world) for id, model in world:query(Components.Model) do - for _ in Matter.useEvent(model.model, "AncestryChanged") do - if model.model:IsDescendantOf(game) == false then + for _ in Matter.useEvent(model, "AncestryChanged") do + if model:IsDescendantOf(game) == false then world:remove(id, Components.Model) break end end - if not model.model.PrimaryPart then + if not model.PrimaryPart then world:remove(id, Components.Model) end end for _id, modelRecord in world:queryChanged(Components.Model) do if modelRecord.new == nil then - if modelRecord.old and modelRecord.old.model then - modelRecord.old.model:Destroy() + if modelRecord.old then + modelRecord.old:Destroy() end end end diff --git a/example/src/server/systems/roombasMove.luau b/example/src/server/systems/roombasMove.luau index e5498856..a9763433 100644 --- a/example/src/server/systems/roombasMove.luau +++ b/example/src/server/systems/roombasMove.luau @@ -4,7 +4,7 @@ local Components = require(ReplicatedStorage.Shared.components) local function roombasMove(world) local targets = {} for _, model in world:query(Components.Model, Components.Target) do - table.insert(targets, model.model.PrimaryPart.CFrame.p) + table.insert(targets, model.PrimaryPart.CFrame.p) end for _, _, charge, model in world:query(Components.Roomba, Components.Charge, Components.Model) do @@ -13,7 +13,7 @@ local function roombasMove(world) end local closestPosition, closestDistance - local currentPosition = model.model.PrimaryPart.CFrame.p + local currentPosition = model.PrimaryPart.CFrame.p for _, target in ipairs(targets) do local distance = (currentPosition - target).magnitude @@ -24,7 +24,7 @@ local function roombasMove(world) end if closestPosition then - local body = model.model.Roomba + local body = model.Roomba local force = body:GetMass() * 20 if closestDistance < 4 then diff --git a/example/src/server/systems/spawnMotherships.luau b/example/src/server/systems/spawnMotherships.luau index e6d464fe..c14805ad 100644 --- a/example/src/server/systems/spawnMotherships.luau +++ b/example/src/server/systems/spawnMotherships.luau @@ -28,12 +28,7 @@ local function spawnMotherships(world) model.Parent = workspace model.PrimaryPart:SetNetworkOwner(nil) - world:insert( - id, - Components.Model({ - model = model, - }) - ) + world:insert(id, Components.Model(model)) end for id, mothership, transform in @@ -58,7 +53,7 @@ local function spawnMotherships(world) end for _, mothership, model in world:query(Components.Mothership, Components.Model):without(Components.Lasering) do - model.model.Roomba.AlignPosition.Position = mothership.goal + model.Roomba.AlignPosition.Position = mothership.goal end end diff --git a/example/src/server/systems/spawnRoombas.luau b/example/src/server/systems/spawnRoombas.luau index 95abe9f4..c286c35a 100644 --- a/example/src/server/systems/spawnRoombas.luau +++ b/example/src/server/systems/spawnRoombas.luau @@ -7,12 +7,7 @@ local function spawnRoombas(world) model.Parent = workspace model.PrimaryPart:SetNetworkOwner(nil) - world:insert( - id, - Components.Model({ - model = model, - }) - ) + world:insert(id, Components.Model(model)) end end diff --git a/example/src/server/systems/updateTransforms.luau b/example/src/server/systems/updateTransforms.luau index 3ce49315..c55b9ac3 100644 --- a/example/src/server/systems/updateTransforms.luau +++ b/example/src/server/systems/updateTransforms.luau @@ -16,7 +16,7 @@ local function updateTransforms(world) end if transformRecord.new and not transformRecord.new.doNotReconcile then - model.model:SetPrimaryPartCFrame(transformRecord.new.cframe) + model:SetPrimaryPartCFrame(transformRecord.new.cframe) end end @@ -33,18 +33,18 @@ local function updateTransforms(world) end if modelRecord.new then - modelRecord.new.model:SetPrimaryPartCFrame(transform.cframe) + modelRecord.new:SetPrimaryPartCFrame(transform.cframe) end end -- Update Transform on unanchored Models for id, model, transform in world:query(Components.Model, Components.Transform) do - if model.model.PrimaryPart.Anchored then + if model.PrimaryPart.Anchored then continue end local existingCFrame = transform.cframe - local currentCFrame = model.model.PrimaryPart.CFrame + local currentCFrame = model.PrimaryPart.CFrame -- Despawn models that fall into the void if currentCFrame.Y < -400 then diff --git a/example/src/shared/setupTags.luau b/example/src/shared/setupTags.luau index 91fefab8..d4c65f73 100644 --- a/example/src/shared/setupTags.luau +++ b/example/src/shared/setupTags.luau @@ -10,9 +10,7 @@ local function setupTags(world) local function spawnBound(instance, component) local id = world:spawn( component(), - Components.Model({ - model = instance, - }), + Components.Model(instance), Components.Transform({ cframe = instance.PrimaryPart.CFrame, }) diff --git a/example/src/shared/start.luau b/example/src/shared/start.luau index 07df6552..0d2a383e 100644 --- a/example/src/shared/start.luau +++ b/example/src/shared/start.luau @@ -19,8 +19,7 @@ local function start(containers) end local model = world:get(id, components.Model) - - return model and model.model or nil + return model end local loop = Matter.Loop.new(world, state, debugger:getWidgets()) diff --git a/example/src/shared/systems/updateModelAttribute.luau b/example/src/shared/systems/updateModelAttribute.luau index fbad30fc..18201db6 100644 --- a/example/src/shared/systems/updateModelAttribute.luau +++ b/example/src/shared/systems/updateModelAttribute.luau @@ -7,7 +7,7 @@ local name = RunService:IsServer() and "serverEntityId" or "clientEntityId" local function updateModelAttribute(world) for id, record in world:queryChanged(Components.Model) do if record.new then - record.new.model:SetAttribute(name, id) + record.new:SetAttribute(name, id) end end end diff --git a/lib/component.luau b/lib/Component.luau similarity index 53% rename from lib/component.luau rename to lib/Component.luau index c257ab12..1e9e7504 100644 --- a/lib/component.luau +++ b/lib/Component.luau @@ -9,10 +9,8 @@ local merge = require(script.Parent.immutable).merge In the docs, the terms "Component" and "ComponentInstance" are used: - **"Component"** refers to the base class of a specific type of component you've created. This is what [`Matter.component`](/api/Matter#component) returns. - - **"Component Instance"** refers to an actual piece of data that can exist on an entity. - The metatable of a component instance table is its respective Component table. - - Component instances are *plain-old data*: they do not contain behaviors or methods. + - **"Component Instance"** refers to what encapsulates data you pass into a Component. + You only really interact with a [TableComponentInstance](/api/TableComponentInstance). Since component instances are immutable, one helper function exists on all component instances, `patch`, which allows reusing data from an existing component instance to make up for the ergonomic loss of mutations. @@ -20,105 +18,107 @@ local merge = require(script.Parent.immutable).merge --[=[ @within Component - @type ComponentInstance {} - - The `ComponentInstance` type refers to an actual piece of data that can exist on an entity. - The metatable of the component instance table is set to its particular Component table. + @type ComponentInstance TableComponentInstance | ValueComponentInstance +]=] - A component instance can be created by calling the Component table: +--[=[ + @within Component + @type ValueComponentInstance {} - ```lua - -- Component: - local MyComponent = Matter.component("My component") + If you pass anything other than a table into a Component, then you will get a ValueComponentInstance back. + Unlike a [TableComponentInstance](/api/TableComponentInstance), you shouldn't need to interact with this + and it will not be passed back to you in queries. - -- component instance: - local myComponentInstance = MyComponent({ - some = "data" - }) + This is strictly used for insertions. +]=] - print(getmetatable(myComponentInstance) == MyComponent) --> true - ``` +--[=[ + @class TableComponentInstance ]=] -- This is a special value we set inside the component's metatable that will allow us to detect when -- a Component is accidentally inserted as a Component Instance. -- It should not be accessible through indexing into a component instance directly. -local DIAGNOSTIC_COMPONENT_MARKER = {} +local DIAGNOSTIC_COMPONENT_MARKER = table.freeze({}) + +-- This tells the World whether the component should be unwrapped on insertion. +local PRIMITIVE_MARKER = table.freeze({}) local lastId = 0 -local function newComponent(name, defaultData) +local function new(name: string, defaultData) name = name or debug.info(2, "s") .. "@" .. debug.info(2, "l") - assert( - defaultData == nil or type(defaultData) == "table", - "if component default data is specified, it must be a table" - ) + local Component = {} + Component.__index = Component - local component = {} - component.__index = component + function Component.new(data) + -- If we aren't passed data, then we use the default data. + -- If no default data is provided, we want to default a table. + data = if data == nil then defaultData or {} else data - function component.new(data) - data = data or {} + if typeof(data) == "table" then + if defaultData then + data = merge(defaultData, data) + end - if defaultData then - data = merge(defaultData, data) + return table.freeze(setmetatable(data, Component)) + else + return table.freeze(setmetatable({ data = data, [PRIMITIVE_MARKER] = true }, Component)) end - - return table.freeze(setmetatable(data, component)) end --[=[ - @within Component - - ```lua - for id, target in world:query(Target) do - if shouldChangeTarget(target) then - world:insert(id, target:patch({ -- modify the existing component - currentTarget = getNewTarget() - })) + @within TableComponentInstance + + ```lua + for id, target in world:query(Target) do + if shouldChangeTarget(target) then + world:insert(id, target:patch({ -- modify the existing component + currentTarget = getNewTarget() + })) + end end - end - ``` + ``` - A utility function used to immutably modify an existing component instance. Key/value pairs from the passed table - will override those of the existing component instance. + A utility function used to immutably modify an existing component instance. Key/value pairs from the passed table + will override those of the existing component instance. - As all components are immutable and frozen, it is not possible to modify the existing component directly. + As all components are immutable and frozen, it is not possible to modify the existing component directly. - You can use the `Matter.None` constant to remove a value from the component instance: + You can use the `Matter.None` constant to remove a value from the component instance: - ```lua - target:patch({ - currentTarget = Matter.None -- sets currentTarget to nil - }) - ``` + ```lua + target:patch({ + currentTarget = Matter.None -- sets currentTarget to nil + }) + ``` - @param partialNewData {} -- The table to be merged with the existing component data. - @return ComponentInstance -- A copy of the component instance with values from `partialNewData` overriding existing values. + @param partialNewData {} -- The table to be merged with the existing component data. + @return TableComponentInstance -- A copy of the component instance with values from `partialNewData` overriding existing values. ]=] - function component:patch(partialNewData) - debug.profilebegin("patch") - local patch = getmetatable(self).new(merge(self, partialNewData)) - debug.profileend() - return patch + function Component:patch(partialNewData) + return getmetatable(self).new(merge(self, partialNewData)) end lastId += 1 local id = lastId - setmetatable(component, { + setmetatable(Component, { __call = function(_, ...) - return component.new(...) + return Component.new(...) end, + __tostring = function() return name end, + __len = function() return id end, + [DIAGNOSTIC_COMPONENT_MARKER] = true, }) - return component + return Component end local function assertValidType(value, position) @@ -137,7 +137,6 @@ local function assertValidComponent(value, position) assertValidType(value, position) local metatable = getmetatable(value) - if getmetatable(metatable) ~= nil and getmetatable(metatable)[DIAGNOSTIC_COMPONENT_MARKER] then error( string.format( @@ -177,10 +176,16 @@ local function assertComponentArgsProvided(...) end end +local function isPrimitive(componentInstance) + return componentInstance[PRIMITIVE_MARKER] ~= nil +end + return { - newComponent = newComponent, + new = new, assertValidComponentInstance = assertValidComponentInstance, assertValidComponentInstances = assertValidComponentInstances, assertComponentArgsProvided = assertComponentArgsProvided, assertValidComponent = assertValidComponent, + + isPrimitive = isPrimitive, } diff --git a/lib/World.luau b/lib/World.luau index 197b34f0..0359d39e 100644 --- a/lib/World.luau +++ b/lib/World.luau @@ -2,7 +2,7 @@ --!optimize 2 local Archetype = require(script.Parent.Archetype) -local Component = require(script.Parent.component) +local Component = require(script.Parent.Component) local topoRuntime = require(script.Parent.topoRuntime) local assertValidComponentInstances = Component.assertValidComponentInstances @@ -244,10 +244,12 @@ local function executeDespawn(world: World, despawnCommand: DespawnCommand) local archetype = entityRecord.archetype -- Track changes - for _, componentStorage in archetype.fields do - local componentInstance = componentStorage[entityRecord.indexInArchetype] - local component = getmetatable(componentInstance :: any) - world:_trackChanged(component, entityId, componentInstance, nil) + for index, componentStorage in archetype.fields do + local data = componentStorage[entityRecord.indexInArchetype] + local componentId = archetype.indexToId[index] + local component = world.componentIdToComponent[componentId] + + world:_trackChanged(component, entityId, data, nil) end -- TODO: @@ -268,6 +270,9 @@ local function executeInsert(world: World, insertCommand: InsertCommand) local oldArchetype = entityRecord.archetype for _, componentInstance in componentInstances do + local isPrimitive = Component.isPrimitive(componentInstance) + local data = if isPrimitive then componentInstance.data else componentInstance + local component = getmetatable(componentInstance) local componentId = #component local componentIds = table.clone(oldArchetype.componentIds) @@ -281,8 +286,7 @@ local function executeInsert(world: World, insertCommand: InsertCommand) entityIndex = transitionArchetype(world, entityId, entityRecord, archetype) oldComponentInstance = archetype.fields[archetype.idToIndex[componentId]][entityIndex] - -- FIXME: - -- This shouldn't be in a hotpath, probably better in createArchetype + -- FIXME: This shouldn't be in a hotpath, probably better in createArchetype world.componentIdToComponent[componentId] = component else archetype = oldArchetype @@ -290,8 +294,8 @@ local function executeInsert(world: World, insertCommand: InsertCommand) oldComponentInstance = oldArchetype.fields[oldArchetype.idToIndex[componentId]][entityIndex] end - archetype.fields[archetype.idToIndex[componentId]][entityIndex] = componentInstance - world:_trackChanged(component, entityId, oldComponentInstance, componentInstance) + archetype.fields[archetype.idToIndex[componentId]][entityIndex] = data + world:_trackChanged(component, entityId, oldComponentInstance, data) oldArchetype = archetype end diff --git a/lib/World.spec.luau b/lib/World.spec.luau index 0986a654..86ef37df 100644 --- a/lib/World.spec.luau +++ b/lib/World.spec.luau @@ -216,7 +216,7 @@ return function() local world = World.new() local Player = component() - local Health = component() + local Health = component("Health", 100) local Poison = component() local id = world:spawn(Player(), Poison()) @@ -225,6 +225,7 @@ return function() expect(world:query(Health):next()).to.never.be.ok() world:insert(id, Health()) + print(world:get(id, Health)) expect(world:query(Player):next()).to.be.ok() expect(world:query(Health):next()).to.be.ok() @@ -238,6 +239,8 @@ return function() expect(world:query(Player):next()).to.never.be.ok() expect(world:query(Health):next()).to.be.ok() expect(world:size()).to.equal(1) + + expect(world:query(Health):next()).to.never.be.ok() end) it("should allow removing missing components", function() @@ -248,6 +251,41 @@ return function() expect(world:remove(entityId, A)).to.equal(nil) end) + it("should allow inserting the same component with multiple datatypes", function() + local world = World.new() + local A = component() + + local one = world:spawn(A("hello")) + local two = world:spawn(A(1)) + local three = world:spawn(A({ whats_good = true })) + local four = world:spawn(A()) + local five = world:spawn(A("test")) + + expect(world:get(one, A)).to.equal("hello") + + expect(world:get(two, A)).to.equal(1) + + expect(typeof(world:get(three, A))).to.equal("table") + expect(world:get(three, A).whats_good).to.be.ok() + + expect(typeof(world:get(four, A))).to.equal("table") + expect(next(world:get(four, A))).to.never.be.ok() + + expect(world:get(five, A)).to.equal("test") + end) + + it("should unwrap non-tables in queries", function() + local world = World.new() + local A = component() + + local entity = world:spawn(A("hello")) + expect(world:query(A):next()).to.equal(entity) + + for _, a in world:query(A) do + expect(a).to.equal("hello") + end + end) + it("should not find any entities", function() local world = World.new() diff --git a/lib/component.spec.luau b/lib/component.spec.luau index 17144a98..5fce5eee 100644 --- a/lib/component.spec.luau +++ b/lib/component.spec.luau @@ -1,6 +1,6 @@ -local Component = require(script.Parent.component) +local Component = require(script.Parent.Component) local None = require(script.Parent.immutable).None -local component = Component.newComponent +local component = Component.new local assertValidComponentInstance = Component.assertValidComponentInstance local assertValidComponent = Component.assertValidComponent diff --git a/lib/debugger/formatTable.luau b/lib/debugger/formatValue.luau similarity index 92% rename from lib/debugger/formatTable.luau rename to lib/debugger/formatValue.luau index 01dacd2e..0c893a2b 100644 --- a/lib/debugger/formatTable.luau +++ b/lib/debugger/formatValue.luau @@ -38,7 +38,11 @@ local FormatMode = { Short = "Short", Long = "Long", } -local function formatTable(object, mode, _padLength, _depth) +local function formatValue(object, mode, _padLength, _depth) + if typeof(object) ~= "table" then + return tostring(object) + end + mode = mode or FormatMode.Short _padLength = _padLength or 0 _depth = _depth or 1 @@ -87,7 +91,7 @@ local function formatTable(object, mode, _padLength, _depth) part ..= "[{..}]=" else part ..= "[" - part ..= formatTable(key, FormatMode.Short, #str + #part + _padLength, _depth + 1) + part ..= formatValue(key, FormatMode.Short, #str + #part + _padLength, _depth + 1) part ..= "] = " end end @@ -107,7 +111,7 @@ local function formatTable(object, mode, _padLength, _depth) if mode == FormatMode.Short then part ..= "{..}" else - part ..= formatTable(value, FormatMode.Long, #str + #part + _padLength, _depth + 1) + part ..= formatValue(value, FormatMode.Long, #str + #part + _padLength, _depth + 1) end elseif mode == FormatMode.Long and (luaType == "userdata" or luaType == "vector") then if robloxType == "CFrame" then @@ -157,6 +161,6 @@ local function formatTable(object, mode, _padLength, _depth) end return { - formatTable = formatTable, + formatValue = formatValue, FormatMode = FormatMode, } diff --git a/lib/debugger/widgets/entityInspect.luau b/lib/debugger/widgets/entityInspect.luau index 966c7c75..d6f202aa 100644 --- a/lib/debugger/widgets/entityInspect.luau +++ b/lib/debugger/widgets/entityInspect.luau @@ -1,7 +1,7 @@ -local formatTableModule = require(script.Parent.Parent.formatTable) +local formatValueModule = require(script.Parent.Parent.formatValue) local getAllComponentData = require(script.Parent.Parent.getAllComponentData) -local formatTable = formatTableModule.formatTable -local FormatMode = formatTableModule.FormatMode +local formatValue = formatValueModule.formatValue +local FormatMode = formatValueModule.FormatMode return function(plasma) return plasma.widget(function(debugger, world) @@ -42,7 +42,7 @@ return function(plasma) for component, componentData in getAllComponentData(world, debugger.debugEntity) do table.insert(items, { tostring(component), - formatTable(componentData, FormatMode.Long), + formatValue(componentData, FormatMode.Long), }) end diff --git a/lib/debugger/widgets/hoverInspect.luau b/lib/debugger/widgets/hoverInspect.luau index cbfc3074..2b45b112 100644 --- a/lib/debugger/widgets/hoverInspect.luau +++ b/lib/debugger/widgets/hoverInspect.luau @@ -1,7 +1,7 @@ -local formatTableModule = require(script.Parent.Parent.formatTable) +local formatValueModule = require(script.Parent.Parent.formatValue) local getAllComponentData = require(script.Parent.Parent.getAllComponentData) -local formatTable = formatTableModule.formatTable -local FormatMode = formatTableModule.FormatMode +local formatValue = formatValueModule.formatValue +local FormatMode = formatValueModule.FormatMode return function(plasma) return plasma.widget(function(world, id, custom) @@ -15,7 +15,7 @@ return function(plasma) if next(componentData) == nil then str ..= "{ }\n" else - str ..= (formatTable(componentData, FormatMode.Long, 0, 2) .. "\n") + str ..= (formatValue(componentData, FormatMode.Long, 0, 2) .. "\n") end end diff --git a/lib/debugger/widgets/valueInspect.luau b/lib/debugger/widgets/valueInspect.luau index 20466ff5..8ee628e2 100644 --- a/lib/debugger/widgets/valueInspect.luau +++ b/lib/debugger/widgets/valueInspect.luau @@ -1,5 +1,5 @@ -local formatTableModule = require(script.Parent.Parent.formatTable) -local formatTable = formatTableModule.formatTable +local formatValueModule = require(script.Parent.Parent.formatValue) +local formatValue = formatValueModule.formatValue return function(plasma) return plasma.widget(function(objectStack, custom) @@ -41,13 +41,13 @@ return function(plasma) valueItem = function() if custom - .link(formatTable(value), { + .link(formatValue(value), { font = Enum.Font.Code, }) :clicked() then table.insert(objectStack, { - key = if type(key) == "table" then formatTable(key) else tostring(key), + key = if type(key) == "table" then formatValue(key) else tostring(key), value = value, }) end diff --git a/lib/debugger/widgets/worldInspect.luau b/lib/debugger/widgets/worldInspect.luau index 358f72d2..8bb29024 100644 --- a/lib/debugger/widgets/worldInspect.luau +++ b/lib/debugger/widgets/worldInspect.luau @@ -1,6 +1,6 @@ -local formatTableModule = require(script.Parent.Parent.formatTable) +local formatValueModule = require(script.Parent.Parent.formatValue) local getAllComponentData = require(script.Parent.Parent.getAllComponentData) -local formatTable = formatTableModule.formatTable +local formatValue = formatValueModule.formatValue local BY_COMPONENT_NAME = "ComponentName" local BY_ENTITY_COUNT = "EntityCount" @@ -130,7 +130,7 @@ return function(plasma) for entityId, data in world:query(debugComponent) do table.insert(items, { entityId, - formatTable(data), + formatValue(data), selected = debugger.debugEntity == entityId, }) @@ -170,7 +170,7 @@ return function(plasma) for i = 1, #intersectingComponents do local data = intersectingData[item[1]][i] - table.insert(item, if data then formatTable(data) else "") + table.insert(item, if data then formatValue(data) else "") end end diff --git a/lib/hooks/log.luau b/lib/hooks/log.luau index e0d944cd..e4de8cd1 100644 --- a/lib/hooks/log.luau +++ b/lib/hooks/log.luau @@ -1,5 +1,5 @@ local topoRuntime = require(script.Parent.Parent.topoRuntime) -local format = require(script.Parent.Parent.debugger.formatTable) +local format = require(script.Parent.Parent.debugger.formatValue) --[=[ @within Matter @@ -25,7 +25,7 @@ local function log(...) local value = select(i, ...) if type(value) == "table" then - segments[i] = format.formatTable(value) + segments[i] = format.formatValue(value) else segments[i] = tostring(value) end diff --git a/lib/init.luau b/lib/init.luau index 644e9859..8a5dc2d3 100644 --- a/lib/init.luau +++ b/lib/init.luau @@ -55,7 +55,7 @@ local immutable = require(script.immutable) local World = require(script.World) local Loop = require(script.Loop) -local newComponent = require(script.component).newComponent +local newComponent = require(script.Component).new local topoRuntime = require(script.topoRuntime) export type World = World.World diff --git a/moonwave.toml b/moonwave.toml index 14d7c13c..48c0257b 100644 --- a/moonwave.toml +++ b/moonwave.toml @@ -1,10 +1,17 @@ -classOrder = ["Matter", "World", "QueryResult", "Loop"] gitSourceBranch = "main" [docusaurus] -url = "https://eryn.io" +url = "https://matter-ecs.github.io/" +baseUrl = "/matter" tagline = "A modern ECS library for Roblox" +[[classOrder]] +classes = ["Matter", "World", "QueryResult", "Loop"] + +[[classOrder]] +section = "Components" +classes = ["Component", "TableComponentInstance"] + [[navbar.items]] href = "https://discord.gg/aQwDAYhqtJ" label = "Roblox Open Source Discord" @@ -25,4 +32,3 @@ src = "/logo.svg" [home] enabled = true includeReadme = false -