1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-11-17 15:58:26 +01:00

Clean and improve sponge

- Solves #268
This commit is contained in:
LeMagnesium 2015-09-05 21:58:43 +02:00
parent 5856d4d6f3
commit bd72179e0e

View File

@ -9,17 +9,17 @@ minetest.register_node("sponge:sponge", {
buildable_to = false, buildable_to = false,
stack_max = 99, stack_max = 99,
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3,flammable=3}, groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3,flammable=3},
on_place = function(itemstack, placer, pointed_thing) after_place_node = function(pos, placer, itemstack, pointed_thing)
local pn = placer:get_player_name() local pn = placer:get_player_name()
if pointed_thing.type ~= "node" then if pointed_thing.type ~= "node" then
return itemstack return
end end
if minetest.is_protected(pointed_thing.above, pn) then if minetest.is_protected(pointed_thing.above, pn) then
return itemstack return
end end
local change = false local change = false
local on_water = false local on_water = false
local pos = pointed_thing.above local pos = pointed_thing.above
-- verifier si il est dans l'eau ou a cotée -- verifier si il est dans l'eau ou a cotée
if string.find(minetest.get_node(pointed_thing.above).name, "water_source") if string.find(minetest.get_node(pointed_thing.above).name, "water_source")
or string.find(minetest.get_node(pointed_thing.above).name, "water_flowing") then or string.find(minetest.get_node(pointed_thing.above).name, "water_flowing") then
@ -50,31 +50,26 @@ minetest.register_node("sponge:sponge", {
end end
end end
if on_water == true then if on_water == true then
for i=-3,3 do for i=-3,3 do
for j=-3,3 do for j=-3,3 do
for k=-3,3 do for k=-3,3 do
p = {x=pos.x+i, y=pos.y+j, z=pos.z+k} p = {x=pos.x+i, y=pos.y+j, z=pos.z+k}
n = minetest.get_node(p) n = minetest.get_node(p)
-- On Supprime l'eau -- On Supprime l'eau
if (n.name=="default:water_flowing") or (n.name == "default:water_source")then if (n.name=="default:water_flowing") or (n.name == "default:water_source")then
minetest.add_node(p, {name="air"}) minetest.add_node(p, {name="air"})
change = true change = true
end
end end
end end
end end
end end
p = {x=pos.x, y=pos.y, z=pos.z} end
n = minetest.get_node(p) if change then
if change == true then minetest.add_node(pointed_thing.above, {name = "sponge:sponge_wet"})
minetest.add_node(pointed_thing.above, {name = "sponge:sponge_wet"}) end
else p = {x=pos.x, y=pos.y, z=pos.z}
minetest.add_node(pointed_thing.above, {name = "sponge:sponge"}) n = minetest.get_node(p)
end
itemstack:take_item()
return itemstack
end end
}) })
@ -97,10 +92,10 @@ minetest.register_craft({
}) })
minetest.register_craft({ minetest.register_craft({
output = "sponge:sponge", output = "sponge:sponge",
recipe = { recipe = {
{"", "dye:black", ""}, {"", "dye:black", ""},
{"dye:yellow", "wool:white", "dye:yellow"}, {"dye:yellow", "wool:white", "dye:yellow"},
{"", "farming:wheat", ""}, {"", "farming:wheat", ""},
}, },
}) })