diff options
author | Wuzzy <wuzzy2@mail.ru> | 2020-05-24 15:46:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-24 14:46:26 +0100 |
commit | 6456aba73f0ef3f2fa7fd2b2a69cfdf8624afe23 (patch) | |
tree | f2bada583c6f4d3032f28b2627bf052174f0a847 /games/minimal/mods/bucket | |
parent | a9b74f4c3966ad38c2f9a97364d3fdda0e514c93 (diff) | |
download | minetest-6456aba73f0ef3f2fa7fd2b2a69cfdf8624afe23.tar.gz minetest-6456aba73f0ef3f2fa7fd2b2a69cfdf8624afe23.tar.bz2 minetest-6456aba73f0ef3f2fa7fd2b2a69cfdf8624afe23.zip |
Replacement for Minimal Development Test (PR) (#9450)
Diffstat (limited to 'games/minimal/mods/bucket')
-rw-r--r-- | games/minimal/mods/bucket/init.lua | 93 | ||||
-rw-r--r-- | games/minimal/mods/bucket/mod.conf | 3 | ||||
-rw-r--r-- | games/minimal/mods/bucket/textures/bucket.png | bin | 182 -> 163 bytes | |||
-rw-r--r-- | games/minimal/mods/bucket/textures/bucket_lava.png | bin | 183 -> 168 bytes | |||
-rw-r--r-- | games/minimal/mods/bucket/textures/bucket_water.png | bin | 180 -> 168 bytes |
5 files changed, 13 insertions, 83 deletions
diff --git a/games/minimal/mods/bucket/init.lua b/games/minimal/mods/bucket/init.lua index dcd59ed38..3189d4aa6 100644 --- a/games/minimal/mods/bucket/init.lua +++ b/games/minimal/mods/bucket/init.lua @@ -1,95 +1,26 @@ --- bucket (Minetest 0.4 mod) --- A bucket, which can pick up water and lava +-- Bucket: Punch liquid source or flowing liquid to collect it -minetest.register_alias("bucket", "bucket:bucket_empty") -minetest.register_alias("bucket_water", "bucket:bucket_water") -minetest.register_alias("bucket_lava", "bucket:bucket_lava") - -minetest.register_craft({ - output = 'bucket:bucket_empty 1', - recipe = { - {'default:steel_ingot', '', 'default:steel_ingot'}, - {'', 'default:steel_ingot', ''}, - } -}) - -bucket = {} -bucket.liquids = {} - --- Register a new liquid --- source = name of the source node --- flowing = name of the flowing node --- itemname = name of the new bucket item (or nil if liquid is not takeable) --- inventory_image = texture of the new bucket item (ignored if itemname == nil) --- This function can be called from any mod (that depends on bucket). -function bucket.register_liquid(source, flowing, itemname, inventory_image) - bucket.liquids[source] = { - source = source, - flowing = flowing, - itemname = itemname, - } - bucket.liquids[flowing] = bucket.liquids[source] - - if itemname ~= nil then - minetest.register_craftitem(itemname, { - inventory_image = inventory_image, - 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 - n = minetest.get_node(pointed_thing.under) - if bucket.liquids[n.name] == nil then - -- Not a liquid - minetest.add_node(pointed_thing.above, {name=source}) - elseif n.name ~= source then - -- It's a liquid - minetest.add_node(pointed_thing.under, {name=source}) - end - return {name="bucket:bucket_empty"} - end - }) - end -end - -minetest.register_craftitem("bucket:bucket_empty", { +minetest.register_tool("bucket:bucket", { + description = "Bucket", inventory_image = "bucket.png", stack_max = 1, liquids_pointable = true, + groups = { disable_repair = 1 }, 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.get_node(pointed_thing.under) - liquiddef = bucket.liquids[n.name] - if liquiddef ~= nil and liquiddef.source == n.name and liquiddef.itemname ~= nil then + -- Check if pointing to a liquid + local n = minetest.get_node(pointed_thing.under) + local def = minetest.registered_nodes[n.name] + if def ~= nil and (def.liquidtype == "source" or def.liquidtype == "flowing") then minetest.add_node(pointed_thing.under, {name="air"}) - return {name=liquiddef.itemname} + local inv = user:get_inventory() + if inv then + inv:add_item("main", ItemStack(n.name)) + end end end, }) -bucket.register_liquid( - "default:water_source", - "default:water_flowing", - "bucket:bucket_water", - "bucket_water.png" -) - -bucket.register_liquid( - "default:lava_source", - "default:lava_flowing", - "bucket:bucket_lava", - "bucket_lava.png" -) - -minetest.register_craft({ - type = "fuel", - recipe = "bucket:bucket_lava", - burntime = 60, -}) diff --git a/games/minimal/mods/bucket/mod.conf b/games/minimal/mods/bucket/mod.conf index 2a6086775..d14deb4ea 100644 --- a/games/minimal/mods/bucket/mod.conf +++ b/games/minimal/mods/bucket/mod.conf @@ -1,3 +1,2 @@ name = bucket -description = Minimal bucket to place and pick up liquids -depends = default +description = Minimal bucket to pick up liquids diff --git a/games/minimal/mods/bucket/textures/bucket.png b/games/minimal/mods/bucket/textures/bucket.png Binary files differindex b775a9fd3..677952875 100644 --- a/games/minimal/mods/bucket/textures/bucket.png +++ b/games/minimal/mods/bucket/textures/bucket.png diff --git a/games/minimal/mods/bucket/textures/bucket_lava.png b/games/minimal/mods/bucket/textures/bucket_lava.png Binary files differindex 889ed61d4..dfcae65fb 100644 --- a/games/minimal/mods/bucket/textures/bucket_lava.png +++ b/games/minimal/mods/bucket/textures/bucket_lava.png diff --git a/games/minimal/mods/bucket/textures/bucket_water.png b/games/minimal/mods/bucket/textures/bucket_water.png Binary files differindex a3c9d72f7..e164b0a50 100644 --- a/games/minimal/mods/bucket/textures/bucket_water.png +++ b/games/minimal/mods/bucket/textures/bucket_water.png |