-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
583c522
commit a84917c
Showing
4 changed files
with
51 additions
and
16 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
src/Spectre/Subsystems/ExampleService/SpectreModules/TestModule.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
local function Test(...) | ||
return ... | ||
end | ||
|
||
return Test |
3 changes: 3 additions & 0 deletions
3
src/Spectre/Subsystems/ExampleService/SpectreModules/init.meta.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"ignoreUnknownInstances": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,48 @@ | ||
-- This is an example Spectre subsystem. | ||
-- It contains the following: an example function, and an example command. | ||
-- | ||
|
||
-- Do some variable initialization if you have to | ||
local Players = game:GetService("Players") | ||
local ServerScriptService = game:GetService("ServerScriptService") | ||
local HttpService = game:GetService("HttpService") | ||
local Spectre = ServerScriptService["Spectre"] | ||
local Modules = {} | ||
local Subsystems = { | ||
LogService = require(Spectre["Subsystems"]["LogService"]), | ||
} | ||
|
||
-- Pull all Spectre modules (Also optional, but it's probably a good idea ) | ||
for i, v in pairs(Spectre["Modules"]:GetChildren()) do | ||
Modules[`Spectre.{v.Name}`] = require(v) | ||
end | ||
|
||
-- Pull our own modules | ||
for i, v in pairs(script["SpectreModules"]:GetChildren()) do | ||
Modules[v.Name] = require(v) | ||
end | ||
|
||
-- The above is boilerplate, and is recommended for access to all Spectre modules. If you need to require any subsystems like the LogService at this point, do it now. | ||
-- Subsystems required for operation | ||
-- (This is optional if your service does not rely on any subsystems, but most services should subscribe to the LogService at least) | ||
local Subsystems = { | ||
LogService = require(Spectre["Subsystems"]["LogService"]), | ||
} | ||
-- Push to Spectre compartment in LogService | ||
Subsystems.LogService:Push("Spectre",{ | ||
Origin = "ExampleService", | ||
LoadedModules = Modules, | ||
Ready = true | ||
}) | ||
|
||
-- Initialize service table | ||
local ExampleService = {} | ||
|
||
-- Add method to service | ||
function ExampleService:Test(...) | ||
Modules.Output(`{script.Name}`, `Example fired: {...}`) | ||
return ... | ||
end | ||
|
||
-- This is used to push an not-API API to Spectre for inclusion in _G.Spectre later | ||
-- This is very much optional, all services will load without an API attached | ||
ExampleService.API = { | ||
Test = ExampleService.Test | ||
} | ||
|
||
return ExampleService -- All Spectre subsystems are ModuleScripts, and as such, need to return the subsystem to be valid | ||
return ExampleService -- All services are modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters