Browse Source

make region ids more consistent

main
Hendrik Langer 5 years ago
parent
commit
e19c470547
  1. 11
      chatcommands.lua
  2. 2
      region.lua

11
chatcommands.lua

@ -17,8 +17,8 @@ minetest.register_chatcommand("creative_region", {
local data = region_name
local astore_id = creative_regions.astore:insert_area(edge1, edge2, tostring(data))
if astore_id then
creative_regions:set_region_privs(tostring(astore_id), nil)
minetest.chat_send_player(name, "[creative_regions] New region set. ID: " .. astore_id)
creative_regions:set_region_privs("r"..tostring(astore_id), nil)
minetest.chat_send_player(name, "[creative_regions] New region set. ID: " .. "r"..astore_id)
creative_regions:save_regions()
return true, "Done"
else
@ -36,7 +36,7 @@ minetest.register_chatcommand("creative_region_privs", {
if not player then
return false, "Player not found"
end
local found, _, region_id, privstring = param:find("^([+-]?%a?%d+)%s*,%s*(.+)$")
local found, _, region_id, privstring = param:find("^([ra]%d+)%s*,%s*(.+)$")
if not found or not region_id or not privstring then
return false, "Syntax error"
end
@ -57,11 +57,12 @@ minetest.register_chatcommand("creative_region_rm", {
if not player then
return false, "Player not found"
end
local found, _, region_id = param:find("^([+-]?%d+)%s*$")
local found, _, region_id = param:find("^(r%d+)%s*$")
if not found or not region_id then
return false, "Syntax error"
end
local success = creative_regions.astore:remove_area(tonumber(region_id))
local astore_id = tonumber(string.sub(region_id, 2))
local success = creative_regions.astore:remove_area(astore_id)
if success then
minetest.chat_send_player(name, "[creative_regions] Region " .. region_id .. "removed")
creative_regions:set_region_privs(tostring(region_id), nil)

2
region.lua

@ -11,7 +11,7 @@ function creative_regions:load_regions()
-- local data = "Testregion"
-- local astore_id = self.astore:insert_area(edge1, edge2, tostring(data))
--
-- creative_regions:set_region_privs(astore_id, "+creative, +fast, +fly")
-- creative_regions:set_region_privs("r"..astore_id, "+creative, +fast, +fly")
end
function creative_regions:save_regions()

Loading…
Cancel
Save