mirror of
https://github.com/minetest-mods/areas.git
synced 2024-12-25 18:20:39 +01:00
Add support for area_pos1 and area_pos2 chatcommands to accept coordinates separated by commas AND spaces
This commit is contained in:
parent
c044d49d21
commit
d1d129bb7f
@ -101,10 +101,10 @@ Commands
|
|||||||
* `/area_pos {set,set1,set2,get}` -- Sets the area positions by punching
|
* `/area_pos {set,set1,set2,get}` -- Sets the area positions by punching
|
||||||
nodes or shows the current area positions.
|
nodes or shows the current area positions.
|
||||||
|
|
||||||
* `/area_pos1 [X,Y,Z|X Y Z]` -- Sets area position one to your position or
|
* `/area_pos1 [X Y Z|X,Y,Z|X, Y, Z]` -- Sets area position one to your position or
|
||||||
the one supplied.
|
the one supplied.
|
||||||
|
|
||||||
* `/area_pos2 [X,Y,Z|X Y Z]` -- Sets area position two to your position or
|
* `/area_pos2 [X Y Z|X,Y,Z|X, Y, Z]` -- Sets area position two to your position or
|
||||||
the one supplied.
|
the one supplied.
|
||||||
|
|
||||||
* `/areas_cleanup` -- Removes all ownerless areas.
|
* `/areas_cleanup` -- Removes all ownerless areas.
|
||||||
|
8
pos.lua
8
pos.lua
@ -41,13 +41,13 @@ minetest.register_chatcommand("select_area", {
|
|||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_chatcommand("area_pos1", {
|
minetest.register_chatcommand("area_pos1", {
|
||||||
params = "[X Y Z|X,Y,Z]",
|
params = "[X Y Z|X,Y,Z|X, Y, Z]",
|
||||||
description = S("Set area protection region position @1 to your"
|
description = S("Set area protection region position @1 to your"
|
||||||
.." location or the one specified", "1"),
|
.." location or the one specified", "1"),
|
||||||
privs = {},
|
privs = {},
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
local pos
|
local pos
|
||||||
local found, _, x, y, z = param:find(
|
local found, _, x, y, z = param:gsub(", ", ","):find(
|
||||||
"^(-?%d+)[, ](-?%d+)[, ](-?%d+)$")
|
"^(-?%d+)[, ](-?%d+)[, ](-?%d+)$")
|
||||||
if found then
|
if found then
|
||||||
pos = {x=tonumber(x), y=tonumber(y), z=tonumber(z)}
|
pos = {x=tonumber(x), y=tonumber(y), z=tonumber(z)}
|
||||||
@ -69,12 +69,12 @@ minetest.register_chatcommand("area_pos1", {
|
|||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_chatcommand("area_pos2", {
|
minetest.register_chatcommand("area_pos2", {
|
||||||
params = "[X Y Z|X,Y,Z]",
|
params = "[X Y Z|X,Y,Z|X, Y, Z]",
|
||||||
description = S("Set area protection region position @1 to your"
|
description = S("Set area protection region position @1 to your"
|
||||||
.." location or the one specified", "2"),
|
.." location or the one specified", "2"),
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
local pos
|
local pos
|
||||||
local found, _, x, y, z = param:find(
|
local found, _, x, y, z = param:gsub(", ", ","):find(
|
||||||
"^(-?%d+)[, ](-?%d+)[, ](-?%d+)$")
|
"^(-?%d+)[, ](-?%d+)[, ](-?%d+)$")
|
||||||
if found then
|
if found then
|
||||||
pos = {x=tonumber(x), y=tonumber(y), z=tonumber(z)}
|
pos = {x=tonumber(x), y=tonumber(y), z=tonumber(z)}
|
||||||
|
Loading…
Reference in New Issue
Block a user