diff --git a/mods/sponge/init.lua b/mods/sponge/init.lua index 2dfc5e47..c9c9090e 100644 --- a/mods/sponge/init.lua +++ b/mods/sponge/init.lua @@ -1,7 +1,7 @@ -minetest.register_node("default:sponge", { +minetest.register_node("sponge:sponge", { description = "Sponge", drawtype = "normal", - tiles = {"default_sponge.png"}, + tiles = {"sponge_sponge.png"}, paramtype = 'light', walkable = true, pointable = true, @@ -68,19 +68,19 @@ minetest.register_node("default:sponge", { p = {x=pos.x, y=pos.y, z=pos.z} n = minetest.env:get_node(p) if change == true then - minetest.env:add_node(pointed_thing.above, {name = "default:sponge_wet"}) + minetest.env:add_node(pointed_thing.above, {name = "sponge:sponge_wet"}) else - minetest.env:add_node(pointed_thing.above, {name = "default:sponge"}) + minetest.env:add_node(pointed_thing.above, {name = "sponge:sponge"}) end return itemstack end }) -minetest.register_node("default:sponge_wet", { +minetest.register_node("sponge:sponge_wet", { description = "Wet Sponge", drawtype = "normal", - tiles = {"default_sponge_wet.png"}, + tiles = {"sponge_sponge_wet.png"}, paramtype = 'light', walkable = true, pointable = true, @@ -88,4 +88,4 @@ minetest.register_node("default:sponge_wet", { buildable_to = false, stack_max = 64, groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3}, -}) \ No newline at end of file +}) diff --git a/mods/sponge/init.lua~ b/mods/sponge/init.lua~ new file mode 100644 index 00000000..c9c9090e --- /dev/null +++ b/mods/sponge/init.lua~ @@ -0,0 +1,91 @@ +minetest.register_node("sponge:sponge", { + description = "Sponge", + drawtype = "normal", + tiles = {"sponge_sponge.png"}, + paramtype = 'light', + walkable = true, + pointable = true, + diggable = true, + buildable_to = false, + stack_max = 64, + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3,flammable=3}, + on_place = function(itemstack, placer, pointed_thing) + local pn = placer:get_player_name() + if pointed_thing.type ~= "node" then + return itemstack + end + if minetest.is_protected(pointed_thing.above, pn) then + return itemstack + end + local change = false + local on_water = false + local pos = pointed_thing.above + -- verifier si il est dans l'eau ou a cotée + if string.find(minetest.env:get_node(pointed_thing.above).name, "water_source") + or string.find(minetest.env:get_node(pointed_thing.above).name, "water_flowing") then + on_water = true + end + for i=-1,1 do + p = {x=pos.x+i, y=pos.y, z=pos.z} + n = minetest.env:get_node(p) + -- On verifie si il y a de l'eau + if (n.name=="default:water_flowing") or (n.name == "default:water_source") then + on_water = true + end + end + for i=-1,1 do + p = {x=pos.x, y=pos.y+i, z=pos.z} + n = minetest.env:get_node(p) + -- On verifie si il y a de l'eau + if (n.name=="default:water_flowing") or (n.name == "default:water_source") then + on_water = true + end + end + for i=-1,1 do + p = {x=pos.x, y=pos.y, z=pos.z+i} + n = minetest.env:get_node(p) + -- On verifie si il y a de l'eau + if (n.name=="default:water_flowing") or (n.name == "default:water_source") then + on_water = true + end + end + + if on_water == true then + for i=-3,3 do + for j=-3,3 do + for k=-3,3 do + p = {x=pos.x+i, y=pos.y+j, z=pos.z+k} + n = minetest.env:get_node(p) + -- On Supprime l'eau + if (n.name=="default:water_flowing") or (n.name == "default:water_source")then + minetest.env:add_node(p, {name="air"}) + change = true + end + end + end + end + end + p = {x=pos.x, y=pos.y, z=pos.z} + n = minetest.env:get_node(p) + if change == true then + minetest.env:add_node(pointed_thing.above, {name = "sponge:sponge_wet"}) + else + minetest.env:add_node(pointed_thing.above, {name = "sponge:sponge"}) + end + return itemstack + + end +}) + +minetest.register_node("sponge:sponge_wet", { + description = "Wet Sponge", + drawtype = "normal", + tiles = {"sponge_sponge_wet.png"}, + paramtype = 'light', + walkable = true, + pointable = true, + diggable = true, + buildable_to = false, + stack_max = 64, + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3}, +}) diff --git a/mods/sponge/sponge_sponge.png b/mods/sponge/sponge_sponge.png new file mode 100644 index 00000000..b91b097b Binary files /dev/null and b/mods/sponge/sponge_sponge.png differ diff --git a/mods/sponge/sponge_sponge_wet.png b/mods/sponge/sponge_sponge_wet.png new file mode 100644 index 00000000..98b3d6c1 Binary files /dev/null and b/mods/sponge/sponge_sponge_wet.png differ