2020-08-04 21:15:26 +02:00
|
|
|
local S = minetest.get_translator("homedecor_cobweb")
|
|
|
|
homedecor_cobweb = {}
|
2017-01-31 06:34:41 +01:00
|
|
|
|
2022-05-03 21:21:14 +02:00
|
|
|
homedecor.register("cobweb_corner", {
|
2017-01-31 06:34:41 +01:00
|
|
|
description = S("Cobweb"),
|
2014-09-04 22:27:05 +02:00
|
|
|
drawtype = "torchlike",
|
|
|
|
tiles = { "homedecor_cobweb_torchlike.png" },
|
2015-05-04 04:00:30 +02:00
|
|
|
inventory_image = "homedecor_cobweb.png",
|
|
|
|
wield_image = "homedecor_cobweb.png",
|
2014-09-04 22:27:05 +02:00
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "wallmounted",
|
|
|
|
sunlight_propagates = true,
|
2014-12-25 14:03:59 +01:00
|
|
|
liquid_viscosity = 8,
|
2015-01-23 22:14:00 +01:00
|
|
|
liquidtype = "source",
|
|
|
|
liquid_alternative_flowing = "homedecor:cobweb_corner",
|
|
|
|
liquid_alternative_source = "homedecor:cobweb_corner",
|
|
|
|
liquid_renewable = false,
|
|
|
|
liquid_range = 0,
|
2014-09-04 22:27:05 +02:00
|
|
|
walkable = false,
|
2015-01-23 17:40:57 +01:00
|
|
|
selection_box = { type = "regular" },
|
2014-09-04 22:27:05 +02:00
|
|
|
visual_scale = 1.4,
|
2022-05-03 21:21:14 +02:00
|
|
|
groups = { snappy = 3, liquid=3, dig_glass = 1 },
|
2015-01-23 22:14:00 +01:00
|
|
|
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
2020-08-04 21:15:26 +02:00
|
|
|
homedecor_cobweb.rotate(pos)
|
2022-05-03 21:21:14 +02:00
|
|
|
end,
|
|
|
|
crafts = {
|
|
|
|
{
|
|
|
|
output = "homedecor:cobweb_corner 5",
|
|
|
|
recipe = {
|
|
|
|
{"string", "", "string"},
|
|
|
|
{"", "string", ""},
|
|
|
|
{"string", "", "string"}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
2014-09-04 22:27:05 +02:00
|
|
|
})
|
|
|
|
|
2022-05-03 21:21:14 +02:00
|
|
|
homedecor.register("cobweb_centered", {
|
2017-01-31 06:34:41 +01:00
|
|
|
description = S("Cobweb"),
|
2014-09-04 22:27:05 +02:00
|
|
|
drawtype = "nodebox",
|
|
|
|
tiles = { "homedecor_cobweb.png" },
|
2015-05-04 04:00:30 +02:00
|
|
|
inventory_image = "homedecor_cobweb.png",
|
2022-02-07 14:18:17 +01:00
|
|
|
use_texture_alpha = "clip",
|
2014-09-04 22:27:05 +02:00
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "facedir",
|
|
|
|
sunlight_propagates = true,
|
2014-12-25 14:03:59 +01:00
|
|
|
liquid_viscosity = 8,
|
2015-01-23 22:14:00 +01:00
|
|
|
liquidtype = "source",
|
|
|
|
liquid_alternative_flowing = "homedecor:cobweb_centered",
|
|
|
|
liquid_alternative_source = "homedecor:cobweb_centered",
|
|
|
|
liquid_renewable = false,
|
|
|
|
liquid_range = 0,
|
2014-09-04 22:27:05 +02:00
|
|
|
walkable = false,
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
2014-09-04 22:50:39 +02:00
|
|
|
fixed = { -0.5, -0.5, -0.1, 0.5, 0.5, 0.1 }
|
2014-09-04 22:27:05 +02:00
|
|
|
},
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = { -0.5, -0.5, 0, 0.5, 0.5, 0 }
|
|
|
|
},
|
2022-05-03 21:21:14 +02:00
|
|
|
groups = { snappy = 3, liquid=3, dig_glass = 1, not_in_creative_inventory = 1 },
|
2014-09-04 22:27:05 +02:00
|
|
|
drop = "homedecor:cobweb_corner"
|
|
|
|
})
|
|
|
|
|
2022-05-03 21:21:14 +02:00
|
|
|
homedecor.register("cobweb_flat", {
|
2017-01-31 06:34:41 +01:00
|
|
|
description = S("Cobweb"),
|
2014-09-04 23:13:58 +02:00
|
|
|
drawtype = "nodebox",
|
|
|
|
tiles = { "homedecor_cobweb.png" },
|
2015-05-04 04:00:30 +02:00
|
|
|
inventory_image = "homedecor_cobweb.png",
|
2014-09-04 23:13:58 +02:00
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "facedir",
|
2022-02-07 14:18:17 +01:00
|
|
|
use_texture_alpha = "clip",
|
2014-09-04 23:13:58 +02:00
|
|
|
sunlight_propagates = true,
|
2014-12-25 14:03:59 +01:00
|
|
|
liquid_viscosity = 8,
|
2015-01-23 22:14:00 +01:00
|
|
|
liquidtype = "source",
|
|
|
|
liquid_alternative_flowing = "homedecor:cobweb_flat",
|
|
|
|
liquid_alternative_source = "homedecor:cobweb_flat",
|
|
|
|
liquid_renewable = false,
|
|
|
|
liquid_range = 0,
|
2014-09-04 23:13:58 +02:00
|
|
|
walkable = false,
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = { -0.5, -0.5, 0.4, 0.5, 0.5, 0.5 }
|
|
|
|
},
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = { -0.5, -0.5, 0.495, 0.5, 0.5, 0.495 }
|
|
|
|
},
|
2022-05-03 21:21:14 +02:00
|
|
|
groups = { snappy = 3, liquid=3, dig_glass = 1, not_in_creative_inventory = 1 },
|
2014-09-04 23:13:58 +02:00
|
|
|
drop = "homedecor:cobweb_corner"
|
|
|
|
})
|
|
|
|
|
2022-05-03 21:21:14 +02:00
|
|
|
homedecor.register("cobweb_plantlike", {
|
2017-01-31 06:34:41 +01:00
|
|
|
description = S("Cobweb"),
|
2014-09-04 22:27:05 +02:00
|
|
|
drawtype = "plantlike",
|
|
|
|
tiles = { "homedecor_cobweb_plantlike.png" },
|
2015-05-04 04:00:30 +02:00
|
|
|
inventory_image = "homedecor_cobweb.png",
|
2014-09-04 22:27:05 +02:00
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "facedir",
|
|
|
|
sunlight_propagates = true,
|
2014-12-25 14:03:59 +01:00
|
|
|
liquid_viscosity = 8,
|
2015-01-23 22:14:00 +01:00
|
|
|
liquidtype = "source",
|
|
|
|
liquid_alternative_flowing = "homedecor:cobweb_plantlike",
|
|
|
|
liquid_alternative_source = "homedecor:cobweb_plantlike",
|
|
|
|
liquid_renewable = false,
|
|
|
|
liquid_range = 0,
|
2014-09-04 22:27:05 +02:00
|
|
|
walkable = false,
|
2015-01-23 17:40:57 +01:00
|
|
|
selection_box = { type = "regular" },
|
2014-09-04 22:27:05 +02:00
|
|
|
visual_scale = 1.189,
|
2022-05-03 21:21:14 +02:00
|
|
|
groups = { snappy = 3, liquid=3, dig_glass = 1, not_in_creative_inventory = 1 },
|
2014-09-04 22:27:05 +02:00
|
|
|
drop = "homedecor:cobweb_corner"
|
|
|
|
})
|
|
|
|
|
|
|
|
-- helper function to rotate the cobweb after it's placed
|
|
|
|
|
2020-08-04 21:15:26 +02:00
|
|
|
function homedecor_cobweb.rotate(pos)
|
2014-09-04 22:27:05 +02:00
|
|
|
local wall_xm = minetest.get_node({ x=pos.x-1, y=pos.y, z=pos.z }).name
|
|
|
|
local wall_xp = minetest.get_node({ x=pos.x+1, y=pos.y, z=pos.z }).name
|
|
|
|
local wall_zm = minetest.get_node({ x=pos.x, y=pos.y, z=pos.z-1}).name
|
|
|
|
local wall_zp = minetest.get_node({ x=pos.x, y=pos.y, z=pos.z+1}).name
|
|
|
|
|
2014-10-03 05:17:30 +02:00
|
|
|
local iswall_xm = (wall_xm ~= "air" and not string.find(wall_xm, "homedecor:cobweb"))
|
|
|
|
local iswall_xp = (wall_xp ~= "air" and not string.find(wall_xp, "homedecor:cobweb"))
|
|
|
|
local iswall_zm = (wall_zm ~= "air" and not string.find(wall_zm, "homedecor:cobweb"))
|
|
|
|
local iswall_zp = (wall_zp ~= "air" and not string.find(wall_zp, "homedecor:cobweb"))
|
2014-09-04 22:27:05 +02:00
|
|
|
|
|
|
|
-- only xm+zp, or only xp+zm means on-floor torchlike
|
|
|
|
|
|
|
|
if (iswall_xm and iswall_zp and not iswall_xp and not iswall_zm)
|
2015-01-20 23:59:50 +01:00
|
|
|
or (iswall_xp and iswall_zm and not iswall_xm and not iswall_zp) then
|
2014-09-04 22:27:05 +02:00
|
|
|
minetest.set_node(pos, {name = "homedecor:cobweb_corner", param2 = 1})
|
2015-01-20 23:59:50 +01:00
|
|
|
|
2014-09-04 22:27:05 +02:00
|
|
|
-- only xm+zm, or only xp+zp means on-ceiling torchlike
|
|
|
|
|
2015-01-20 23:59:50 +01:00
|
|
|
elseif (iswall_xm and iswall_zm and not iswall_xp and not iswall_zp)
|
|
|
|
or (iswall_xp and iswall_zp and not iswall_xm and not iswall_zm) then
|
2014-09-04 22:27:05 +02:00
|
|
|
minetest.set_node(pos, {name = "homedecor:cobweb_corner", param2 = 0})
|
2015-01-20 23:59:50 +01:00
|
|
|
|
2014-09-04 22:27:05 +02:00
|
|
|
-- only xm+xp means nodebox (not rotated, 0 degrees)
|
|
|
|
|
2015-01-20 23:59:50 +01:00
|
|
|
elseif iswall_xm and iswall_xp and not iswall_zm and not iswall_zp then
|
2014-09-04 22:27:05 +02:00
|
|
|
minetest.set_node(pos, {name = "homedecor:cobweb_centered", param2 = 0})
|
2015-01-20 23:59:50 +01:00
|
|
|
|
2014-09-04 22:27:05 +02:00
|
|
|
-- only zm+zp means nodebox rotated to 90 degrees
|
|
|
|
|
2015-01-20 23:59:50 +01:00
|
|
|
elseif iswall_zm and iswall_zp and not iswall_xm and not iswall_xp then
|
2014-09-04 22:27:05 +02:00
|
|
|
minetest.set_node(pos, {name = "homedecor:cobweb_centered", param2 = 1})
|
2014-09-04 23:13:58 +02:00
|
|
|
|
|
|
|
-- ok, there aren't any simple two-wall corners or opposing walls.
|
|
|
|
-- Are there any standalone walls?
|
|
|
|
|
|
|
|
elseif iswall_xm and not iswall_xp and not iswall_zm and not iswall_zp then
|
|
|
|
minetest.set_node(pos, {name = "homedecor:cobweb_flat", param2 = 3})
|
|
|
|
|
|
|
|
elseif iswall_xp and not iswall_xm and not iswall_zm and not iswall_zp then
|
|
|
|
minetest.set_node(pos, {name = "homedecor:cobweb_flat", param2 = 1})
|
|
|
|
|
|
|
|
elseif iswall_zm and not iswall_xm and not iswall_xp and not iswall_zp then
|
|
|
|
minetest.set_node(pos, {name = "homedecor:cobweb_flat", param2 = 2})
|
|
|
|
|
|
|
|
elseif iswall_zp and not iswall_xm and not iswall_xp and not iswall_zm then
|
|
|
|
minetest.set_node(pos, {name = "homedecor:cobweb_flat", param2 = 0})
|
2015-01-20 23:59:50 +01:00
|
|
|
|
2014-09-04 22:27:05 +02:00
|
|
|
-- if all else fails, place the plantlike version as a fallback.
|
|
|
|
|
|
|
|
else
|
|
|
|
minetest.set_node(pos, {name = "homedecor:cobweb_plantlike", param2 = 0})
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|