-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase.lua
More file actions
61 lines (49 loc) · 1.75 KB
/
base.lua
File metadata and controls
61 lines (49 loc) · 1.75 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
52
53
54
55
56
57
58
59
60
61
local PATH = string.sub(..., 1, string.len(...) - string.len("plugins.base"))
local Class = require(PATH .. ".lib.class")
---@class FeatherPlugin
---@field options table
---@field logger FeatherLogger
---@field observer FeatherObserver
---@field init fun(self: FeatherPlugin, config: table)
---@field update fun(self: FeatherPlugin, dt: number, feather: Feather): ...
---@field onerror fun(self: FeatherPlugin, msg: string, feather: Feather): ...
---@field handleRequest fun(self: FeatherPlugin, request: table, feather: Feather): ...
---@field handleActionRequest fun(self: FeatherPlugin, request: table, feather: Feather): ...
---@field handleParamsUpdate fun(self: FeatherPlugin, request: table, feather: Feather): ...
---@field isSupported fun(self: FeatherPlugin, version: number): boolean
---@field finish fun(self: FeatherPlugin, feather: Feather): ...
---@field getConfig fun(self: FeatherPlugin): table
local FeatherPlugin = Class({})
function FeatherPlugin:init(config)
self.options = config.options or {}
self.logger = config.logger or {}
self.observer = config.observer or {}
end
function FeatherPlugin:update(dt)
return self, dt
end
function FeatherPlugin:onerror(msg)
return self, msg
end
function FeatherPlugin:handleRequest(request)
return self, request
end
function FeatherPlugin:handleActionRequest(request)
return self, request
end
function FeatherPlugin:handleParamsUpdate()
return {}
end
--- Verify if the plugin is supported by the current plugin api version of Feather
---@param version number
function FeatherPlugin:isSupported(version)
-- By default, all api versions are supported
return version > 0
end
function FeatherPlugin:finish()
return self, "Finish"
end
function FeatherPlugin:getConfig()
return {}
end
return FeatherPlugin