cache/
storage/
+players/
+!players/.gitkeep
-elidragon = {}
+local proxy = {
+ WORLDS = {"lobby", "creative", "survival", "skyblock"},
+}
+
+elidragon = setmetatable({}, {
+ __index = function(t, k)
+ return proxy[k]
+ end,
+ __newindex = function(t, k, v)
+ assert(not proxy[k])
+ proxy[k] = v
+ end,
+})
name = elidragon
author = Fleckenstein
-description = Initalizer for the Elidragon v2 API
+description = Safe API Initalizer for the Elidragon v2, makes sure that every module is only defined once. Also contains constants
--- /dev/null
+local function class(classdef)
+ local metatable = {
+ __index = classdef,
+ }
+
+ return function (...)
+ local object = setmetatable({}, metatable)
+ if object.constructor then
+ object:constructor(...)
+ end
+ return object
+ end
+end
+
+elidragon.class = class
-local plot, schems = elidragon.plot, elidragon.schems
+local plot, plotmg, schems = elidragon.plot, elidragon.plotmg, elidragon.schems
plot.config = {
gap = 50,
road_width = 10,
- mapgen = {
- min_y = 9,
- max_y = 9,
- c_border = minetest.get_content_id("mcl_stairs:slab_stonebrick"),
- road_schem = "elidragon_creative_road",
- road_schem_offset = -3,
- },
- claiming = {
- enable_autoclaim_command = true,
- max_plots = 5,
- },
+ enable_autoclaim_command = true,
+ max_plots_per_player = 5,
+}
+
+plotmg.config = {
+ min_y = 9,
+ max_y = 9,
+ c_border = minetest.get_content_id("mcl_stairs:slab_stonebrick"),
+ road_schem = "elidragon_creative_road",
+ road_schem_offset = -3,
}
schems.load("elidragon_creative_road")
name = elidragon_creative
author = Fleckenstein
description = Creative gamemode for Elidragon v2
-depends = elidragon, elidragon_plot, elidragon_schems, mcl_core
+depends = elidragon, elidragon_plot, elidragon_plotmg, elidragon_schems, mcl_core
--- /dev/null
+local class = elidragon.class
+
+local db = {}
+
+local paths = {}
+local worldpath = minetest.get_worldpath()
+
+function db:constructor(name, initial_data, dir)
+ paths[self] = dir or worldpath .. "/" .. name .. ".json"
+ self:load(initial_data or {})
+end
+
+function db:load(initial_data)
+ local file = io.open(paths[self], "r")
+ local data = file and minetest.parse_json(file:read()) or {}
+ if file then
+ file:close()
+ end
+ for k, v in pairs(data) do
+ self[k] = v
+ end
+ for k, v in pairs(initial_data) do
+ if not rawget(self, k) then
+ self[k] = v
+ end
+ end
+end
+
+function db:save()
+ local file = assert(io.open(paths[self], "w"))
+ file:write(minetest.write_json(self))
+ file:close()
+end
+
+function db:close()
+ self:save()
+ paths[self] = nil
+end
+
+minetest.register_on_shutdown(function()
+ for d in pairs(private) do
+ d:save()
+ end
+end)
+
+elidragon.db = class(db)
--- /dev/null
+name = elidragon_db
+author = Fleckenstein
+description = Easily migratable JSON databases for Elidragon v2, supports custom paths and safe usage of insecure environment
+depends = elidragon, elidragon_class
--- /dev/null
+local db = elidragon.db
+
+local playerdb = {
+ initial_data = {},
+ players = {},
+}
+
+local players = playerdb.players
+local env = assert(minetest.request_insecure_environment())
+
+minetest.register_on_joinplayer(function (player)
+ local name = player:get_player_name()
+ if name ~= "rpc" then
+ players[name] = db(name, playerdb.initial_data, "players", env)
+ end
+end)
+
+minetest.register_on_leaveplayer(function (player)
+ local name = player:get_player_name()
+ if name ~= "rpc" then
+ players[name]:close()
+ players[name] = nil
+ end
+end)
+
+elidragon.playerdb = playerdb
--- /dev/null
+name = elidragon_playerdb
+author = Fleckenstein
+description = Per-player modular storage shared between worlds for Elidragon v2, multiserver compatible
+depends = elidragon, elidragon_db
local plot = {}
-minetest.register_on_generated(function(minp, maxp)
- local config = assert(plot.config)
-
- local mgconfig = config.mapgen
-
- if not mgconfig then
- return
- end
+local old_is_protected = minetest.is_protected
- local min_y, max_y = mgconfig.min_y, mgconfig.max_y
-
- if maxp.y < min_y or minp.y > max_y then
- return
- end
-
- local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
- local data = vm:get_data()
- local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax})
-
- local void_layer = mgconfig.void_layer
-
- if void_layer then
- for idx in area:iter(minp.x, math.max(minp.y, void_layer.min_y), minp.z, maxp.x, math.min(maxp.y, void_layer.max_y), mapx.z) do
- data[idx] = void_layer.c_void
- end
- end
-
- local function do_multiples(low, high, base, add, func)
- for p = math.ceil(low / base), math.floor(high / base) do
- func(p * base + add)
- end
- end
-
- local function do_borders(low, high, base, road, func)
- do_multiples(low - road, high - road, base, road, func)
- do_multiples(low + road, high + road, base, -road, func)
- end
-
- min_y, max_y = math.max(minp.y, min_y), math.min(maxp.y, max_y)
-
- local gap, road_width = config.gap, config.road_width
- local road_width_half = road_width / 2
-
- do_borders(minp.x, maxp.x, gap, road_width_half, function(x)
- do_multiples(minp.z - gap + road_width_half, maxp.z - road_width_half, gap, road_width_half, function(start_z)
- for idx in area:iter(x, min_y, math.max(minp.z, start_z), x, max_y, math.min(maxp.z, start_z + gap - road_width)) do
- data[idx] = mgconfig.c_border
- end
- end)
- end)
-
- do_borders(minp.z, maxp.z, gap, road_width_half, function(z)
- do_multiples(minp.x - gap + road_width_half, maxp.x - road_width_half, gap, road_width_half, function(start_x)
- for idx in area:iter(math.max(minp.x, start_x), min_y, z, math.min(maxp.x, start_x + gap - road_width), max_y, z) do
- data[idx] = mgconfig.c_border
- end
- end)
- end)
-
- vm:set_data(data)
- vm:calc_lighting()
- vm:update_liquids()
- vm:write_to_map()
-
- local road_schem = mgconfig.road_schem
-
- if road_schem and min_y == mgconfig.min_y then
- do_multiples(minp.x, maxp.x, gap, 0, function(x)
- do_multiples(minp.z, maxp.z, gap, 0, function(z)
- elidragon.schems.add(vector.new(x + road_width_half, min_y + mgconfig.road_schem_offset, z - road_width_half + 1), road_schem)
- elidragon.schems.add(vector.new(x - road_width_half + 1, min_y + mgconfig.road_schem_offset, z + road_width_half), road_schem .. "_flipped")
- end)
- end)
- end
-end)
+function minetest.is_protected(pos, name)
+ return old_is_protected(pos, name)
+end
elidragon.plot = plot
name = elidragon_plot
author = Fleckenstein
description = Flexible plot system for Elidragon v2
-depends = elidragon, mcl_mapgen_core
+depends = elidragon
--- /dev/null
+local plot, schems = elidragon.plot, elidragon.schems
+
+local plotmg = {}
+
+minetest.register_on_generated(function(minp, maxp)
+ local config = assert(plot.config)
+ local mgconfig = assert(plotmg.config)
+
+ local min_y, max_y = mgconfig.min_y, mgconfig.max_y
+
+ if maxp.y < min_y or minp.y > max_y then
+ return
+ end
+
+ local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
+ local data = vm:get_data()
+ local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax})
+
+ local void_layer = mgconfig.void_layer
+
+ if void_layer then
+ for idx in area:iter(minp.x, math.max(minp.y, void_layer.min_y), minp.z, maxp.x, math.min(maxp.y, void_layer.max_y), mapx.z) do
+ data[idx] = void_layer.c_void
+ end
+ end
+
+ local function do_multiples(low, high, base, add, func)
+ for p = math.ceil(low / base), math.floor(high / base) do
+ func(p * base + add)
+ end
+ end
+
+ local function do_borders(low, high, base, road, func)
+ do_multiples(low - road, high - road, base, road, func)
+ do_multiples(low + road, high + road, base, -road, func)
+ end
+
+ min_y, max_y = math.max(minp.y, min_y), math.min(maxp.y, max_y)
+
+ local gap, road_width = config.gap, config.road_width
+ local road_width_half = road_width / 2
+
+ do_borders(minp.x, maxp.x, gap, road_width_half, function(x)
+ do_multiples(minp.z - gap + road_width_half, maxp.z - road_width_half, gap, road_width_half, function(start_z)
+ for idx in area:iter(x, min_y, math.max(minp.z, start_z), x, max_y, math.min(maxp.z, start_z + gap - road_width)) do
+ data[idx] = mgconfig.c_border
+ end
+ end)
+ end)
+
+ do_borders(minp.z, maxp.z, gap, road_width_half, function(z)
+ do_multiples(minp.x - gap + road_width_half, maxp.x - road_width_half, gap, road_width_half, function(start_x)
+ for idx in area:iter(math.max(minp.x, start_x), min_y, z, math.min(maxp.x, start_x + gap - road_width), max_y, z) do
+ data[idx] = mgconfig.c_border
+ end
+ end)
+ end)
+
+ vm:set_data(data)
+ vm:calc_lighting()
+ vm:update_liquids()
+ vm:write_to_map()
+
+ local road_schem = mgconfig.road_schem
+
+ if road_schem and min_y == mgconfig.min_y then
+ do_multiples(minp.x, maxp.x, gap, 0, function(x)
+ do_multiples(minp.z, maxp.z, gap, 0, function(z)
+ schems.add(vector.new(x + road_width_half, min_y + mgconfig.road_schem_offset, z - road_width_half + 1), road_schem)
+ schems.add(vector.new(x - road_width_half + 1, min_y + mgconfig.road_schem_offset, z + road_width_half), road_schem .. "_flipped")
+ end)
+ end)
+ end
+end)
+
+elidragon.plotmg = plotmg
--- /dev/null
+name = elidragon_plotmg
+author = Fleckenstein
+description = Plot map generation for Elidragon v2
+depends = elidragon, elidragon_plot, elidragon_schems, mcl_mapgen_core
-local plot = elidragon.plot
+local plot, plotmg = elidragon.plot, elidragon.plotmg
plot.config = {
gap = 1000,
road_width = 100,
- --[[min_y = 2000,
- max_y = 31000,]]--
- mapgen = {
+ min_y = 2000,
+ max_y = 31000,
+ auto_allocation = true,
+ on_claim = function() -- create island and move there
+ end
+}
+
+plotmg.config = {
+ min_y = 1000,
+ max_y = 31000,
+ void_layer = {
min_y = 1000,
- max_y = 31000,
- void_layer = {
- min_y = 1000,
- max_y = 2000,
- c_void = minetest.get_content_id("mcl_core:void"),
- },
- c_border = minetest.get_content_id("mcl_core:barrier"), -- ToDo: make world border
+ max_y = 2000,
+ c_void = minetest.get_content_id("mcl_core:void"),
},
- --[[claiming = {
- auto_allocation = true,
- on_claim = function() -- create island and move there
- end
- },]]--
+ c_border = minetest.get_content_id("mcl_core:barrier"), -- ToDo: make world border
}
elidragon.skyblock = {}
name = elidragon_skyblock
author = Fleckenstein
description = Skyblock gamemode for Elidragon v2
-depends = elidragon, elidragon_plot, mcl_core
+depends = elidragon, elidragon_plot, elidragon_plotmg, mcl_core
player_backend = sqlite3
load_mod_default = false
load_mod_elidragon = true
+load_mod_elidragon_class = true
load_mod_elidragon_creative = true
+load_mod_elidragon_db = true
load_mod_elidragon_grouplist = false
load_mod_elidragon_luckyblock = false
+load_mod_elidragon_playerdb = true
load_mod_elidragon_plot = true
+load_mod_elidragon_plotmg = true
load_mod_elidragon_random = false
load_mod_elidragon_request = true
load_mod_elidragon_schems = true
player_backend = sqlite3
load_mod_default = false
load_mod_elidragon = true
+load_mod_elidragon_class = true
load_mod_elidragon_creative = false
+load_mod_elidragon_db = false
load_mod_elidragon_grouplist = false
load_mod_elidragon_luckyblock = false
+load_mod_elidragon_playerdb = true
load_mod_elidragon_plot = false
+load_mod_elidragon_plotmg = false
load_mod_elidragon_random = false
load_mod_elidragon_request = false
load_mod_elidragon_schems = false
player_backend = sqlite3
load_mod_default = true
load_mod_elidragon = true
+load_mod_elidragon_class = true
load_mod_elidragon_creative = false
+load_mod_elidragon_db = true
load_mod_elidragon_grouplist = true
load_mod_elidragon_luckyblock = true
+load_mod_elidragon_playerdb = true
load_mod_elidragon_plot = true
+load_mod_elidragon_plotmg = true
load_mod_elidragon_random = false
load_mod_elidragon_request = true
load_mod_elidragon_schems = false
player_backend = sqlite3
load_mod_default = false
load_mod_elidragon = true
+load_mod_elidragon_class = true
load_mod_elidragon_creative = false
+load_mod_elidragon_db = true
load_mod_elidragon_grouplist = false
load_mod_elidragon_luckyblock = false
+load_mod_elidragon_playerdb = true
load_mod_elidragon_plot = false
+load_mod_elidragon_plotmg = false
load_mod_elidragon_random = false
load_mod_elidragon_request = true
load_mod_elidragon_schems = false