Add /land list
parent
1ff818c28a
commit
11b1751eb7
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
name = land
|
||||
depends = company, banking, areas, audit
|
||||
depends = company, banking, areas, audit, lib_underscore
|
||||
|
|
Loading…
Reference in New Issue