Skip to content

Commit

Permalink
Rename uncaught .lua files to .luau & update docs/project references (#…
Browse files Browse the repository at this point in the history
…85)

Co-authored-by: Lucas Gangstad <[email protected]>
  • Loading branch information
Ukendio and LastTalon authored Jul 2, 2024
1 parent ae81b8e commit 48fd7a8
Show file tree
Hide file tree
Showing 30 changed files with 22 additions and 21 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions docs/BestPractices/Reconciliation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion docs/Concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
12 changes: 6 additions & 6 deletions docs/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand All @@ -39,15 +39,15 @@ loop:scheduleSystems(systems)

Then, simply start the loop.

```lua title="init.server.lua"
```lua title="init.server.luau"
loop:begin({
default = RunService.Heartbeat
})
```

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
Expand All @@ -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 {
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/Guides/HotReloading.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

2 changes: 1 addition & 1 deletion docs/Guides/MatterDebugger.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions docs/Guides/Replication.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 = {}
Expand Down
2 changes: 1 addition & 1 deletion example.project.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"StarterPlayerScripts": {
"$className": "StarterPlayerScripts",
"Game": {
"$path": "example/src/game.client.lua"
"$path": "example/src/game.client.luau"
}
}
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions lib/immutable.luau
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}

Expand All @@ -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 = {}

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion test.project.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"$className": "TestService",
"run": {
"$path": "tests.server.lua"
"$path": "tests.server.luau"
}
}
}
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 48fd7a8

Please sign in to comment.