Implement modlib-based configuration

master
Lars Mueller 2020-12-22 13:40:45 +01:00
parent e6d050ed04
commit 7ac030b4b3
4 changed files with 70 additions and 13 deletions

View File

@ -36,12 +36,32 @@ Relies on multiple hacks and thus imposes the following limitations on other mod
* `respawn_timer.bone_names_by_model["<filename>.<ext>"] = { "Bone_1", "Bone_2", ... }` including standard bone names if used
* If both bone position and rotation are set to `{ x = 0, y = 0, z = 0 }`, the bone will be ignored
Respawning can be done using `respawn_timer.respawn(player_ref)`, the timer can be modified by altering the exposed table
Respawning can be done using `respawn_timer.respawn(player_ref)`.
```lua
respawn_timer.timer = {
name = "Respawn",
duration = 5,
color = "FF00FF"
}
```
## Configuration
<!--modlib:conf:2-->
### `timer`
#### `color`
Timer fill color as hex string
* Type: string
* Default: `FF00FF`
* &gt; 000000
* &lt; FFFFFF
#### `duration`
Timer duration in seconds
* Type: number
* Default: `5`
* &gt; 0
* &lt; 6000
#### `name`
Timer caption
* Type: string
* Default: `Respawn`
<!--modlib:conf-->

View File

@ -1,9 +1,6 @@
local modname = minetest.get_current_modname()
timer = {
name = "Respawn",
duration = 5,
color = "FF00FF"
}
conf = modlib.mod.configuration()
local timer = conf.timer
bone_names_by_model = {
default = {"Head", "Body", "Arm_Right", "Arm_Left", "Leg_Right", "Leg_Left"}
}

33
schema.lua Normal file
View File

@ -0,0 +1,33 @@
return {
type = "table",
entries = {
timer = {
type = "table",
entries = {
name = {
description = "Timer caption",
type = "string",
default = "Respawn"
},
duration = {
description = "Timer duration in seconds",
type = "number",
range = {
min = 0,
max = 6e3
},
default = 5
},
color = {
description = "Timer fill color as hex string",
type = "string",
range = {
min = "000000",
max = "FFFFFF"
},
default = "FF00FF"
}
}
}
}
}

7
settingtypes.txt Normal file
View File

@ -0,0 +1,7 @@
[*respawn_timer.timer]
# Timer fill color as hex string
respawn_timer.timer.color (Respawn timer Timer Color) string FF00FF
# Timer duration in seconds
respawn_timer.timer.duration (Respawn timer Timer Duration) float 5
# Timer caption
respawn_timer.timer.name (Respawn timer Timer Name) string Respawn