From 1728194d066ae98a2ee1d2a8757e3571e2f49e73 Mon Sep 17 00:00:00 2001 From: LeMagnesium Date: Tue, 9 Jun 2015 21:23:22 +0200 Subject: [PATCH] Merged buckets --- minetestforfun_game/mods/bucket/init.lua | 52 +++++++++++------------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/minetestforfun_game/mods/bucket/init.lua b/minetestforfun_game/mods/bucket/init.lua index 948176f6..df8ea7ec 100755 --- a/minetestforfun_game/mods/bucket/init.lua +++ b/minetestforfun_game/mods/bucket/init.lua @@ -7,10 +7,10 @@ minetest.register_alias("bucket_acid", "bucket:bucket_acid") minetest.register_alias("bucket_lava", "bucket:bucket_lava") minetest.register_craft({ - output = "bucket:bucket_empty 1", + output = 'bucket:bucket_empty 1', recipe = { - {"group:ingot", "", "group:ingot"}, - {"", "group:ingot", ""}, + {'group:ingot', '', 'group:ingot'}, + {'', 'group:ingot', ''}, } }) @@ -23,7 +23,7 @@ local function check_protection(pos, name, text) .. " tried to " .. text .. " at protected position " .. minetest.pos_to_string(pos) - .. " with a bucket.") + .. " with a bucket") minetest.record_protection_violation(pos, name) return true end @@ -127,37 +127,37 @@ minetest.register_craftitem("bucket:bucket_empty", { and liquiddef.itemname ~= nil and node.name == liquiddef.source then if check_protection(pointed_thing.under, - user:get_player_name(), - "take ".. node.name) then + user:get_player_name(), + "take ".. node.name) then return end --- default set to return filled bucket + -- default set to return filled bucket local giving_back = liquiddef.itemname --- check if holding more than 1 empty bucket + -- check if holding more than 1 empty bucket if item_count > 1 then - -- if space in inventory add filled bucked, otherwise drop as item - local inv = user:get_inventory() - if inv:room_for_item("main", {name=liquiddef.itemname}) then - inv:add_item("main", liquiddef.itemname) - else - local pos = user:getpos() - pos.y = math.floor(pos.y + 0.5) - core.add_item(pos, liquiddef.itemname) + -- if space in inventory add filled bucked, otherwise drop as item + local inv = user:get_inventory() + if inv:room_for_item("main", {name=liquiddef.itemname}) then + inv:add_item("main", liquiddef.itemname) + else + local pos = user:getpos() + pos.y = math.floor(pos.y + 0.5) + core.add_item(pos, liquiddef.itemname) + end + + -- set to return empty buckets minus 1 + giving_back = "bucket:bucket_empty "..tostring(item_count-1) + end - -- set to return empty buckets minus 1 - giving_back = "bucket:bucket_empty "..tostring(item_count-1) + minetest.add_node(pointed_thing.under, {name="air"}) + return ItemStack(giving_back) end - - minetest.add_node(pointed_thing.under, {name="air"}) - - return ItemStack(giving_back) - end -end, + end, }) bucket.register_liquid( @@ -219,7 +219,3 @@ minetest.register_craft({ {"bucket:bucket_water"}, }, }) - -if minetest.setting_getbool("log_mods") then - minetest.log("action", "Carbone: [bucket] loaded.") -end