Squeeze sponges to produce temporary splashes of water.

Pummel a sponge and it will release water if there is space
nearby, though it will be reabsorbed by the sponge in a few
seconds.

This CAN be used to wet other sponges (i.e. to have a managed
supply of water if working far from oceans) but CANNOT be used
to create infinite springs.

If the original sponge is removed (and there is no other sponge
to absorb the water) then the water will be removed as well.
This commit is contained in:
Aaron Suen 2019-08-23 21:18:20 -04:00
parent 4d245b850b
commit 10db2d6dbf
4 changed files with 77 additions and 3 deletions

View File

@ -1,2 +1,3 @@
nc_api
nc_api_craft
nc_terrain

View File

@ -6,3 +6,4 @@ local include
include('node')
include('abm')
include('gen')
include('squeeze')

View File

@ -13,7 +13,8 @@ minetest.register_node(modname .. ":sponge", {
groups = {
crumbly = 2,
flammable = 3,
fire_fuel = 3
fire_fuel = 3,
sponge = 1
},
sounds = nodecore.sounds("nc_terrain_swishy")
})
@ -27,7 +28,8 @@ minetest.register_node(modname .. ":sponge_wet", {
crumbly = 2,
coolant = 1,
falling_node = 1,
moist = 1
moist = 1,
sponge = 1
},
sounds = nodecore.sounds("nc_terrain_swishy")
})
@ -41,7 +43,8 @@ minetest.register_node(modname .. ":sponge_living", {
crumbly = 2,
coolant = 1,
falling_node = 1,
moist = 1
moist = 1,
sponge = 1
},
drop = modname .. ":sponge_wet",
sounds = nodecore.sounds("nc_terrain_swishy")

View File

@ -0,0 +1,69 @@
-- LUALOCALS < ---------------------------------------------------------
local math, minetest, nodecore, pairs, vector
= math, minetest, nodecore, pairs, vector
local math_random
= math.random
-- LUALOCALS > ---------------------------------------------------------
local modname = minetest.get_current_modname()
minetest.register_entity(modname .. ":waterguard", {
initial_properties = {
physical = false,
collide_with_objects = false,
collisionbox = {0, 0, 0, 0, 0, 0},
textures = {""},
is_visible = false,
static_save = true
},
on_step = function(self, dtime)
local pos = self.object:get_pos()
local node = minetest.get_node(pos)
if node.name ~= "nc_terrain:water_source" then
return self.object:remove()
end
if not minetest.find_node_near(pos, 1, {modname .. ":sponge"}) then
return minetest.remove_node(pos)
end
end
})
local spongedirs = {
{x = 1, y = 0, z = 0},
{x = -1, y = 0, z = 0},
{x = 0, y = 0, z = 1},
{x = 0, y = 0, z = -1}
}
nodecore.register_craft({
label = "squeeze sponge",
action = "pummel",
toolgroups = {thumpy = 1},
nodes = {
{
match = modname .. ":sponge_wet",
replace = modname .. ":sponge"
},
{
x = 1,
match = "air"
}
},
after = function(pos)
local dirs = {}
for _, d in pairs(spongedirs) do
local p = vector.add(pos, d)
if minetest.get_node(p).name == "air" then
dirs[#dirs + 1] = p
end
end
local p = dirs[math_random(1, #dirs)]
if minetest.get_node(p).name ~= "air"
or minetest.find_node_near(p, 2, {"nc_terrain:water_source"})
then return end
minetest.set_node(p, {name = "nc_terrain:water_source"})
minetest.add_entity(p, modname .. ":waterguard")
end
})