From 48fd7a86caae5c0e3fd19f13efd406f0b3ce2298 Mon Sep 17 00:00:00 2001 From: Marcus Date: Tue, 2 Jul 2024 18:23:55 +0200 Subject: [PATCH] Rename uncaught .lua files to .luau & update docs/project references (#85) Co-authored-by: Lucas Gangstad --- CHANGELOG.md | 1 + docs/BestPractices/Reconciliation.md | 12 ++++++------ docs/Concepts.md | 2 +- docs/GettingStarted.md | 12 ++++++------ docs/Guides/HotReloading.md | 2 +- docs/Guides/MatterDebugger.md | 2 +- docs/Guides/Replication.md | 4 ++-- example.project.json | 2 +- ...eceiveReplication.lua => receiveReplication.luau} | 0 .../systems/{roombasHurt.lua => roombasHurt.luau} | 0 .../systems/{spinSpinners.lua => spinSpinners.luau} | 0 example/src/{game.client.lua => game.client.luau} | 0 .../src/server/{init.server.lua => init.server.luau} | 0 ...SpawnRoombas.lua => mothershipsSpawnRoombas.luau} | 0 ...{playersAreTargets.lua => playersAreTargets.luau} | 0 ...oveMissingModels.lua => removeMissingModels.luau} | 0 .../systems/{replication.lua => replication.luau} | 0 .../systems/{roombasMove.lua => roombasMove.luau} | 0 .../{spawnMotherships.lua => spawnMotherships.luau} | 0 .../systems/{spawnRoombas.lua => spawnRoombas.luau} | 0 .../{updateTransforms.lua => updateTransforms.luau} | 0 .../src/shared/{components.lua => components.luau} | 0 example/src/shared/{setupTags.lua => setupTags.luau} | 0 example/src/shared/{start.lua => start.luau} | 0 ...eModelAttribute.lua => updateModelAttribute.luau} | 0 lib/immutable.luau | 4 ++-- lib/{init.lua => init.luau} | 0 test.project.json | 2 +- tests.server.lua => tests.server.luau | 0 ...{stressTest.client.lua => stressTest.client.luau} | 0 30 files changed, 22 insertions(+), 21 deletions(-) rename example/src/client/{receiveReplication.lua => receiveReplication.luau} (100%) rename example/src/client/systems/{roombasHurt.lua => roombasHurt.luau} (100%) rename example/src/client/systems/{spinSpinners.lua => spinSpinners.luau} (100%) rename example/src/{game.client.lua => game.client.luau} (100%) rename example/src/server/{init.server.lua => init.server.luau} (100%) rename example/src/server/systems/{mothershipsSpawnRoombas.lua => mothershipsSpawnRoombas.luau} (100%) rename example/src/server/systems/{playersAreTargets.lua => playersAreTargets.luau} (100%) rename example/src/server/systems/{removeMissingModels.lua => removeMissingModels.luau} (100%) rename example/src/server/systems/{replication.lua => replication.luau} (100%) rename example/src/server/systems/{roombasMove.lua => roombasMove.luau} (100%) rename example/src/server/systems/{spawnMotherships.lua => spawnMotherships.luau} (100%) rename example/src/server/systems/{spawnRoombas.lua => spawnRoombas.luau} (100%) rename example/src/server/systems/{updateTransforms.lua => updateTransforms.luau} (100%) rename example/src/shared/{components.lua => components.luau} (100%) rename example/src/shared/{setupTags.lua => setupTags.luau} (100%) rename example/src/shared/{start.lua => start.luau} (100%) rename example/src/shared/systems/{updateModelAttribute.lua => updateModelAttribute.luau} (100%) rename lib/{init.lua => init.luau} (100%) rename tests.server.lua => tests.server.luau (100%) rename tests/{stressTest.client.lua => stressTest.client.luau} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 68c1597f..6fb04da7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog][kac], and this project adheres to ## [Unreleased] ### Fixed +- Converted the remaining lua files in the example project to luau files. - Iterating empty views properly iterates over nothing rather than the data structure members. ## [0.8.2] - 2024-06-25 diff --git a/docs/BestPractices/Reconciliation.md b/docs/BestPractices/Reconciliation.md index e0f6107d..7bd513b8 100644 --- a/docs/BestPractices/Reconciliation.md +++ b/docs/BestPractices/Reconciliation.md @@ -30,7 +30,7 @@ We can create another component (in the [Matter example game](https://github.com We can loop over all Ships that don't also have a Model, and create one for it. -```lua title="ships.lua" +```lua title="ships.luau" for id, ship in world:query(Ship):without(Model) do local model = prefabs.Ship:Clone() -- assuming prefabs is a place where you store pre-made models model.Parent = workspace @@ -43,7 +43,7 @@ end Now, whenever there's an entity with Ship without Model, we create the model and insert the Model component. We can then loop over all Ships that have Models, and update the position of the Model. -```lua title="ships.lua" +```lua title="ships.luau" for id, ship, model in world:query(Ship, Model) do model.instance.BodyPosition.Position = ship.goalPosition end @@ -53,7 +53,7 @@ Keep in mind, both of these loops are performed every frame - that's what a syst We have a problem now, though: whenever an entity with both Ship and Model is despawned, the physical ship Instance in the Data Model will stick around. Since the Model component is generic and could be reused with any other component (it's not specific to just Ship), we can create another system that handles this case for anything that uses Model. -```lua title="removeModels.lua" +```lua title="removeModels.luau" for _id, modelRecord in world:queryChanged(Model) do if modelRecord.new == nil then if modelRecord.old and modelRecord.old.instance then @@ -75,7 +75,7 @@ While we generally want our state to flow in one direction (Lua into the DataMod As an example, let's say we wanted the Ship to despawn if it was touched by anything. We can use Matter's [`useEvent`](/api/Matter#useEvent) utility to collect events that fire in a frame and loop over them. -```lua title="ships.lua" +```lua title="ships.luau" for id, model in world:query(Model, Ship) do for _ in Matter.useEvent(model.Instance, "Touched") do world:despawn(id) @@ -89,7 +89,7 @@ Sometimes, instances can be removed from the Data Model or destroyed without us To account for this, we can simply loop over every Model and check if it's still in the world. If not, we can either remove the Model component or despawn the entire entity (whichever makes more sense for your game). -```lua title="removeModels.lua" +```lua title="removeModels.luau" for id, model in world:query(Model) do if model.instance:IsDescendantOf(game) == false then world:remove(id, Model) @@ -111,7 +111,7 @@ There are two potential ways we could want to use this component: We can make a system that handles both of these cases for us. -```lua title="updateTransforms.lua" +```lua title="updateTransforms.luau" -- Handle Transform added/changed to existing entity with Model for id, transformRecord in world:queryChanged(Transform) do diff --git a/docs/Concepts.md b/docs/Concepts.md index 2bc9102c..23206016 100644 --- a/docs/Concepts.md +++ b/docs/Concepts.md @@ -75,7 +75,7 @@ We can reuse our `Health` component from earlier. Let's say that in our game, we A good way to name systems is by declaring something about the world that they do. In this case: "Health Regenerates." -```lua title="healthRegenerates.lua" +```lua title="healthRegenerates.luau" for id, health in world:query(Health) do if health.current < health.max then world:insert(id, health:patch({ diff --git a/docs/GettingStarted.md b/docs/GettingStarted.md index 87a7e6fd..21b4ac9f 100644 --- a/docs/GettingStarted.md +++ b/docs/GettingStarted.md @@ -16,7 +16,7 @@ Here's how you scaffold a project with Matter. First, import Matter at the top of your file. Then, create your [`World`](/api/World) and your [`Loop`](/api/Loop). -```lua title="init.server.lua" +```lua title="init.server.luau" local Matter = require(ReplicatedStorage.Matter) local world = Matter.World.new() @@ -26,7 +26,7 @@ local loop = Matter.Loop.new(world) -- This makes Loop pass the world to all you Then, we should collect all of your systems and schedule them. Assuming they're in a `systems` folder inside this script: -```lua title="init.server.lua" +```lua title="init.server.luau" local systems = {} for _, child in ipairs(script.systems:GetChildren()) do if child:IsA("ModuleScript") then @@ -39,7 +39,7 @@ loop:scheduleSystems(systems) Then, simply start the loop. -```lua title="init.server.lua" +```lua title="init.server.luau" loop:begin({ default = RunService.Heartbeat }) @@ -47,7 +47,7 @@ loop:begin({ Now your systems would run every heartbeat, if you had any. Let's make some. -```lua title="systems/myFirstSystem.lua" +```lua title="systems/myFirstSystem.luau" local function myFirstSystem() print("Hello world!") end @@ -59,7 +59,7 @@ Now we're printing something 60 times per second. We should probably do somethin Let's create a couple components. -```lua title="components.lua" +```lua title="components.luau" local Matter = require(ReplicatedStorage.Matter) return { @@ -70,7 +70,7 @@ return { Let's make a system that removes 0.1 health every frame from things that are poisoned. -```lua title="systems/poisonHurts.lua" +```lua title="systems/poisonHurts.luau" local Components = require(script.Parent.components) local Health = Components.Health local Poison = Components.Poison diff --git a/docs/Guides/HotReloading.md b/docs/Guides/HotReloading.md index 54ba8a77..8ee8db0e 100644 --- a/docs/Guides/HotReloading.md +++ b/docs/Guides/HotReloading.md @@ -89,5 +89,5 @@ end, function(_, context) end) ``` -That's it! For a real example of this in action, check out the [Matter example game](https://github.com/matter-ecs/matter/blob/main/example/src/shared/start.lua). +That's it! For a real example of this in action, check out the [Matter example game](https://github.com/matter-ecs/matter/blob/main/example/src/shared/start.luau). diff --git a/docs/Guides/MatterDebugger.md b/docs/Guides/MatterDebugger.md index b9f274d2..6f54792e 100644 --- a/docs/Guides/MatterDebugger.md +++ b/docs/Guides/MatterDebugger.md @@ -28,7 +28,7 @@ end This is accomplished using [Plasma](https://matter-ecs.github.io/plasma/), an immediate-mode widget library. The widgets are only created while the debugger is active. Leaving the widget calls in your systems all the time is fine, because calling a widget function when the debugger is not open is a no-op. -The [Matter example game](https://github.com/matter-ecs/matter/blob/main/example/shared/start.lua) comes with the debugger set up already. If you want to see an example of the debugger already set up in a game, check out that page. +The [Matter example game](https://github.com/matter-ecs/matter/blob/main/example/shared/start.luau) comes with the debugger set up already. If you want to see an example of the debugger already set up in a game, check out that page. ## Adding the Matter debugger to your game diff --git a/docs/Guides/Replication.md b/docs/Guides/Replication.md index 8cb0a8e0..eef622d4 100644 --- a/docs/Guides/Replication.md +++ b/docs/Guides/Replication.md @@ -2,7 +2,7 @@ Replication is not built into Matter, but it's easy to implement yourself. This guide will give you an overview of one way to implement replication with Matter. -This article will cover the way the [Matter example game](https://github.com/matter-ecs/matter/blob/main/example/shared/start.lua) implements replication. +This article will cover the way the [Matter example game](https://github.com/matter-ecs/matter/blob/main/example/shared/start.luau) implements replication. ## Deciding which components to replicate @@ -35,7 +35,7 @@ RemoteEvent.Name = "MatterRemote" RemoteEvent.Parent = ReplicatedStorage ``` -Let's convert the list of component names into actual components. This is assuming you have a Components module that exports your components, like [the matter example game does](https://github.com/matter-ecs/matter/blob/main/example/shared/components.lua). +Let's convert the list of component names into actual components. This is assuming you have a Components module that exports your components, like [the matter example game does](https://github.com/matter-ecs/matter/blob/main/example/shared/components.luau). ```lua local replicatedComponents = {} diff --git a/example.project.json b/example.project.json index a0478e6f..4bbfaa18 100644 --- a/example.project.json +++ b/example.project.json @@ -48,7 +48,7 @@ "StarterPlayerScripts": { "$className": "StarterPlayerScripts", "Game": { - "$path": "example/src/game.client.lua" + "$path": "example/src/game.client.luau" } } } diff --git a/example/src/client/receiveReplication.lua b/example/src/client/receiveReplication.luau similarity index 100% rename from example/src/client/receiveReplication.lua rename to example/src/client/receiveReplication.luau diff --git a/example/src/client/systems/roombasHurt.lua b/example/src/client/systems/roombasHurt.luau similarity index 100% rename from example/src/client/systems/roombasHurt.lua rename to example/src/client/systems/roombasHurt.luau diff --git a/example/src/client/systems/spinSpinners.lua b/example/src/client/systems/spinSpinners.luau similarity index 100% rename from example/src/client/systems/spinSpinners.lua rename to example/src/client/systems/spinSpinners.luau diff --git a/example/src/game.client.lua b/example/src/game.client.luau similarity index 100% rename from example/src/game.client.lua rename to example/src/game.client.luau diff --git a/example/src/server/init.server.lua b/example/src/server/init.server.luau similarity index 100% rename from example/src/server/init.server.lua rename to example/src/server/init.server.luau diff --git a/example/src/server/systems/mothershipsSpawnRoombas.lua b/example/src/server/systems/mothershipsSpawnRoombas.luau similarity index 100% rename from example/src/server/systems/mothershipsSpawnRoombas.lua rename to example/src/server/systems/mothershipsSpawnRoombas.luau diff --git a/example/src/server/systems/playersAreTargets.lua b/example/src/server/systems/playersAreTargets.luau similarity index 100% rename from example/src/server/systems/playersAreTargets.lua rename to example/src/server/systems/playersAreTargets.luau diff --git a/example/src/server/systems/removeMissingModels.lua b/example/src/server/systems/removeMissingModels.luau similarity index 100% rename from example/src/server/systems/removeMissingModels.lua rename to example/src/server/systems/removeMissingModels.luau diff --git a/example/src/server/systems/replication.lua b/example/src/server/systems/replication.luau similarity index 100% rename from example/src/server/systems/replication.lua rename to example/src/server/systems/replication.luau diff --git a/example/src/server/systems/roombasMove.lua b/example/src/server/systems/roombasMove.luau similarity index 100% rename from example/src/server/systems/roombasMove.lua rename to example/src/server/systems/roombasMove.luau diff --git a/example/src/server/systems/spawnMotherships.lua b/example/src/server/systems/spawnMotherships.luau similarity index 100% rename from example/src/server/systems/spawnMotherships.lua rename to example/src/server/systems/spawnMotherships.luau diff --git a/example/src/server/systems/spawnRoombas.lua b/example/src/server/systems/spawnRoombas.luau similarity index 100% rename from example/src/server/systems/spawnRoombas.lua rename to example/src/server/systems/spawnRoombas.luau diff --git a/example/src/server/systems/updateTransforms.lua b/example/src/server/systems/updateTransforms.luau similarity index 100% rename from example/src/server/systems/updateTransforms.lua rename to example/src/server/systems/updateTransforms.luau diff --git a/example/src/shared/components.lua b/example/src/shared/components.luau similarity index 100% rename from example/src/shared/components.lua rename to example/src/shared/components.luau diff --git a/example/src/shared/setupTags.lua b/example/src/shared/setupTags.luau similarity index 100% rename from example/src/shared/setupTags.lua rename to example/src/shared/setupTags.luau diff --git a/example/src/shared/start.lua b/example/src/shared/start.luau similarity index 100% rename from example/src/shared/start.lua rename to example/src/shared/start.luau diff --git a/example/src/shared/systems/updateModelAttribute.lua b/example/src/shared/systems/updateModelAttribute.luau similarity index 100% rename from example/src/shared/systems/updateModelAttribute.lua rename to example/src/shared/systems/updateModelAttribute.luau diff --git a/lib/immutable.luau b/lib/immutable.luau index c93e976c..06b93fda 100644 --- a/lib/immutable.luau +++ b/lib/immutable.luau @@ -14,7 +14,7 @@ local function merge(one, two) return new end --- https://github.com/freddylist/llama/blob/master/src/List/toSet.lua +-- https://github.com/freddylist/llama/blob/master/src/List/toSet.luau local function toSet(list) local set = {} @@ -25,7 +25,7 @@ local function toSet(list) return set end --- https://github.com/freddylist/llama/blob/master/src/Dictionary/values.lua +-- https://github.com/freddylist/llama/blob/master/src/Dictionary/values.luau local function values(dictionary) local valuesList = {} diff --git a/lib/init.lua b/lib/init.luau similarity index 100% rename from lib/init.lua rename to lib/init.luau diff --git a/test.project.json b/test.project.json index fe02bba6..02661724 100644 --- a/test.project.json +++ b/test.project.json @@ -22,7 +22,7 @@ }, "$className": "TestService", "run": { - "$path": "tests.server.lua" + "$path": "tests.server.luau" } } } diff --git a/tests.server.lua b/tests.server.luau similarity index 100% rename from tests.server.lua rename to tests.server.luau diff --git a/tests/stressTest.client.lua b/tests/stressTest.client.luau similarity index 100% rename from tests/stressTest.client.lua rename to tests/stressTest.client.luau