From 9950c4c2f21e4690541ef5ea73444a4324e72b0b Mon Sep 17 00:00:00 2001 From: James Stevenson Date: Fri, 22 Jan 2016 01:02:11 -0500 Subject: [PATCH] Infinite water --- mods/bucket/init.lua | 13 +++++++++++-- mods/default/functions.lua | 37 +++++++++++++++++++++++++++++-------- mods/default/nodes.lua | 13 +++++++++++-- mods/stairs/init.lua | 2 +- 4 files changed, 52 insertions(+), 13 deletions(-) diff --git a/mods/bucket/init.lua b/mods/bucket/init.lua index 1430ce1..c0550ad 100644 --- a/mods/bucket/init.lua +++ b/mods/bucket/init.lua @@ -153,6 +153,14 @@ minetest.register_craftitem("bucket:bucket_empty", { minetest.add_node(pointed_thing.under, {name="air"}) return ItemStack(giving_back) + elseif node.name == "default:water_source_infinite" then + if check_protection(pointed_thing.under, + user:get_player_name(), + "take ".. node.name) then + return + end + minetest.add_node(pointed_thing.under, {name = "air"}) + return ItemStack("bucket:bucket_water") end end, }) @@ -178,8 +186,9 @@ minetest.register_craft({ type = "fuel", recipe = "bucket:bucket_lava", burntime = 60, - replacements = {{"bucket:bucket_lava", "bucket:bucket_empty"}}, + replacements = { + {"bucket:bucket_lava", "bucket:bucket_empty"} + } }) dofile(minetest.get_modpath("bucket") .. "/snowbucket.lua") - diff --git a/mods/default/functions.lua b/mods/default/functions.lua index 691d1db..4fb6476 100644 --- a/mods/default/functions.lua +++ b/mods/default/functions.lua @@ -176,7 +176,7 @@ minetest.register_abm({ chance = 1, action = function(pos, node, active_object_count, active_object_count_wider) default.cool_lava_flowing(pos, node, active_object_count, active_object_count_wider) - end, + end }) minetest.register_abm({ @@ -186,7 +186,28 @@ minetest.register_abm({ chance = 1, action = function(pos, node, active_object_count, active_object_count_wider) default.cool_lava_source(pos, node, active_object_count, active_object_count_wider) - end, + end +}) + +-- Infinite water +local function get_water(pos) + local pos1 = {x = pos.x - 1, y = pos.y, z = pos.z - 1} + local pos2 = {x = pos.x + 1, y = pos.y, z = pos.z + 1} + local water = minetest.find_nodes_in_area(pos1, pos2, "default:water_source") + if #water > 8 then + minetest.set_node(pos, {name = "default:water_source_infinite"}) + end +end + +minetest.register_abm({ + nodenames = {"default:water_source"}, + neighbors = {"default:water_source"}, + interval = 10, + chance = 1, + catch_up = false, + action = function(pos, node, active_object_count, active_object_count_wider) + get_water(pos) + end }) -- Papyrus and cactus growing @@ -198,22 +219,22 @@ minetest.register_abm({ interval = 50, chance = 20, action = function(pos, node) - pos.y = pos.y-1 + pos.y = pos.y - 1 local name = minetest.get_node(pos).name if minetest.get_item_group(name, "sand") ~= 0 then - pos.y = pos.y+1 + pos.y = pos.y + 1 local height = 0 while minetest.get_node(pos).name == "default:cactus" and height < 4 do - height = height+1 - pos.y = pos.y+1 + height = height + 1 + pos.y = pos.y + 1 end if height < 4 then if minetest.get_node(pos).name == "air" then - minetest.set_node(pos, {name="default:cactus"}) + minetest.set_node(pos, {name = "default:cactus"}) end end end - end, + end }) minetest.register_abm({ diff --git a/mods/default/nodes.lua b/mods/default/nodes.lua index b0aa7c9..5693617 100644 --- a/mods/default/nodes.lua +++ b/mods/default/nodes.lua @@ -334,7 +334,12 @@ minetest.register_node("default:junglegrass", { walkable = false, buildable_to = true, is_ground_content = true, - groups = {dig=default.dig.instant, flammable=2, flora=1, attached_node=1}, + groups = { + dig = default.dig.instant, + flammable = 2, + flora = 1, + attached_node = 1 + }, sounds = default.node_sound_leaves_defaults(), selection_box = { type = "fixed", @@ -350,7 +355,11 @@ minetest.register_node("default:leaves", { tiles = {"default_leaves.png"}, is_ground_content = false, paramtype = "light", - groups = {snappy=default.dig.leaves, leafdecay=3, flammable=2, leaves=1}, + groups = { + snappy = default.dig.leaves, + leafdecay = 3, + flammable = 2, + leaves = 1}, drop = { max_items=1, items = { diff --git a/mods/stairs/init.lua b/mods/stairs/init.lua index 5c21c5b..def4ba6 100644 --- a/mods/stairs/init.lua +++ b/mods/stairs/init.lua @@ -500,7 +500,7 @@ stairs.register_shape("wood", "default:wood", default.node_sound_wood_defaults()) stairs.register_shape("junglewood", "default:junglewood", - {choppy = default.dig.wood, flammable = 3, fuel =1}, + {choppy = default.dig.wood, flammable = 3, fuel = 1}, {"default_junglewood.png"}, "Junglewood Stair", "Junglewood Slab",