mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-26 01:03:46 +01:00
rolling-12
This commit is contained in:
parent
faa47ab595
commit
2e0eb885c4
8
conf.lua
8
conf.lua
@ -3,9 +3,9 @@ function get_path(confname)
|
|||||||
return minetest.get_worldpath().."/config/"..confname
|
return minetest.get_worldpath().."/config/"..confname
|
||||||
end
|
end
|
||||||
function load (filename, constraints)
|
function load (filename, constraints)
|
||||||
local config=minetest.parse_json(modlib.file.read(filename))
|
local config = minetest.parse_json(modlib.file.read(filename))
|
||||||
if constraints then
|
if constraints then
|
||||||
local error_message=check_constraints(config, constraints)
|
local error_message = check_constraints(config, constraints)
|
||||||
if error_message then
|
if error_message then
|
||||||
error("Configuration - "..filename.." doesn't satisfy constraints : "..error_message)
|
error("Configuration - "..filename.." doesn't satisfy constraints : "..error_message)
|
||||||
end
|
end
|
||||||
@ -16,8 +16,8 @@ function load_or_create(filename, replacement_file, constraints)
|
|||||||
modlib.file.create_if_not_exists_from_file(filename, replacement_file)
|
modlib.file.create_if_not_exists_from_file(filename, replacement_file)
|
||||||
return load(filename, constraints)
|
return load(filename, constraints)
|
||||||
end
|
end
|
||||||
function import(modname,constraints)
|
function import(modname, constraints)
|
||||||
return load_or_create(get_path(modname)..".json", modlib.mod.get_resource(modname, "default_config.json"),constraints)
|
return load_or_create(get_path(modname)..".json", modlib.mod.get_resource(modname, "default_config.json"), constraints)
|
||||||
end
|
end
|
||||||
function check_constraints(value, constraints)
|
function check_constraints(value, constraints)
|
||||||
local t=type(value)
|
local t=type(value)
|
||||||
|
Loading…
Reference in New Issue
Block a user