Skip to content
This repository has been archived by the owner on Jul 31, 2024. It is now read-only.

GetServices and GetControllers #239

Merged
merged 3 commits into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Aftman
uses: ok-nick/setup-aftman@v0
uses: ok-nick/setup-aftman@v0.4.2
- name: Lint
run: |
selene ./src
Expand All @@ -29,5 +29,5 @@ jobs:
- uses: JohnnyMorganz/stylua-action@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: v0.19.1
version: v0.20.0
args: --check ./src
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Aftman
uses: ok-nick/setup-aftman@v0
uses: ok-nick/setup-aftman@v0.4.2
- name: Publish release to Wally
shell: bash
env:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.7.0
- Adds `Knit.GetServices()` function server-side
- Adds `Knit.GetControllers()` function client-side
- Freezes `services`/`controllers` tables so that they can be safely returned in the functions listed above.
- Update GitHub workflow dependencies

## 1.6.0

- Add support for UnreliableRemoteEvents (using `Knit.CreateUnreliableSignal()` on server)
Expand Down
2 changes: 1 addition & 1 deletion docs/gettingstarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Installing Knit is very simple. Just drop the module into ReplicatedStorage. Kni

**Rojo/Wally workflow:**

- Add Knit to your `wally.toml` dependency list (e.g. `Knit = "sleitnick/knit@^1.6"`)
- Add Knit to your `wally.toml` dependency list (e.g. `Knit = "sleitnick/knit@^1.7"`)
- Require Knit like any other module grabbed from Wally

:::note Wally
Expand Down
10 changes: 10 additions & 0 deletions src/KnitClient.lua
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,14 @@ function KnitClient.GetController(controllerName: string): Controller
error(`Could not find controller "{controllerName}". Check to verify a controller with this name exists.`, 2)
end

--[=[
Gets a table of all controllers.
]=]
function KnitClient.GetControllers(): { [string]: Controller }
assert(started, "Cannot call GetControllers until Knit has been started")
return controllers
end

--[=[
@return Promise
Starts Knit. Should only be called once per client.
Expand All @@ -314,6 +322,8 @@ function KnitClient.Start(options: KnitOptions?)

started = true

table.freeze(controllers)

if options == nil then
selectedOptions = defaultOptions
else
Expand Down
10 changes: 10 additions & 0 deletions src/KnitServer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,14 @@ function KnitServer.GetService(serviceName: string): Service
return assert(services[serviceName], `Could not find service "{serviceName}"`) :: Service
end

--[=[
Gets a table of all services.
]=]
function KnitServer.GetServices(): { [string]: Service }
assert(started, "Cannot call GetServices until Knit has been started")
return services
end

--[=[
@return SIGNAL_MARKER
Returns a marker that will transform the current key into
Expand Down Expand Up @@ -364,6 +372,8 @@ function KnitServer.Start(options: KnitOptions?)

started = true

table.freeze(services)

if options == nil then
selectedOptions = defaultOptions
else
Expand Down
2 changes: 1 addition & 1 deletion src/wally.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "sleitnick/knit"
description = "Knit is a lightweight game framework"
version = "1.6.0"
version = "1.7.0"
license = "MIT"
registry = "https://github.com/UpliftGames/wally-index"
realm = "shared"
Expand Down
Loading