Add /land list

master
rubenwardy 2018-11-22 18:32:19 +00:00
parent 1ff818c28a
commit 11b1751eb7
4 changed files with 23 additions and 15 deletions

View File

@ -16,7 +16,7 @@ ChatCmdBuilder.new("banking", function(cmd)
end
acc.balance = acc.balance + amount
return true, "Gave " .. acc.balance .. " to " .. owner
return true, "Gave " .. amount .. " to " .. owner
end)
cmd:sub("transfer :to:owner :amount:int :reason:text", function(name, to, amount, reason)

View File

@ -39,20 +39,16 @@ function land.get_area_tree(list)
return root, item_by_id
end
function land.get_for_player(pname)
assert(type(pname) == "string")
assert(minetest.player_exists(pname))
local comp = company.get_active(pname)
if not comp then
return nil
function land.get_all(owner)
local lands = {}
for id, area in pairs(areas.areas) do
if area.land_type and area.owner == owner then
area.id = id
lands[#lands + 1] = area
end
end
return land.get_for_company(comp)
end
function land.get_for_company(comp)
return lands
end
function land.get_by_pos(pos)

View File

@ -4,7 +4,7 @@ minetest.register_privilege("land_admin", {
ChatCmdBuilder.new("land", function(cmd)
cmd:sub("debug", function(name)
cmd:sub("admin", function(name)
if not minetest.check_player_privs(name, { land_admin = true }) then
return false, "Missing privilege: land_admin"
end
@ -13,6 +13,18 @@ ChatCmdBuilder.new("land", function(cmd)
return true, "Showed land debug form"
end)
cmd:sub("list", function(name)
local comp = company.get_active(name)
local owner = comp and comp.name or name
local areas = land.get_all(owner)
return true, "Areas owned by " .. owner .. "\n" ..
table.concat(_.map(areas, function(area)
return " - " .. area.name .. " [id=" .. area.id .. "]"
end), "\n")
end)
cmd:sub("owner :id:int :newowner:owner", function(name, id, newowner)
return land.transfer(id, newowner, name)
end)

View File

@ -1,2 +1,2 @@
name = land
depends = company, banking, areas, audit
depends = company, banking, areas, audit, lib_underscore