Add autogenerated settingtypes, clarifying comments, improved & fixed constraints

master
Lars Mueller 2020-06-02 23:10:58 +02:00
parent 371ac98a6e
commit d522467c36
5 changed files with 47 additions and 15 deletions

View File

@ -477,6 +477,7 @@ if speedup then
neighbors[index] = neighbors[index] or 0
end
local delta = (cell and 1) or -1
-- This won't give out of bounds because it only iterates the inside of the voxelarea (content)
for _, offset in pairs(self.offsets) do
local newindex = index + offset
neighbors[newindex] = (neighbors[newindex] or 0) + delta
@ -514,6 +515,7 @@ function calculate_neighbors(self)
self.neighbors = neighbors
for index, _ in pairs(cells) do
neighbors[index] = neighbors[index] or 0
-- This won't give out of bounds because it only iterates the inside of the voxelarea (content)
for _, offset in pairs(offsets) do
local new_index = index + offset
neighbors[new_index] = (neighbors[new_index] or 0) + 1
@ -577,6 +579,7 @@ else
for index in iter_content(self) do
local c_id = data[index]
local amount = 0
-- This won't give out of bounds because it only iterates the inside of the voxelarea (content)
for _, offset in pairs(offsets) do
if data[index + offset] == c_cell then
amount = amount + 1

View File

@ -12,7 +12,7 @@ local function register_chatcommand(cmd, desc, func, param)
if not arena:is_owner(name) and not is_cellestial(name) then
return false, "Not an owner of the current arena"
end
return unpack({ func(arena, name, params) })
return func(arena, name, params)
end
}
)
@ -368,7 +368,7 @@ cmdlib.register_chatcommand(
if not player then
return false, "You need to be online to teleport"
end
return unpack({create_teleport_request(name, arena, "pos", vector)})
return create_teleport_request(name, arena, "pos", vector)
end
return success, arena
end
@ -389,7 +389,7 @@ cmdlib.register_chatcommand(
if not arena then
return false, "No arena with the ID #"..id
end
return unpack({create_teleport_request(name, arena, "id", id)})
return create_teleport_request(name, arena, "id", id)
end
}
)
@ -506,7 +506,7 @@ cmdlib.register_chatcommand(
params = "<x> <y> <z> <width> <height> <length> [name] {owners}",
description = "Create a new arena",
func = function(sendername, params)
return unpack({ create_arena(sendername, params, {}) })
return create_arena(sendername, params, {})
end
}
)
@ -521,7 +521,7 @@ cmdlib.register_chatcommand(
if not player then
return false, "You need to be online in-game to use the command."
end
return unpack({ create_arena(sendername, params, vector.floor(player:get_pos())) })
return create_arena(sendername, params, vector.floor(player:get_pos()))
end
}
)

View File

@ -1,10 +1,9 @@
-- TODO func = int is deprecated and only kept for compatibility
-- HACK 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 pos_int = { type = "number", range = { 1 }, int = true, func = int }
local component = { type = "number", range = { 0, 255 }, int = true, func = int }
local color = { type = "table", children = {r = component, g = component, b = component} }
local node_colors = { fill = color, edge = color }
local vector = { type = "table", children = { x = pos_int, y = pos_int, z = pos_int } }
local node_colors = { type = "table", children = {fill = color, edge = color} }
local conf_spec = {
type = "table",
children = {
@ -18,11 +17,14 @@ local conf_spec = {
max_steps = pos_int,
request_duration = pos_int,
arena_defaults = {
name = { type = "string" },
dimension = vector,
search_origin = vector,
steps = pos_int,
threshold = { type = "number", range = {0, 1} }
type = "table",
children = {
name = { type = "string" },
dimension = { type = "table", children = { x = pos_int, y = pos_int, z = pos_int } },
search_origin = { type = "table", children = { x = {type="number"}, y = {type="number"}, z = {type="number"} } },
steps = pos_int,
threshold = { type = "number", range = {0, 1} }
}
},
creative = { type = "boolean" },
speedup = { type = "boolean" },

View File

@ -123,7 +123,7 @@ minetest.register_node("cellestial:cell", {
if arena and arena:is_owner(digger:get_player_name()) then
arena:set_cell(pos)
else
return unpack{minetest.node_dig(pos, node, digger)}
return minetest.node_dig(pos, node, digger)
end
if not creative then
local leftover = digger:get_inventory():add_item("main", "cellestial:cell")
@ -150,7 +150,7 @@ minetest.register_node("cellestial:cell", {
if arena and arena:is_content(pos) and arena:is_owner(placer:get_player_name()) then
arena:set_cell(pos, true)
else
return unpack{minetest.item_place_node(itemstack, placer, pointed_thing)}
return minetest.item_place_node(itemstack, placer, pointed_thing)
end
if not creative then
itemstack:take_item()

27
settingtypes.txt Normal file
View File

@ -0,0 +1,27 @@
cellestial.speedup (Cellestial speedup) bool true
cellestial.creative (Cellestial creative) bool true
cellestial.arena_defaults.dimension.y (Cellestial arena_defaults dimension y) int 80 1 1073741824
cellestial.arena_defaults.dimension.x (Cellestial arena_defaults dimension x) int 80 1 1073741824
cellestial.arena_defaults.dimension.z (Cellestial arena_defaults dimension z) int 80 1 1073741824
cellestial.arena_defaults.threshold (Cellestial arena_defaults threshold) float 0.5 0.000000 1.000000
cellestial.arena_defaults.search_origin.y (Cellestial arena_defaults search_origin y) float 0
cellestial.arena_defaults.search_origin.x (Cellestial arena_defaults search_origin x) float 0
cellestial.arena_defaults.search_origin.z (Cellestial arena_defaults search_origin z) float 0
cellestial.arena_defaults.name (Cellestial arena_defaults name) string unnamed
cellestial.arena_defaults.steps (Cellestial arena_defaults steps) int 1 1 1073741824
cellestial.request_duration (Cellestial request_duration) int 30 1 1073741824
cellestial.mapcache (Cellestial mapcache) bool false
cellestial.colors.border.fill.r (Cellestial colors border fill r) int 77 0 255
cellestial.colors.border.fill.b (Cellestial colors border fill b) int 77 0 255
cellestial.colors.border.fill.g (Cellestial colors border fill g) int 77 0 255
cellestial.colors.border.edge.r (Cellestial colors border edge r) int 51 0 255
cellestial.colors.border.edge.b (Cellestial colors border edge b) int 51 0 255
cellestial.colors.border.edge.g (Cellestial colors border edge g) int 51 0 255
cellestial.colors.cell.fill.r (Cellestial colors cell fill r) int 0 0 255
cellestial.colors.cell.fill.b (Cellestial colors cell fill b) int 0 0 255
cellestial.colors.cell.fill.g (Cellestial colors cell fill g) int 255 0 255
cellestial.colors.cell.edge.r (Cellestial colors cell edge r) int 0 0 255
cellestial.colors.cell.edge.b (Cellestial colors cell edge b) int 0 0 255
cellestial.colors.cell.edge.g (Cellestial colors cell edge g) int 128 0 255
cellestial.max_steps (Cellestial max_steps) int 10 1 1073741824
cellestial.place_inside_player (Cellestial place_inside_player) bool false