cleanup
This commit is contained in:
parent
ca635b9d3e
commit
e4b1994c88
54
chat.lua
54
chat.lua
@ -1,58 +1,4 @@
|
||||
|
||||
minetest.register_chatcommand("building_place", {
|
||||
func = function(name, building_name)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
local pos = player:get_pos()
|
||||
local mapblock_pos = mapblock_lib.get_mapblock(pos)
|
||||
|
||||
local t0 = minetest.get_us_time()
|
||||
local success, err = building_lib.do_build(mapblock_pos, building_name, {}, function() end)
|
||||
local diff = minetest.get_us_time() - t0
|
||||
if success then
|
||||
return true, "Placement took " .. diff .. " us"
|
||||
else
|
||||
return false, err
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("building_remove", {
|
||||
func = function(name)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
local pos = player:get_pos()
|
||||
local mapblock_pos = mapblock_lib.get_mapblock(pos)
|
||||
local origin = mapblock_pos
|
||||
|
||||
local data = building_lib.store:get(mapblock_pos)
|
||||
if not data then
|
||||
return false, "no building found"
|
||||
end
|
||||
|
||||
if data.building and data.building.ref then
|
||||
-- resolve link
|
||||
origin = data.building.ref
|
||||
data = building_lib.store:get(data.building.ref)
|
||||
end
|
||||
|
||||
if data.building then
|
||||
local size = data.building.size
|
||||
for x=origin.x,origin.x+size.x-1 do
|
||||
for y=origin.y,origin.y+size.y-1 do
|
||||
for z=origin.z,origin.z+size.z-1 do
|
||||
local offset_mapblock_pos = {x=x, y=y, z=z}
|
||||
-- clear building data
|
||||
building_lib.store:set(offset_mapblock_pos, nil)
|
||||
-- remove mapblock
|
||||
mapblock_lib.clear_mapblock(offset_mapblock_pos)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return true, "removed '" .. data.building.name .. "'"
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("building_info", {
|
||||
func = function(name)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
|
Loading…
x
Reference in New Issue
Block a user