Advertisement
Guest User

Untitled

a guest
Oct 16th, 2012
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.16 KB | None | 0 0
  1. --[[
  2. Alternative by NakedFury
  3. With help from: thexyz
  4. Wood Buckets
  5. Version 1.0
  6. License: GNU GPLv3
  7. Date: 10/12/2012
  8. --]]
  9. altwood = {}
  10. altw.liquids = {}
  11.  
  12. minetest.register_craft({
  13.     output = 'alternative:wood_bucket 1',
  14.     recipe = {
  15.         {'default:wood', '', 'default:wood'},
  16.         {'', 'default:wood', ''},
  17.     }
  18. })
  19.  
  20. function altwood.register_liquid(source, flowing, itemname, inventory_image)
  21.     altw.liquids[source] = {
  22.         source = source,
  23.         flowing = flowing,
  24.         itemname = itemname,
  25.     }
  26.     altw.liquids[flowing] = altw.liquids[source]
  27.  
  28.     if itemname ~= nil then
  29.         minetest.register_craftitem(itemname, {
  30.             inventory_image = inventory_image,
  31.             stack_max = 1,
  32.             liquids_pointable = true,
  33.             on_use = function(itemstack, user, pointed_thing)
  34.                 -- Must be pointing to node
  35.                 if pointed_thing.type ~= "node" then
  36.                     return
  37.                 end
  38.                 -- Check if pointing to a liquid
  39.                 n = minetest.env:get_node(pointed_thing.under)
  40.                 if altw.liquids[n.name] == nil then
  41.                     -- Not a liquid
  42.                     minetest.env:add_node(pointed_thing.above, {name=water_source})
  43.                 elseif n.name ~= source then
  44.                     -- It's a liquid
  45.                     minetest.env:add_node(pointed_thing.under, {name=water_ source})
  46.                 end
  47.                 return {name="alternative:wood_bucket"}
  48.             end
  49.         })
  50.     end
  51. end
  52.  
  53. minetest.register_craftitem("alternative:wood_bucket", {
  54.     description = "Wood bucket",
  55.     inventory_image = "alternative_wood_bucket.png",
  56.     stack_max = 1,
  57.     liquids_pointable = true,
  58.     on_use = function(itemstack, user, pointed_thing)
  59.         -- Must be pointing to node
  60.         if pointed_thing.type ~= "node" then
  61.             return
  62.         end
  63.         -- Check if pointing to a liquid source
  64.         n = minetest.env:get_node(pointed_thing.under)
  65.         liquiddef = altw.liquids[n.name]
  66.         if liquiddef ~= nil and liquiddef.source == n.name and liquiddef.itemname ~= nil then
  67.             minetest.env:add_node(pointed_thing.under, {name="air"})
  68.             return {name=liquiddef.itemname}
  69.         end
  70.     end,
  71. })
  72.  
  73. altwood.register_liquid(
  74.     "default:water_source",
  75.     "default:water_flowing",
  76.     "alternative:wood_bucket_water",
  77.     "alternative_wood_bucket_water.png"
  78. )
  79.  
  80. minetest.register_craft({
  81.     type = "fuel",
  82.     recipe = "alternative:wood_bucket",
  83.     burntime = 4,
  84. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement