Use a variable for the node definition

Searching a table that can get quite large isn't a good idea.
This commit is contained in:
C1ffisme 2016-04-13 19:49:20 -05:00
parent 843631e760
commit c01f86ff02

View file

@ -119,6 +119,7 @@ minetest.register_craftitem("bucket:bucket_empty", {
local node = minetest.get_node(pointed_thing.under) local node = minetest.get_node(pointed_thing.under)
local liquiddef = bucket.liquids[node.name] local liquiddef = bucket.liquids[node.name]
local item_count = user:get_wielded_item():get_count() local item_count = user:get_wielded_item():get_count()
local node_def = minetest.registered_nodes[node.name]
if liquiddef ~= nil if liquiddef ~= nil
and liquiddef.itemname ~= nil and liquiddef.itemname ~= nil
@ -153,10 +154,10 @@ minetest.register_craftitem("bucket:bucket_empty", {
minetest.add_node(pointed_thing.under, {name="air"}) minetest.add_node(pointed_thing.under, {name="air"})
return ItemStack(giving_back) return ItemStack(giving_back)
elseif minetest.registered_nodes[node.name] then elseif node_def then
-- Buckets will run a node's on_punch function if it is not liquid. -- Buckets will run a node's on_punch function if it is not liquid.
if minetest.registered_nodes[node.name].on_punch then if node_def.on_punch then
minetest.registered_nodes[node.name].on_punch( node_def.on_punch(
pointed_thing.under, pointed_thing.under,
minetest.get_node(pointed_thing.under), minetest.get_node(pointed_thing.under),
user, user,