display api compat
This commit is contained in:
parent
3dbe0fe166
commit
7efd0ad19b
@ -14,5 +14,5 @@ read_globals = {
|
||||
"minetest",
|
||||
|
||||
-- mods
|
||||
"mapsync", "mtt", "blockexchange", "travelnet"
|
||||
"mapsync", "mtt", "blockexchange", "travelnet", "display_api"
|
||||
}
|
||||
|
27
compat/display_api.lua
Normal file
27
compat/display_api.lua
Normal file
@ -0,0 +1,27 @@
|
||||
local display_nodeids = {}
|
||||
|
||||
minetest.register_on_mods_loaded(function()
|
||||
for nodename, nodedef in pairs(minetest.registered_nodes) do
|
||||
if nodedef.groups and nodedef.groups.display_api then
|
||||
display_nodeids[minetest.get_content_id(nodename)] = true
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
pick_and_place.register_on_place(function(pos1, pos2, nodeids)
|
||||
local match = false
|
||||
for display_nodeid in pairs(display_nodeids) do
|
||||
if nodeids[display_nodeid] then
|
||||
match = true
|
||||
end
|
||||
end
|
||||
|
||||
if not match then
|
||||
return
|
||||
end
|
||||
|
||||
local poslist = minetest.find_nodes_in_area(pos1, pos2, {"group:display_api"})
|
||||
for _, pos in ipairs(poslist) do
|
||||
display_api.update_entities(pos)
|
||||
end
|
||||
end)
|
4
init.lua
4
init.lua
@ -32,6 +32,10 @@ if minetest.get_modpath("travelnet") then
|
||||
dofile(MP .. "/compat/travelnet.lua")
|
||||
end
|
||||
|
||||
if minetest.get_modpath("display_api") then
|
||||
dofile(MP.."/compat/display_api.lua")
|
||||
end
|
||||
|
||||
if minetest.get_modpath("mtt") and mtt.enabled then
|
||||
dofile(MP .. "/configure.spec.lua")
|
||||
dofile(MP .. "/create_tool.spec.lua")
|
||||
|
2
mod.conf
2
mod.conf
@ -1,5 +1,5 @@
|
||||
name = pick_and_place
|
||||
description = Pick and place utility
|
||||
depends = wield_events
|
||||
optional_depends = mapsync, mtt, blockexchange, travelnet
|
||||
optional_depends = mapsync, mtt, blockexchange, travelnet, display_api
|
||||
min_minetest_version = 5.5.0
|
@ -40,6 +40,11 @@ function pick_and_place.remove_area(pos1, pos2)
|
||||
meta:from_table({})
|
||||
end
|
||||
|
||||
local objects = minetest.get_objects_in_area(pos1, pos2)
|
||||
for _, obj in ipairs(objects) do
|
||||
obj:remove()
|
||||
end
|
||||
|
||||
for _, fn in ipairs(removal_callbacks) do
|
||||
fn(pos1, pos2, node_ids)
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user