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

16
pos.lua
View File

@ -11,6 +11,14 @@ areas.set_pos = {}
areas.pos1 = {}
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", {
params = "<ID>",
description = "Select a area by id.",
@ -129,14 +137,6 @@ function areas:getPos(playerName)
return areas:sortPos(pos1, pos2)
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)
areas.pos1[playerName] = posLimit(pos)
areas.markPos1(playerName)