mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-19 01:21:05 +01:00
Refactor sponge code
This commit is contained in:
parent
7f5629fc2a
commit
6620ee91ae
1 changed files with 27 additions and 33 deletions
|
@ -31,32 +31,28 @@ minetest.register_node("mcl_sponges:sponge", {
|
|||
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.get_node(pointed_thing.above).name, "water_source")
|
||||
or string.find(minetest.get_node(pointed_thing.above).name, "water_flowing") then
|
||||
local nn = minetest.get_node(pointed_thing.above).name
|
||||
if minetest.get_item_group(nn, "water") ~= 0 then
|
||||
on_water = true
|
||||
end
|
||||
for i=-1,1 do
|
||||
local p = {x=pos.x+i, y=pos.y, z=pos.z}
|
||||
local n = minetest.get_node(p)
|
||||
-- On verifie si il y a de l'eau
|
||||
if (n.name=="mcl_core:water_flowing") or (n.name == "mcl_core:water_source") then
|
||||
if minetest.get_item_group(n.name, "water") ~= 0 then
|
||||
on_water = true
|
||||
end
|
||||
end
|
||||
for i=-1,1 do
|
||||
local p = {x=pos.x, y=pos.y+i, z=pos.z}
|
||||
local n = minetest.get_node(p)
|
||||
-- On verifie si il y a de l'eau
|
||||
if (n.name=="mcl_core:water_flowing") or (n.name == "mcl_core:water_source") then
|
||||
if minetest.get_item_group(n.name, "water") ~= 0 then
|
||||
on_water = true
|
||||
end
|
||||
end
|
||||
for i=-1,1 do
|
||||
local p = {x=pos.x, y=pos.y, z=pos.z+i}
|
||||
local n = minetest.get_node(p)
|
||||
-- On verifie si il y a de l'eau
|
||||
if (n.name=="mcl_core:water_flowing") or (n.name == "mcl_core:water_source") then
|
||||
if minetest.get_item_group(n.name, "water") ~= 0 then
|
||||
on_water = true
|
||||
end
|
||||
end
|
||||
|
@ -67,8 +63,7 @@ minetest.register_node("mcl_sponges:sponge", {
|
|||
for k=-3,3 do
|
||||
p = {x=pos.x+i, y=pos.y+j, z=pos.z+k}
|
||||
n = minetest.get_node(p)
|
||||
-- On Supprime l'eau
|
||||
if (n.name=="mcl_core:water_flowing") or (n.name == "mcl_core:water_source")then
|
||||
if minetest.get_item_group(n.name, "water") ~= 0 then
|
||||
minetest.add_node(p, {name="air"})
|
||||
change = true
|
||||
end
|
||||
|
@ -84,7 +79,6 @@ minetest.register_node("mcl_sponges:sponge", {
|
|||
minetest.add_node(pointed_thing.above, {name = "mcl_sponges:sponge"})
|
||||
end
|
||||
return itemstack
|
||||
|
||||
end,
|
||||
_mcl_blast_resistance = 3,
|
||||
_mcl_hardness = 0.6,
|
||||
|
|
Loading…
Reference in a new issue