Get rid of deprecated modlib.conf usage

This commit is contained in:
Lars Mueller 2022-09-18 16:23:30 +02:00
parent 6a444dfb6b
commit d6fbdc5755
5 changed files with 59 additions and 62 deletions

@ -31,39 +31,32 @@ Code should be self-explanatory. If not, feel free to contact me (opening an iss
## Configuration ## Configuration
### Locations <!--modlib:conf:2-->
### `format`
* JSON Configuration: `<worldpath>/config/hud_timers.json` The format for the timer label - first string is timer name, second one is seconds left.
* Text Logs: `<worldpath>/logs/hud_timers/<date>.txt`
* Readme: `<modpath/gamepath>/hud_timers/Readme.md`
### Default Configuration * Type: string
* Default: `%s: %s s`
Located under `<modpath/gamepath>/hud_timers/default_config.json` ### `globalstep`
```json How often timers should be updated (interval duration in seconds).
{
"hud_pos": {"x": 0,"y": 0},
"globalstep": 0.1,
"hud_timers_max": 10,
"format": "%s: %s s"
}
```
### Usage * Type: number
* Default: `0.1`
* &gt;= `0`
#### `hud_pos` ### `hud_pos`
Screen coordinates where the timer stack should start. Screen coordinates where the timer stack should start.
#### `globalstep` ### `hud_timers_max`
How often timers should be updated(interval, seconds).
#### `hud_timers_max`
How many timers(maximum) may exist at a time. How many timers(maximum) may exist at a time.
#### `format` : "%s : %s s" * Type: number
* Default: `10`
The format for the timer label - first string is timer name, second one is seconds left. * &gt;= `0`
* &lt;= `100`
<!--modlib:conf-->

@ -1,6 +0,0 @@
{
"hud_pos" : {"x": 0.1,"y": 0.9},
"globalstep" : 0.1,
"hud_timers_max" : 10,
"format" : "%s: %s s"
}

@ -1,32 +1,6 @@
timers = {} timers = {}
local config = local config = modlib.mod.configuration()
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"
}
}
}
)
modlib.table.add_all(getfenv(1), config) modlib.table.add_all(getfenv(1), config)

31
schema.lua Normal file

@ -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."
}
}
}

@ -1,5 +1,10 @@
hud_timers.hud_timers_max (Hud timers hud_timers_max) float 10 0.000000 100.000000 # 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 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 # How often timers should be updated (interval duration in seconds).
hud_timers.hud_pos.x (Hud timers hud_pos x) float 0.1 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]