Merged config help into Readme, code quality improvements, fixes
This commit is contained in:
parent
4219d0a78e
commit
2c0d96f790
69
Readme.md
69
Readme.md
@ -1,4 +1,4 @@
|
|||||||

|

|
||||||
|
|
||||||
# Voxelizer (`voxelizer`)
|
# Voxelizer (`voxelizer`)
|
||||||
|
|
||||||
@ -8,6 +8,7 @@ Another mighty world manipulation tool like [`worldedit`](https://github.com/Ube
|
|||||||
## About
|
## About
|
||||||
|
|
||||||
**Note: Voxelizer needs to be added to the "trusted mods" if "mod security" is enabled. You should always ensure that all your "trusted mods" run in a safe environment (which means that all other mods are safe as well).**
|
**Note: Voxelizer needs to be added to the "trusted mods" if "mod security" is enabled. You should always ensure that all your "trusted mods" run in a safe environment (which means that all other mods are safe as well).**
|
||||||
|
|
||||||
Depends on [`modlib`](https://github.com/appgurueu/modlib) and [`cmdlib`](https://github.com/appgurueu/cmdlib). IntelliJ IDEA with EmmyLua plugin project.
|
Depends on [`modlib`](https://github.com/appgurueu/modlib) and [`cmdlib`](https://github.com/appgurueu/cmdlib). IntelliJ IDEA with EmmyLua plugin project.
|
||||||
Code licensed under the [GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html) for now.
|
Code licensed under the [GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html) for now.
|
||||||
|
|
||||||
@ -86,7 +87,8 @@ On my system (Java 11), the output was :
|
|||||||
The supported image file formats are : JPG, jpg, tiff, bmp, BMP, gif, GIF, WBMP, png, PNG, JPEG, tif, TIF, TIFF, wbmp, jpeg
|
The supported image file formats are : JPG, jpg, tiff, bmp, BMP, gif, GIF, WBMP, png, PNG, JPEG, tif, TIF, TIFF, wbmp, jpeg
|
||||||
```
|
```
|
||||||
|
|
||||||
Internally, the `SIF` (`.sif`, "Simple Image File") file format (just gave it some name) is used :
|
Internally, the `SIF` (`.sif`, "Simple Image File") file format (just gave it some name) is used:
|
||||||
|
|
||||||
* 4 byte header : 2 times a 2 byte unsigned short, first is width, second is height
|
* 4 byte header : 2 times a 2 byte unsigned short, first is width, second is height
|
||||||
* Followed by uncompressed image data : array of 4 byte tuples, consisting of ARGB unsigned bytes, positions in array are calculated as `x + y * width`
|
* Followed by uncompressed image data : array of 4 byte tuples, consisting of ARGB unsigned bytes, positions in array are calculated as `x + y * width`
|
||||||
|
|
||||||
@ -132,3 +134,66 @@ Everything else should not be ticked.
|
|||||||
* `place [scale]` - place model with given scale (defaults to `1`)
|
* `place [scale]` - place model with given scale (defaults to `1`)
|
||||||
* `download <url> [filename]` - download a file from the internet using a GET request, requires `voxelizer:download` priv additionally.
|
* `download <url> [filename]` - download a file from the internet using a GET request, requires `voxelizer:download` priv additionally.
|
||||||
File will be downloaded to `<worldpath>/media/filename`. The URL filename will be taken if `filename` is not specified.
|
File will be downloaded to `<worldpath>/media/filename`. The URL filename will be taken if `filename` is not specified.
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
JSON Configuration: `<worldpath>/config/voxelizer.json`
|
||||||
|
Text Logs: `<worldpath>/logs/voxelizer/<date>.txt`
|
||||||
|
Readme : `<modpath/gamepath>/voxelizer/Readme.md`
|
||||||
|
Default Configuration : `<modpath/gamepath>/voxelizer/default_config.json`
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"max_precision" : 15,
|
||||||
|
"download" : true,
|
||||||
|
"defaults" : {
|
||||||
|
"precision" : 4,
|
||||||
|
"min_density" : 0.1,
|
||||||
|
"dithering" : 10,
|
||||||
|
"placement" : 1,
|
||||||
|
"color_choosing" : 1,
|
||||||
|
"filtering" : 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `max_precision`
|
||||||
|
|
||||||
|
Integer, maximum settable precision.
|
||||||
|
|
||||||
|
#### `download`
|
||||||
|
|
||||||
|
Boolean, whether to enable the `/vox download` chatcommand.
|
||||||
|
|
||||||
|
#### `defaults`
|
||||||
|
|
||||||
|
Dictionary / table, default names assigned to corresponding values. Possible names below.
|
||||||
|
|
||||||
|
##### `min_density`
|
||||||
|
|
||||||
|
Float between 0 and 1. Minimum density default.
|
||||||
|
|
||||||
|
##### `precision`
|
||||||
|
|
||||||
|
Integer > 1 and < 100. Precision default.
|
||||||
|
|
||||||
|
##### `dithering`
|
||||||
|
|
||||||
|
Default dithering algorithm ID (see `/vox dithering`).
|
||||||
|
|
||||||
|
##### `placement`
|
||||||
|
|
||||||
|
Default placement mode ID (see `/vox placement`).
|
||||||
|
|
||||||
|
##### `color_choosing`
|
||||||
|
|
||||||
|
Default color choosing algorithm ID (see `/vox color_choosing`).
|
||||||
|
|
||||||
|
##### `filtering`
|
||||||
|
|
||||||
|
Default filtering algorithm ID (see `/vox filtering`).
|
||||||
|
|
||||||
|
##### `model` / `texture` / `nodemap`
|
||||||
|
|
||||||
|
Optional default filenames. Files will be searched in world's media folder.
|
||||||
|
If not given, Voxelizer falls back to default files from mod's media folder.
|
103
conf.lua
103
conf.lua
@ -1,65 +1,62 @@
|
|||||||
-- TODO func = int is deprecated and only kept for compatibility
|
-- TODO func = int is deprecated and only kept for compatibility
|
||||||
local int = function(value) if value % 1 ~= 0 then return "Integer instead of float expected" end end
|
local int = function(value) if value % 1 ~= 0 then return "Integer instead of float expected" end end
|
||||||
local conf_spec = {
|
local conf_spec = {type = "table", children = {
|
||||||
type = "table",
|
max_precision = {
|
||||||
children = {
|
type = "number",
|
||||||
max_precision = {
|
int = true,
|
||||||
type = "number",
|
func = int
|
||||||
int = true,
|
},
|
||||||
func = int
|
download = {
|
||||||
|
type = "boolean"
|
||||||
|
},
|
||||||
|
defaults = {
|
||||||
|
type = "table",
|
||||||
|
possible_keys = {
|
||||||
|
model = {type = "string"},
|
||||||
|
texture = {type = "string"},
|
||||||
|
nodemap = {type = "string"}
|
||||||
},
|
},
|
||||||
download = {
|
required_keys = {
|
||||||
type = "boolean"
|
min_density = {type = "number", range = {0, 1}},
|
||||||
},
|
precision = {
|
||||||
defaults = {
|
type = "number",
|
||||||
type = "table",
|
range = {1, 100},
|
||||||
possible_keys = {
|
int = true,
|
||||||
model = {type = "string"},
|
func = int
|
||||||
texture = {type = "string"},
|
|
||||||
nodemap = {type = "string"}
|
|
||||||
},
|
},
|
||||||
required_keys = {
|
dithering = {
|
||||||
min_density = {type = "number", range = {0, 1}},
|
type = "number",
|
||||||
precision = {
|
range = {1, 10},
|
||||||
type = "number",
|
int = true,
|
||||||
range = {1, 100},
|
func = int
|
||||||
int = true,
|
},
|
||||||
func = int
|
placement = {
|
||||||
},
|
type = "number",
|
||||||
dithering = {
|
range = {1, 3},
|
||||||
type = "number",
|
int = true,
|
||||||
range = {1, 10},
|
func = int
|
||||||
int = true,
|
},
|
||||||
func = int
|
color_choosing = {
|
||||||
},
|
type = "number",
|
||||||
placement = {
|
range = {1, 2},
|
||||||
type = "number",
|
int = true,
|
||||||
range = {1, 3},
|
func = int
|
||||||
int = true,
|
},
|
||||||
func = int
|
filtering = {
|
||||||
},
|
type = "number",
|
||||||
color_choosing = {
|
range = {1, 2},
|
||||||
type = "number",
|
int = true,
|
||||||
range = {1, 2},
|
func = int
|
||||||
int = true,
|
|
||||||
func = int
|
|
||||||
},
|
|
||||||
filtering = {
|
|
||||||
type = "number",
|
|
||||||
range = {1, 2},
|
|
||||||
int = true,
|
|
||||||
func = int
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
}
|
}}
|
||||||
|
|
||||||
config=modlib.conf.import("voxelizer", conf_spec)
|
config = modlib.conf.import("voxelizer", conf_spec)
|
||||||
local mediapath = minetest.get_modpath("voxelizer").."/default_media/"
|
local mediapath = minetest.get_modpath("voxelizer").."/default_media/"
|
||||||
local fallback_defaults = {texture = mediapath.."character.png", model = mediapath.."character.obj", nodemap = mediapath.."colors.txt"}
|
local fallback_defaults = {texture = mediapath.."character.png", model = mediapath.."character.obj", nodemap = mediapath.."colors.txt"}
|
||||||
for key, alt in pairs(fallback_defaults) do
|
for key, alt in pairs(fallback_defaults) do
|
||||||
if config.defaults[key] == nil then
|
if config.defaults[key] == nil then
|
||||||
config.defaults[key] = alt
|
config.defaults[key] = alt
|
||||||
end
|
end
|
||||||
end
|
end
|
@ -1,47 +0,0 @@
|
|||||||
# Voxelizer - Configuration
|
|
||||||
|
|
||||||
JSON Configuration : `<worldpath>/config/voxelizer.json`
|
|
||||||
|
|
||||||
Text Logs : `<worldpath>/logs/voxelizer/<date>.txt`
|
|
||||||
|
|
||||||
Explaining document(this, Markdown) : `<modpath/gamepath>/voxelizer/config_help.md`
|
|
||||||
|
|
||||||
Readme : `<modpath/gamepath>/voxelizer/Readme.md`
|
|
||||||
|
|
||||||
Default Configuration : `<modpath/gamepath>/voxelizer/default_config.json`
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"max_precision" : 15,
|
|
||||||
"download" : true,
|
|
||||||
"defaults" : {
|
|
||||||
"precision" : 4,
|
|
||||||
"min_density" : 0.1,
|
|
||||||
"dithering" : 10,
|
|
||||||
"placement" : 1,
|
|
||||||
"color_choosing" : 1,
|
|
||||||
"filtering" : 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### `max_precision`
|
|
||||||
Integer, maximum settable precision.
|
|
||||||
#### `download`
|
|
||||||
Boolean, whether to enable the `/vox download` chatcommand.
|
|
||||||
#### `defaults`
|
|
||||||
Dictionairy / table, default names assigned to corresponding values. Possible names below.
|
|
||||||
##### `min_density`
|
|
||||||
Float between 0 and 1. Minimum density default.
|
|
||||||
##### `precision`
|
|
||||||
Integer > 1 and < 100. Precision default.
|
|
||||||
##### `dithering`
|
|
||||||
Default dithering algorithm ID (see `/vox dithering`).
|
|
||||||
##### `placement`
|
|
||||||
Default placement mode ID (see `/vox placement`).
|
|
||||||
##### `color_choosing`
|
|
||||||
Default color choosing algorithm ID (see `/vox color_choosing`).
|
|
||||||
##### `filtering`
|
|
||||||
Default filtering algorithm ID (see `/vox filtering`).
|
|
||||||
##### `model` / `texture` / `nodemap`
|
|
||||||
Optional default filenames. Files will be searched in world's media folder.
|
|
||||||
If not given, Voxelizer falls back to default files from mod's media folder.
|
|
2
main.lua
2
main.lua
@ -102,7 +102,7 @@ function place_obj(params)
|
|||||||
|
|
||||||
local is_protected = function(pos) return true end
|
local is_protected = function(pos) return true end
|
||||||
if params.playername and not params.protection_bypass then
|
if params.playername and not params.protection_bypass then
|
||||||
is_protected = function(pos) return minetest.is_protected(pos, params.playername) end
|
is_protected = function(pos) return minetest.is_protected(pos, params.playername) ~= true end
|
||||||
end
|
end
|
||||||
|
|
||||||
local is_mergeable = function(index) return true end
|
local is_mergeable = function(index) return true end
|
||||||
|
3
settingtypes.txt
Normal file
3
settingtypes.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
voxelizer.max_precision (Voxelizer max_precision) int 15
|
||||||
|
|
||||||
|
voxelizer.download (Voxelizer download) bool true
|
Loading…
x
Reference in New Issue
Block a user