-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTriggerModule.luau
More file actions
51 lines (40 loc) · 1.28 KB
/
TriggerModule.luau
File metadata and controls
51 lines (40 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
--- @class Triggers
--- Trigger module. I hate typechecking.
local Triggers = {}
local Modules = script.Parent
local Objectives = require(Modules:WaitForChild("ObjectiveModule"))
--- Why?
Triggers.RegisteredTriggers = {}
--[=[
I hardcoded the variable. Do you like it?
@private
@within Triggers
@param x string -- Welcome to Australia
]=]
local function DebugOutput(x: string)
print(string.format("[Triggers]: %s", x))
end
--[=[
Register a trigger, who wrote this documentation?
@within Triggers
@param TriggerName string -- Name of the trigger
@param Function () -> () -- Function to hook
]=]
Triggers.RegisterTrigger = function(TriggerName: string, Function: () -> ())
Triggers.RegisteredTriggers[TriggerName] = Function
DebugOutput("Registered trigger: "..TriggerName)
end
--[=[
Trigger a trigger. You can go handle the debugging.
@within Triggers
@param TriggerName string -- Name of the trigger
]=]
Triggers.Trigger = function(TriggerName: string)
assert(typeof(TriggerName) == "string", "Not a string")
if typeof(Triggers.RegisteredTriggers[TriggerName]) == "function" then
Triggers.RegisteredTriggers[TriggerName]()
else
DebugOutput(string.format("Trigger %s does not exist!", TriggerName))
end
end
return Triggers