2012-10-30 13:59:41 +06:00
|
|
|
buckets = {}
|
|
|
|
buckets.liquids = {}
|
2012-10-15 16:38:08 +06:00
|
|
|
|
2012-10-30 20:02:00 +06:00
|
|
|
function buckets.register_liquid(name, source, flowing, itemname, inventory_image)
|
2012-10-15 16:38:08 +06:00
|
|
|
|
2012-10-30 13:59:41 +06:00
|
|
|
buckets.liquids[source] = {
|
2012-10-30 20:02:00 +06:00
|
|
|
name = name,
|
2012-10-15 16:38:08 +06:00
|
|
|
source = source,
|
|
|
|
flowing = flowing,
|
|
|
|
itemname = itemname,
|
|
|
|
}
|
2012-10-30 13:59:41 +06:00
|
|
|
buckets.liquids[flowing] = buckets.liquids[source]
|
2012-10-15 16:38:08 +06:00
|
|
|
|
|
|
|
if itemname ~= nil then
|
2012-10-30 13:59:41 +06:00
|
|
|
for i = 1,#metals.list do
|
|
|
|
minetest.register_craftitem(itemname.."_"..metals.list[i], {
|
2012-10-30 20:02:00 +06:00
|
|
|
description = metals.desc_list[i] .. " Bucket with " .. name,
|
2012-11-01 11:59:36 +06:00
|
|
|
inventory_image = "instruments_bucket_"..metals.list[i]..".png^"..inventory_image,
|
2012-10-15 16:38:08 +06:00
|
|
|
stack_max = 1,
|
|
|
|
liquids_pointable = true,
|
|
|
|
on_use = function(itemstack, user, pointed_thing)
|
|
|
|
-- Must be pointing to node
|
|
|
|
if pointed_thing.type ~= "node" then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
n = minetest.env:get_node(pointed_thing.under)
|
2012-11-09 21:36:41 +06:00
|
|
|
if minetest.registered_nodes[n.name].buildable_to then
|
|
|
|
minetest.env:add_node(pointed_thing.under, {name=source})
|
|
|
|
else
|
|
|
|
n = minetest.env:get_node(pointed_thing.above)
|
|
|
|
if minetest.registered_nodes[n.name].buildable_to then
|
2012-10-15 16:38:08 +06:00
|
|
|
minetest.env:add_node(pointed_thing.above, {name=source})
|
2012-10-30 20:02:00 +06:00
|
|
|
else
|
2012-11-09 21:36:41 +06:00
|
|
|
return
|
2012-10-30 20:02:00 +06:00
|
|
|
end
|
2012-10-15 16:38:08 +06:00
|
|
|
end
|
2012-11-01 11:59:36 +06:00
|
|
|
return {name="instruments:bucket_empty_"..metals.list[i]}
|
2012-10-15 16:38:08 +06:00
|
|
|
end
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-10-30 13:59:41 +06:00
|
|
|
for i = 1,#metals.list do
|
2012-11-01 11:59:36 +06:00
|
|
|
minetest.register_craftitem("instruments:bucket_empty_"..metals.list[i], {
|
2012-11-02 23:10:51 +06:00
|
|
|
description = "Empty " .. metals.desc_list[i] .. " Bucket",
|
2012-11-01 11:59:36 +06:00
|
|
|
inventory_image = "instruments_bucket_"..metals.list[i]..".png",
|
2012-10-15 16:38:08 +06:00
|
|
|
stack_max = 1,
|
|
|
|
liquids_pointable = true,
|
|
|
|
on_use = function(itemstack, user, pointed_thing)
|
|
|
|
-- Must be pointing to node
|
|
|
|
if pointed_thing.type ~= "node" then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
-- Check if pointing to a liquid source
|
|
|
|
n = minetest.env:get_node(pointed_thing.under)
|
2012-10-30 13:59:41 +06:00
|
|
|
liquiddef = buckets.liquids[n.name]
|
2012-10-15 16:38:08 +06:00
|
|
|
if liquiddef ~= nil and liquiddef.source == n.name and liquiddef.itemname ~= nil then
|
|
|
|
minetest.env:add_node(pointed_thing.under, {name="air"})
|
2012-10-30 13:59:41 +06:00
|
|
|
return {name=liquiddef.itemname.."_"..metals.list[i]}
|
2012-10-15 16:38:08 +06:00
|
|
|
end
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
2012-10-30 13:59:41 +06:00
|
|
|
buckets.register_liquid(
|
2012-10-30 20:02:00 +06:00
|
|
|
"Water",
|
2012-10-15 16:38:08 +06:00
|
|
|
"default:water_source",
|
|
|
|
"default:water_flowing",
|
2012-11-01 11:59:36 +06:00
|
|
|
"instruments:bucket_water",
|
|
|
|
"instruments_water.png"
|
2012-10-15 16:38:08 +06:00
|
|
|
)
|
|
|
|
|
2012-10-30 13:59:41 +06:00
|
|
|
buckets.register_liquid(
|
2012-10-30 20:02:00 +06:00
|
|
|
"Lava",
|
2012-10-15 16:38:08 +06:00
|
|
|
"default:lava_source",
|
|
|
|
"default:lava_flowing",
|
2012-11-01 11:59:36 +06:00
|
|
|
"instruments:bucket_lava",
|
|
|
|
"instruments_lava.png"
|
2012-10-15 16:38:08 +06:00
|
|
|
)
|