Skip to content

Commit

Permalink
Wrench: Fix node registration from other mods
Browse files Browse the repository at this point in the history
  • Loading branch information
SmallJoker committed Jan 29, 2023
1 parent 86e083c commit 9b7c44b
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions wrench/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,26 @@ local function restore(pos, placer, itemstack)
return itemstack
end

for name, info in pairs(wrench.registered_nodes) do
local olddef = minetest.registered_nodes[name]
if olddef then
local newdef = {}
for key, value in pairs(olddef) do
newdef[key] = value
minetest.register_on_mods_loaded(function()
-- Delayed registration for foreign mod support
for name, info in pairs(wrench.registered_nodes) do
local olddef = minetest.registered_nodes[name]
if olddef then
local newdef = {}
for key, value in pairs(olddef) do
newdef[key] = value
end
newdef.stack_max = 1
newdef.description = S("%s with items"):format(newdef.description)
newdef.groups = {}
newdef.groups.not_in_creative_inventory = 1
newdef.on_construct = nil
newdef.on_destruct = nil
newdef.after_place_node = restore
minetest.register_node(":"..get_pickup_name(name), newdef)
end
newdef.stack_max = 1
newdef.description = S("%s with items"):format(newdef.description)
newdef.groups = {}
newdef.groups.not_in_creative_inventory = 1
newdef.on_construct = nil
newdef.on_destruct = nil
newdef.after_place_node = restore
minetest.register_node(":"..get_pickup_name(name), newdef)
end
end
end)

minetest.register_tool("wrench:wrench", {
description = S("Wrench"),
Expand Down

0 comments on commit 9b7c44b

Please sign in to comment.