Convert glowlights/glowcubes to 6d facedir

This commit is contained in:
Vanessa Ezekowitz 2013-04-24 12:30:21 -04:00
parent 57ef8401fe
commit 4a1ded8528

View File

@ -10,9 +10,101 @@ else
S = function ( s ) return s end S = function ( s ) return s end
end end
local dirs1 = { 20, 23, 22, 21 }
local dirs2 = { 9, 18, 7, 12 }
function homedecor_rotate_and_place(itemstack, placer, pointed_thing)
local node = minetest.env:get_node(pointed_thing.under)
if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].on_rightclick then
local above = pointed_thing.above
local under = pointed_thing.under
local pitch = placer:get_look_pitch()
local node = minetest.env:get_node(above)
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
local wield_name = itemstack:get_name()
if node.name ~= "air" then return end
local iswall = (above.x ~= under.x) or (above.z ~= under.z)
local isceiling = (above.x == under.x) and (above.z == under.z) and (pitch > 0)
if iswall then
minetest.env:add_node(above, {name = wield_name, param2 = dirs2[fdir+1] }) -- place wall variant
elseif isceiling then
minetest.env:add_node(above, {name = wield_name, param2 = 20 }) -- place upside down variant
else
minetest.env:add_node(above, {name = wield_name, param2 = 0 }) -- place right side up
end
if not homedecor_expect_infinite_stacks then
itemstack:take_item()
return itemstack
end
else
minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer)
end
end
local colors = {"yellow","white"}
for i in ipairs(colors) do
local color = colors[i]
minetest.register_abm({
nodenames = { "homedecor:glowlight_thin_"..color },
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
minetest.env:add_node(pos, {name = "homedecor:glowlight_quarter_"..color, param2 = 20})
end,
})
minetest.register_abm({
nodenames = { "homedecor:glowlight_thick_"..color },
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
minetest.env:add_node(pos, {name = "homedecor:glowlight_half_"..color, param2 = 20})
end,
})
minetest.register_abm({
nodenames = { "homedecor:glowlight_thin_"..color.."_wall" },
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local fdir = node.param2 or 0
nfdir = dirs2[fdir+1]
minetest.env:add_node(pos, {name = "homedecor:glowlight_quarter_"..color, param2 = nfdir})
end,
})
minetest.register_abm({
nodenames = { "homedecor:glowlight_thick_"..color.."_wall" },
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local fdir = node.param2 or 0
nfdir = dirs2[fdir+1]
minetest.env:add_node(pos, {name = "homedecor:glowlight_half_"..color, param2 = nfdir})
end,
})
minetest.register_abm({
nodenames = { "homedecor:glowlight_small_cube_"..color.."_ceiling" },
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
minetest.env:add_node(pos, {name = "homedecor:glowlight_small_cube_"..color, param2 = 20})
end,
})
end
-- Yellow -- Yellow
minetest.register_node('homedecor:glowlight_thick_yellow', { minetest.register_node('homedecor:glowlight_half_yellow', {
description = S("Yellow Glowlight (thick)"), description = S("Yellow Glowlight (thick)"),
drawtype = "nodebox", drawtype = "nodebox",
tiles = { tiles = {
@ -25,104 +117,27 @@ minetest.register_node('homedecor:glowlight_thick_yellow', {
}, },
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = { -0.5, 0, -0.5, 0.5, 0.5, 0.5 } fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
}, },
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = { -0.5, 0, -0.5, 0.5, 0.5, 0.5 } fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
}, },
sunlight_propagates = false, sunlight_propagates = false,
paramtype = "light", paramtype = "light",
paramtype2 = "facedir",
walkable = true, walkable = true,
groups = { snappy = 3 }, groups = { snappy = 3 },
light_source = LIGHT_MAX, light_source = LIGHT_MAX,
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
homedecor_rotate_and_place(itemstack, placer, pointed_thing)
local node = minetest.env:get_node(pointed_thing.under)
if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].on_rightclick then
local above = pointed_thing.above
local under = pointed_thing.under
local pitch = placer:get_look_pitch()
local node = minetest.env:get_node(above)
if node.name ~= "air" then return end
if above.x ~= under.x or above.z ~= under.z then
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
minetest.env:add_node(above, {name = 'homedecor:glowlight_thick_yellow_wall', param2 = fdir})
else
minetest.env:add_node(above, {name = 'homedecor:glowlight_thick_yellow'})
end
if not homedecor_expect_infinite_stacks then
itemstack:take_item()
return itemstack
end
else
minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer)
end
end end
}) })
minetest.register_node('homedecor:glowlight_thick_yellow_wall', { minetest.register_node('homedecor:glowlight_quarter_yellow', {
description = S("Yellow Glowlight (thick, on wall)"),
drawtype = "nodebox",
tiles = {
'homedecor_glowlight_thick_yellow_sides.png',
'homedecor_glowlight_thick_yellow_sides.png',
'homedecor_glowlight_thick_yellow_wall_sides.png',
'homedecor_glowlight_thick_yellow_wall_sides.png',
'homedecor_glowlight_yellow_tb.png',
'homedecor_glowlight_yellow_tb.png'
},
selection_box = {
type = "fixed",
fixed = { -0.5, -0.5, 0, 0.5, 0.5, 0.5 }
},
node_box = {
type = "fixed",
fixed = { -0.5, -0.5, 0, 0.5, 0.5, 0.5 }
},
sunlight_propagates = false,
paramtype = "light",
paramtype2 = "facedir",
walkable = true,
groups = { snappy = 3, not_in_creative_inventory=1 },
light_source = LIGHT_MAX,
sounds = default.node_sound_wood_defaults(),
on_place = function(itemstack, placer, pointed_thing)
local node = minetest.env:get_node(pointed_thing.under)
if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].on_rightclick then
local above = pointed_thing.above
local under = pointed_thing.under
local pitch = placer:get_look_pitch()
local node = minetest.env:get_node(above)
if node.name ~= "air" then return end
if above.x ~= under.x or above.z ~= under.z then
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
minetest.env:add_node(above, {name = 'homedecor:glowlight_thick_yellow_wall', param2 = fdir})
else
minetest.env:add_node(above, {name = 'homedecor:glowlight_thick_yellow'})
end
if not homedecor_expect_infinite_stacks then
itemstack:take_item()
return itemstack
end
else
minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer)
end
end,
drop = 'homedecor:glowlight_thick_yellow'
})
minetest.register_node('homedecor:glowlight_thin_yellow', {
description = S("Yellow Glowlight (thin)"), description = S("Yellow Glowlight (thin)"),
drawtype = "nodebox", drawtype = "nodebox",
tiles = { tiles = {
@ -135,102 +150,95 @@ minetest.register_node('homedecor:glowlight_thin_yellow', {
}, },
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = { -0.5, 0.25, -0.5, 0.5, 0.5, 0.5 } fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
}, },
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = { -0.5, 0.25, -0.5, 0.5, 0.5, 0.5 } fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
}, },
sunlight_propagates = false, sunlight_propagates = false,
paramtype = "light", paramtype = "light",
paramtype2 = "facedir",
walkable = true, walkable = true,
groups = { snappy = 3 }, groups = { snappy = 3 },
light_source = LIGHT_MAX-1, light_source = LIGHT_MAX-1,
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
homedecor_rotate_and_place(itemstack, placer, pointed_thing)
local node = minetest.env:get_node(pointed_thing.under)
if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].on_rightclick then
local above = pointed_thing.above
local under = pointed_thing.under
local pitch = placer:get_look_pitch()
local node = minetest.env:get_node(above)
if node.name ~= "air" then return end
if above.x ~= under.x or above.z ~= under.z then
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
minetest.env:add_node(above, {name = 'homedecor:glowlight_thin_yellow_wall', param2 = fdir})
else
minetest.env:add_node(above, {name = 'homedecor:glowlight_thin_yellow'})
end
if not homedecor_expect_infinite_stacks then
itemstack:take_item()
return itemstack
end
else
minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer)
end
end end
}) })
minetest.register_node('homedecor:glowlight_thin_yellow_wall', {
description = S("Yellow Glowlight (thin, on wall)"),
-- White
minetest.register_node('homedecor:glowlight_half_white', {
description = S("White Glowlight (thick)"),
drawtype = "nodebox", drawtype = "nodebox",
tiles = { tiles = {
'homedecor_glowlight_thin_yellow_sides.png', 'homedecor_glowlight_white_tb.png',
'homedecor_glowlight_thin_yellow_sides.png', 'homedecor_glowlight_white_tb.png',
'homedecor_glowlight_thin_yellow_wall_sides.png', 'homedecor_glowlight_thick_white_sides.png',
'homedecor_glowlight_thin_yellow_wall_sides.png', 'homedecor_glowlight_thick_white_sides.png',
'homedecor_glowlight_yellow_tb.png', 'homedecor_glowlight_thick_white_sides.png',
'homedecor_glowlight_yellow_tb.png' 'homedecor_glowlight_thick_white_sides.png'
}, },
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = { -0.5, -0.5, 0.25, 0.5, 0.5, 0.5 } fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
}, },
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = { -0.5, -0.5, 0.25, 0.5, 0.5, 0.5 } fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
}, },
sunlight_propagates = false, sunlight_propagates = false,
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
walkable = true, walkable = true,
groups = { snappy = 3, not_in_creative_inventory=1 }, groups = { snappy = 3 },
light_source = LIGHT_MAX,
sounds = default.node_sound_wood_defaults(),
on_place = function(itemstack, placer, pointed_thing)
homedecor_rotate_and_place(itemstack, placer, pointed_thing)
end
})
minetest.register_node('homedecor:glowlight_quarter_white', {
description = S("White Glowlight (thin)"),
drawtype = "nodebox",
tiles = {
'homedecor_glowlight_white_tb.png',
'homedecor_glowlight_white_tb.png',
'homedecor_glowlight_thin_white_sides.png',
'homedecor_glowlight_thin_white_sides.png',
'homedecor_glowlight_thin_white_sides.png',
'homedecor_glowlight_thin_white_sides.png'
},
selection_box = {
type = "fixed",
fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
},
node_box = {
type = "fixed",
fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
},
sunlight_propagates = false,
paramtype = "light",
paramtype2 = "facedir",
walkable = true,
groups = { snappy = 3 },
light_source = LIGHT_MAX-1, light_source = LIGHT_MAX-1,
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
homedecor_rotate_and_place(itemstack, placer, pointed_thing)
local node = minetest.env:get_node(pointed_thing.under) end
if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].on_rightclick then
local above = pointed_thing.above
local under = pointed_thing.under
local pitch = placer:get_look_pitch()
local node = minetest.env:get_node(above)
if node.name ~= "air" then return end
if above.x ~= under.x or above.z ~= under.z then
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
minetest.env:add_node(above, {name = 'homedecor:glowlight_thin_yellow_wall', param2 = fdir})
else
minetest.env:add_node(above, {name = 'homedecor:glowlight_thin_yellow'})
end
if not homedecor_expect_infinite_stacks then
itemstack:take_item()
return itemstack
end
else
minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer)
end
end,
drop = 'homedecor:glowlight_thin_yellow'
}) })
-- Glowlight "cubes"
minetest.register_node('homedecor:glowlight_small_cube_yellow', { minetest.register_node('homedecor:glowlight_small_cube_yellow', {
description = S("Yellow Glowlight (small cube)"), description = S("Yellow Glowlight (small cube)"),
drawtype = "nodebox", drawtype = "nodebox",
@ -251,314 +259,19 @@ minetest.register_node('homedecor:glowlight_small_cube_yellow', {
fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 } fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
}, },
sunlight_propagates = false,
paramtype = "light",
walkable = true,
groups = { snappy = 3 },
light_source = LIGHT_MAX-1,
sounds = default.node_sound_wood_defaults(),
on_place = function(itemstack, placer, pointed_thing)
local node = minetest.env:get_node(pointed_thing.under)
if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].on_rightclick then
local above = pointed_thing.above
local under = pointed_thing.under
local pitch = placer:get_look_pitch()
local node = minetest.env:get_node(above)
if node.name ~= "air" then return end
if above.x == under.x and above.z == under.z and pitch > 0 then
minetest.env:add_node(above, {name = 'homedecor:glowlight_small_cube_yellow_ceiling'})
else
minetest.env:add_node(above, {name = 'homedecor:glowlight_small_cube_yellow'})
end
if not homedecor_expect_infinite_stacks then
itemstack:take_item()
return itemstack
end
else
minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer)
end
end
})
minetest.register_node('homedecor:glowlight_small_cube_yellow_ceiling', {
description = S("Yellow Glowlight (small cube, on ceiling)"),
drawtype = "nodebox",
tiles = {
'homedecor_glowlight_cube_yellow_tb.png',
'homedecor_glowlight_cube_yellow_tb.png',
'homedecor_glowlight_cube_yellow_sides_ceiling.png',
'homedecor_glowlight_cube_yellow_sides_ceiling.png',
'homedecor_glowlight_cube_yellow_sides_ceiling.png',
'homedecor_glowlight_cube_yellow_sides_ceiling.png'
},
selection_box = {
type = "fixed",
fixed = { -0.25, 0, -0.25, 0.25, 0.5, 0.25 }
},
node_box = {
type = "fixed",
fixed = { -0.25, 0, -0.25, 0.25, 0.5, 0.25 }
},
sunlight_propagates = false,
paramtype = "light",
walkable = true,
groups = { snappy = 3, not_in_creative_inventory=1 },
light_source = LIGHT_MAX-1,
sounds = default.node_sound_wood_defaults(),
on_place = function(itemstack, placer, pointed_thing)
local node = minetest.env:get_node(pointed_thing.under)
if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].on_rightclick then
local above = pointed_thing.above
local under = pointed_thing.under
local pitch = placer:get_look_pitch()
local node = minetest.env:get_node(above)
if node.name ~= "air" then return end
if above.x == under.x and above.z == under.z and pitch > 0 then
minetest.env:add_node(above, {name = 'homedecor:glowlight_small_cube_yellow_ceiling'})
else
minetest.env:add_node(above, {name = 'homedecor:glowlight_small_cube_yellow'})
end
if not homedecor_expect_infinite_stacks then
itemstack:take_item()
return itemstack
end
else
minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer)
end
end,
drop = "homedecor:glowlight_small_cube_yellow",
})
-- White
minetest.register_node('homedecor:glowlight_thick_white', {
description = S("White Glowlight (thick)"),
drawtype = "nodebox",
tiles = {
'homedecor_glowlight_white_tb.png',
'homedecor_glowlight_white_tb.png',
'homedecor_glowlight_thick_white_sides.png',
'homedecor_glowlight_thick_white_sides.png',
'homedecor_glowlight_thick_white_sides.png',
'homedecor_glowlight_thick_white_sides.png'
},
selection_box = {
type = "fixed",
fixed = { -0.5, 0, -0.5, 0.5, 0.5, 0.5 }
},
node_box = {
type = "fixed",
fixed = { -0.5, 0, -0.5, 0.5, 0.5, 0.5 }
},
sunlight_propagates = false,
paramtype = "light",
walkable = true,
groups = { snappy = 3 },
light_source = LIGHT_MAX,
sounds = default.node_sound_wood_defaults(),
on_place = function(itemstack, placer, pointed_thing)
local node = minetest.env:get_node(pointed_thing.under)
if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].on_rightclick then
local above = pointed_thing.above
local under = pointed_thing.under
local pitch = placer:get_look_pitch()
local node = minetest.env:get_node(above)
if node.name ~= "air" then return end
if above.x ~= under.x or above.z ~= under.z then
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
minetest.env:add_node(above, {name = 'homedecor:glowlight_thick_white_wall', param2 = fdir})
else
minetest.env:add_node(above, {name = 'homedecor:glowlight_thick_white'})
end
if not homedecor_expect_infinite_stacks then
itemstack:take_item()
return itemstack
end
else
minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer)
end
end
})
minetest.register_node('homedecor:glowlight_thick_white_wall', {
description = S("White Glowlight (thick, on wall)"),
drawtype = "nodebox",
tiles = {
'homedecor_glowlight_thick_white_sides.png',
'homedecor_glowlight_thick_white_sides.png',
'homedecor_glowlight_thick_white_wall_sides.png',
'homedecor_glowlight_thick_white_wall_sides.png',
'homedecor_glowlight_white_tb.png',
'homedecor_glowlight_white_tb.png'
},
selection_box = {
type = "fixed",
fixed = { -0.5, -0.5, 0, 0.5, 0.5, 0.5 }
},
node_box = {
type = "fixed",
fixed = { -0.5, -0.5, 0, 0.5, 0.5, 0.5 }
},
sunlight_propagates = false, sunlight_propagates = false,
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
walkable = true, walkable = true,
groups = { snappy = 3, not_in_creative_inventory=1 },
light_source = LIGHT_MAX,
sounds = default.node_sound_wood_defaults(),
on_place = function(itemstack, placer, pointed_thing)
local node = minetest.env:get_node(pointed_thing.under)
if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].on_rightclick then
local above = pointed_thing.above
local under = pointed_thing.under
local pitch = placer:get_look_pitch()
local node = minetest.env:get_node(above)
if node.name ~= "air" then return end
if above.x ~= under.x or above.z ~= under.z then
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
minetest.env:add_node(above, {name = 'homedecor:glowlight_thick_white_wall', param2 = fdir})
else
minetest.env:add_node(above, {name = 'homedecor:glowlight_thick_white'})
end
if not homedecor_expect_infinite_stacks then
itemstack:take_item()
return itemstack
end
else
minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer)
end
end,
drop = 'homedecor:glowlight_thick_white'
})
minetest.register_node('homedecor:glowlight_thin_white', {
description = S("White Glowlight (thin)"),
drawtype = "nodebox",
tiles = {
'homedecor_glowlight_white_tb.png',
'homedecor_glowlight_white_tb.png',
'homedecor_glowlight_thin_white_sides.png',
'homedecor_glowlight_thin_white_sides.png',
'homedecor_glowlight_thin_white_sides.png',
'homedecor_glowlight_thin_white_sides.png'
},
selection_box = {
type = "fixed",
fixed = { -0.5, 0.25, -0.5, 0.5, 0.5, 0.5 }
},
node_box = {
type = "fixed",
fixed = { -0.5, 0.25, -0.5, 0.5, 0.5, 0.5 }
},
sunlight_propagates = false,
paramtype = "light",
walkable = true,
groups = { snappy = 3 }, groups = { snappy = 3 },
light_source = LIGHT_MAX-1, light_source = LIGHT_MAX-1,
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
homedecor_rotate_and_place(itemstack, placer, pointed_thing)
local node = minetest.env:get_node(pointed_thing.under)
if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].on_rightclick then
local above = pointed_thing.above
local under = pointed_thing.under
local pitch = placer:get_look_pitch()
local node = minetest.env:get_node(above)
if node.name ~= "air" then return end
if above.x ~= under.x or above.z ~= under.z then
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
minetest.env:add_node(above, {name = 'homedecor:glowlight_thin_white_wall', param2 = fdir})
else
minetest.env:add_node(above, {name = 'homedecor:glowlight_thin_white'})
end
if not homedecor_expect_infinite_stacks then
itemstack:take_item()
return itemstack
end
else
minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer)
end
end end
}) })
minetest.register_node('homedecor:glowlight_thin_white_wall', {
description = S("White Glowlight (thin, on wall)"),
drawtype = "nodebox",
tiles = {
'homedecor_glowlight_thin_white_sides.png',
'homedecor_glowlight_thin_white_sides.png',
'homedecor_glowlight_thin_white_wall_sides.png',
'homedecor_glowlight_thin_white_wall_sides.png',
'homedecor_glowlight_white_tb.png',
'homedecor_glowlight_white_tb.png'
},
selection_box = {
type = "fixed",
fixed = { -0.5, -0.5, 0.25, 0.5, 0.5, 0.5 }
},
node_box = {
type = "fixed",
fixed = { -0.5, -0.5, 0.25, 0.5, 0.5, 0.5 }
},
sunlight_propagates = false,
paramtype = "light",
paramtype2 = "facedir",
walkable = true,
groups = { snappy = 3, not_in_creative_inventory=1 },
light_source = LIGHT_MAX-1,
sounds = default.node_sound_wood_defaults(),
on_place = function(itemstack, placer, pointed_thing)
local node = minetest.env:get_node(pointed_thing.under)
if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].on_rightclick then
local above = pointed_thing.above
local under = pointed_thing.under
local pitch = placer:get_look_pitch()
local node = minetest.env:get_node(above)
if node.name ~= "air" then return end
if above.x ~= under.x or above.z ~= under.z then
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
minetest.env:add_node(above, {name = 'homedecor:glowlight_thin_white_wall', param2 = fdir})
else
minetest.env:add_node(above, {name = 'homedecor:glowlight_thin_white'})
end
if not homedecor_expect_infinite_stacks then
itemstack:take_item()
return itemstack
end
else
minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer)
end
end,
drop = 'homedecor:glowlight_thin_white'
})
minetest.register_node('homedecor:glowlight_small_cube_white', { minetest.register_node('homedecor:glowlight_small_cube_white', {
description = S("White Glowlight (small cube)"), description = S("White Glowlight (small cube)"),
drawtype = "nodebox", drawtype = "nodebox",
@ -581,87 +294,13 @@ minetest.register_node('homedecor:glowlight_small_cube_white', {
sunlight_propagates = false, sunlight_propagates = false,
paramtype = "light", paramtype = "light",
paramtype2 = "facedir",
walkable = true, walkable = true,
groups = { snappy = 3 }, groups = { snappy = 3 },
light_source = LIGHT_MAX-1, light_source = LIGHT_MAX-1,
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
homedecor_rotate_and_place(itemstack, placer, pointed_thing)
local node = minetest.env:get_node(pointed_thing.under)
if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].on_rightclick then
local above = pointed_thing.above
local under = pointed_thing.under
local pitch = placer:get_look_pitch()
local node = minetest.env:get_node(above)
if node.name ~= "air" then return end
if above.x == under.x and above.z == under.z and pitch > 0 then
minetest.env:add_node(above, {name = 'homedecor:glowlight_small_cube_white_ceiling'})
else
minetest.env:add_node(above, {name = 'homedecor:glowlight_small_cube_white'})
end
if not homedecor_expect_infinite_stacks then
itemstack:take_item()
return itemstack
end
else
minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer)
end
end end
}) })
minetest.register_node('homedecor:glowlight_small_cube_white_ceiling', {
description = S("White Glowlight (small cube, on ceiling)"),
drawtype = "nodebox",
tiles = {
'homedecor_glowlight_cube_white_tb.png',
'homedecor_glowlight_cube_white_tb.png',
'homedecor_glowlight_cube_white_sides_ceiling.png',
'homedecor_glowlight_cube_white_sides_ceiling.png',
'homedecor_glowlight_cube_white_sides_ceiling.png',
'homedecor_glowlight_cube_white_sides_ceiling.png'
},
selection_box = {
type = "fixed",
fixed = { -0.25, 0, -0.25, 0.25, 0.5, 0.25 }
},
node_box = {
type = "fixed",
fixed = { -0.25, 0, -0.25, 0.25, 0.5, 0.25 }
},
sunlight_propagates = false,
paramtype = "light",
walkable = true,
groups = { snappy = 3, not_in_creative_inventory=1 },
light_source = LIGHT_MAX-1,
sounds = default.node_sound_wood_defaults(),
on_place = function(itemstack, placer, pointed_thing)
local node = minetest.env:get_node(pointed_thing.under)
if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].on_rightclick then
local above = pointed_thing.above
local under = pointed_thing.under
local pitch = placer:get_look_pitch()
local node = minetest.env:get_node(above)
if node.name ~= "air" then return end
if above.x == under.x and above.z == under.z and pitch > 0 then
minetest.env:add_node(above, {name = 'homedecor:glowlight_small_cube_white_ceiling'})
else
minetest.env:add_node(above, {name = 'homedecor:glowlight_small_cube_white'})
end
if not homedecor_expect_infinite_stacks then
itemstack:take_item()
return itemstack
end
else
minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer)
end
end,
drop = "homedecor:glowlight_small_cube_white",
})