Needs to be defined earlier.

This commit is contained in:
Auke Kok 2019-04-03 10:24:02 -07:00
parent 024424ee8b
commit 6e2b9a0a51
4 changed files with 18 additions and 13 deletions

@ -3,13 +3,17 @@ allow_defined_top = true
read_globals = { read_globals = {
"DIR_DELIM", "DIR_DELIM",
"minetest", "core", "core",
"dump", "dump",
"vector", "nodeupdate", "vector", "nodeupdate",
"VoxelManip", "VoxelArea", "VoxelManip", "VoxelArea",
"PseudoRandom", "ItemStack", "PseudoRandom", "ItemStack",
"AreaStore",
"intllib", "intllib",
"default", "default",
table = { fields = { "copy", "getn" } } table = { fields = { "copy", "getn" } }
} }
globals = {
"minetest"
}

@ -383,10 +383,10 @@ minetest.register_chatcommand("area_info", {
table.insert(lines, ("%s spanning up to %dx%dx%d.") table.insert(lines, ("%s spanning up to %dx%dx%d.")
:format(str, size.x, size.y, size.z)) :format(str, size.x, size.y, size.z))
end end
local function priv_limit_info(priv, max_count, max_size) local function priv_limit_info(lpriv, lmax_count, lmax_size)
size_info(("Players with the %q privilege".. size_info(("Players with the %q privilege"..
" can protect up to %d areas"):format( " can protect up to %d areas"):format(
priv, max_count), max_size) lpriv, lmax_count), lmax_size)
end end
if self_prot then if self_prot then
if privs.areas then if privs.areas then

@ -10,7 +10,7 @@ minetest.register_chatcommand("legacy_load_areas", {
minetest.chat_send_player(name, "Converting areas...") minetest.chat_send_player(name, "Converting areas...")
local version = tonumber(param) local version = tonumber(param)
if version == 0 then if version == 0 then
err = areas:node_ownership_load() local err = areas:node_ownership_load()
if err then if err then
minetest.chat_send_player(name, "Error loading legacy file: "..err) minetest.chat_send_player(name, "Error loading legacy file: "..err)
return return
@ -48,6 +48,7 @@ minetest.register_chatcommand("legacy_load_areas", {
function areas:node_ownership_load() function areas:node_ownership_load()
local filename = minetest.get_worldpath().."/owners.tbl" local filename = minetest.get_worldpath().."/owners.tbl"
local tables, err
tables, err = loadfile(filename) tables, err = loadfile(filename)
if err then if err then
return err return err

16
pos.lua

@ -11,6 +11,14 @@ areas.set_pos = {}
areas.pos1 = {} areas.pos1 = {}
areas.pos2 = {} areas.pos2 = {}
local function posLimit(pos)
return {
x = math.max(math.min(pos.x, 31000), -31000),
y = math.max(math.min(pos.y, 31000), -31000),
z = math.max(math.min(pos.z, 31000), -31000)
}
end
minetest.register_chatcommand("select_area", { minetest.register_chatcommand("select_area", {
params = "<ID>", params = "<ID>",
description = "Select a area by id.", description = "Select a area by id.",
@ -129,14 +137,6 @@ function areas:getPos(playerName)
return areas:sortPos(pos1, pos2) return areas:sortPos(pos1, pos2)
end end
local function posLimit(pos)
return {
x = math.max(math.min(pos.x, 31000), -31000),
y = math.max(math.min(pos.y, 31000), -31000),
z = math.max(math.min(pos.z, 31000), -31000)
}
end
function areas:setPos1(playerName, pos) function areas:setPos1(playerName, pos)
areas.pos1[playerName] = posLimit(pos) areas.pos1[playerName] = posLimit(pos)
areas.markPos1(playerName) areas.markPos1(playerName)