From d6fbdc5755e32c209ec42f64b2d49bc32bfd2bb5 Mon Sep 17 00:00:00 2001 From: Lars Mueller Date: Sun, 18 Sep 2022 16:23:30 +0200 Subject: [PATCH] Get rid of deprecated modlib.conf usage --- Readme.md | 41 +++++++++++++++++------------------------ default_config.json | 6 ------ main.lua | 28 +--------------------------- schema.lua | 31 +++++++++++++++++++++++++++++++ settingtypes.txt | 15 ++++++++++----- 5 files changed, 59 insertions(+), 62 deletions(-) delete mode 100644 default_config.json create mode 100644 schema.lua diff --git a/Readme.md b/Readme.md index fa4e6ec..46e9322 100644 --- a/Readme.md +++ b/Readme.md @@ -31,39 +31,32 @@ Code should be self-explanatory. If not, feel free to contact me (opening an iss ## Configuration -### Locations + +### `format` -* JSON Configuration: `/config/hud_timers.json` -* Text Logs: `/logs/hud_timers/.txt` -* Readme: `/hud_timers/Readme.md` +The format for the timer label - first string is timer name, second one is seconds left. -### Default Configuration +* Type: string +* Default: `%s: %s s` -Located under `/hud_timers/default_config.json` +### `globalstep` -```json -{ - "hud_pos": {"x": 0,"y": 0}, - "globalstep": 0.1, - "hud_timers_max": 10, - "format": "%s: %s s" -} -``` +How often timers should be updated (interval duration in seconds). -### Usage +* Type: number +* Default: `0.1` +* >= `0` -#### `hud_pos` +### `hud_pos` Screen coordinates where the timer stack should start. -#### `globalstep` - -How often timers should be updated(interval, seconds). - -#### `hud_timers_max` +### `hud_timers_max` How many timers(maximum) may exist at a time. -#### `format` : "%s : %s s" - -The format for the timer label - first string is timer name, second one is seconds left. \ No newline at end of file +* Type: number +* Default: `10` +* >= `0` +* <= `100` + diff --git a/default_config.json b/default_config.json deleted file mode 100644 index 3bf1437..0000000 --- a/default_config.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "hud_pos" : {"x": 0.1,"y": 0.9}, - "globalstep" : 0.1, - "hud_timers_max" : 10, - "format" : "%s: %s s" -} \ No newline at end of file diff --git a/main.lua b/main.lua index 1d3db72..43d9013 100644 --- a/main.lua +++ b/main.lua @@ -1,32 +1,6 @@ timers = {} -local config = - modlib.conf.import( - "hud_timers", - { - type = "table", - children = { - hud_timers_max = { - type = "number", - range = {0, 100} - }, - hud_pos = { - type = "table", - children = { - x = {type = "number"}, - y = {type = "number"} - } - }, - globalstep = { - type = "number", - range = {0} - }, - format = { - type = "string" - } - } - } -) +local config = modlib.mod.configuration() modlib.table.add_all(getfenv(1), config) diff --git a/schema.lua b/schema.lua new file mode 100644 index 0000000..a712f81 --- /dev/null +++ b/schema.lua @@ -0,0 +1,31 @@ +return { + type = "table", + entries = { + hud_timers_max = { + type = "number", + range = {min = 0, max = 100}, + default = 10, + description = "How many timers(maximum) may exist at a time." + }, + hud_pos = { + type = "table", + children = { + x = {type = "number"}, + y = {type = "number"} + }, + default = {x = 0.1, y = 0.9}, + description = "Screen coordinates where the timer stack should start." + }, + globalstep = { + type = "number", + range = { min = 0 }, + default = 0.1, + description = "How often timers should be updated (interval duration in seconds)." + }, + format = { + type = "string", + default = "%s: %s s", + description = "The format for the timer label - first string is timer name, second one is seconds left." + } + } +} \ No newline at end of file diff --git a/settingtypes.txt b/settingtypes.txt index eba0c42..c57a1c6 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -1,5 +1,10 @@ -hud_timers.hud_timers_max (Hud timers hud_timers_max) float 10 0.000000 100.000000 -hud_timers.format (Hud timers format) string %s: %s s -hud_timers.globalstep (Hud timers globalstep) float 0.1 0.000000 1073741824.000000 -hud_timers.hud_pos.y (Hud timers hud_pos y) float 0.9 -hud_timers.hud_pos.x (Hud timers hud_pos x) float 0.1 \ No newline at end of file +# The format for the timer label - first string is timer name, second one is seconds left. +hud_timers.format (Hud timers Format) string %s: %s s + +# How often timers should be updated (interval duration in seconds). +hud_timers.globalstep (Hud timers Globalstep) float 0.1 0.000000 1073741824.000000 + +# How many timers(maximum) may exist at a time. +hud_timers.hud_timers_max (Hud timers Hud timers max) float 10 0.000000 100.000000 + +[hud_timers.hud_pos] \ No newline at end of file