homedecor_modpack/lighting.lua

294 lines
8.9 KiB
Lua
Raw Normal View History

-- This file supplies glowlights
2013-03-05 08:18:56 +01:00
-- Boilerplate to support localized strings if intllib mod is installed.
local S
if homedecor.intllib_modpath then
dofile(homedecor.intllib_modpath.."/intllib.lua")
2013-03-05 08:18:56 +01:00
S = intllib.Getter(minetest.get_current_modname())
else
S = function ( s ) return s 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.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.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.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.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.add_node(pos, {name = "homedecor:glowlight_small_cube_"..color, param2 = 20})
end,
})
end
-- Yellow
minetest.register_node('homedecor:glowlight_half_yellow', {
2013-03-05 08:18:56 +01:00
description = S("Yellow Glowlight (thick)"),
drawtype = "nodebox",
tiles = {
'homedecor_glowlight_yellow_top.png',
'homedecor_glowlight_yellow_bottom.png',
'homedecor_glowlight_thick_yellow_sides.png',
'homedecor_glowlight_thick_yellow_sides.png',
'homedecor_glowlight_thick_yellow_sides.png',
'homedecor_glowlight_thick_yellow_sides.png'
},
selection_box = {
type = "fixed",
fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
},
node_box = {
type = "fixed",
fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
},
sunlight_propagates = false,
paramtype = "light",
paramtype2 = "facedir",
walkable = true,
groups = { snappy = 3 },
light_source = LIGHT_MAX,
2013-03-17 00:46:30 +01:00
sounds = default.node_sound_wood_defaults(),
on_place = function(itemstack, placer, pointed_thing)
if not homedecor:node_is_owned(pointed_thing.under, placer)
and not homedecor:node_is_owned(pointed_thing.above, placer) then
lib_6d:rotate_and_place(itemstack, placer, pointed_thing, homedecor.expect_infinite_stacks)
end
return itemstack
end
})
minetest.register_node('homedecor:glowlight_quarter_yellow', {
2013-03-05 08:18:56 +01:00
description = S("Yellow Glowlight (thin)"),
drawtype = "nodebox",
tiles = {
'homedecor_glowlight_yellow_top.png',
'homedecor_glowlight_yellow_bottom.png',
'homedecor_glowlight_thin_yellow_sides.png',
'homedecor_glowlight_thin_yellow_sides.png',
'homedecor_glowlight_thin_yellow_sides.png',
'homedecor_glowlight_thin_yellow_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,
2013-03-17 00:46:30 +01:00
sounds = default.node_sound_wood_defaults(),
on_place = function(itemstack, placer, pointed_thing)
if not homedecor:node_is_owned(pointed_thing.under, placer)
and not homedecor:node_is_owned(pointed_thing.above, placer) then
lib_6d:rotate_and_place(itemstack, placer, pointed_thing, homedecor.expect_infinite_stacks)
end
return itemstack
end
})
-- White
minetest.register_node('homedecor:glowlight_half_white', {
2013-03-05 08:18:56 +01:00
description = S("White Glowlight (thick)"),
drawtype = "nodebox",
tiles = {
'homedecor_glowlight_white_top.png',
'homedecor_glowlight_white_bottom.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.5, -0.5, 0.5, 0, 0.5 }
},
node_box = {
type = "fixed",
fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
},
sunlight_propagates = false,
paramtype = "light",
paramtype2 = "facedir",
walkable = true,
groups = { snappy = 3 },
light_source = LIGHT_MAX,
2013-03-17 00:46:30 +01:00
sounds = default.node_sound_wood_defaults(),
on_place = function(itemstack, placer, pointed_thing)
if not homedecor:node_is_owned(pointed_thing.under, placer)
and not homedecor:node_is_owned(pointed_thing.above, placer) then
lib_6d:rotate_and_place(itemstack, placer, pointed_thing, homedecor.expect_infinite_stacks)
end
return itemstack
end
})
minetest.register_node('homedecor:glowlight_quarter_white', {
2013-03-05 08:18:56 +01:00
description = S("White Glowlight (thin)"),
drawtype = "nodebox",
tiles = {
'homedecor_glowlight_white_top.png',
'homedecor_glowlight_white_bottom.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,
2013-03-17 00:46:30 +01:00
sounds = default.node_sound_wood_defaults(),
on_place = function(itemstack, placer, pointed_thing)
if not homedecor:node_is_owned(pointed_thing.under, placer)
and not homedecor:node_is_owned(pointed_thing.above, placer) then
lib_6d:rotate_and_place(itemstack, placer, pointed_thing, homedecor.expect_infinite_stacks)
end
return itemstack
end
})
-- Glowlight "cubes"
minetest.register_node('homedecor:glowlight_small_cube_yellow', {
description = S("Yellow Glowlight (small cube)"),
drawtype = "nodebox",
tiles = {
'homedecor_glowlight_cube_yellow_tb.png',
'homedecor_glowlight_cube_yellow_tb.png',
'homedecor_glowlight_cube_yellow_sides.png',
'homedecor_glowlight_cube_yellow_sides.png',
'homedecor_glowlight_cube_yellow_sides.png',
'homedecor_glowlight_cube_yellow_sides.png'
},
selection_box = {
type = "fixed",
fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
},
node_box = {
type = "fixed",
fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
},
sunlight_propagates = false,
paramtype = "light",
paramtype2 = "facedir",
walkable = true,
groups = { snappy = 3 },
light_source = LIGHT_MAX-1,
2013-03-17 00:46:30 +01:00
sounds = default.node_sound_wood_defaults(),
on_place = function(itemstack, placer, pointed_thing)
if not homedecor:node_is_owned(pointed_thing.under, placer)
and not homedecor:node_is_owned(pointed_thing.above, placer) then
lib_6d:rotate_and_place(itemstack, placer, pointed_thing, homedecor.expect_infinite_stacks)
end
return itemstack
end
})
minetest.register_node('homedecor:glowlight_small_cube_white', {
2013-03-05 08:18:56 +01:00
description = S("White Glowlight (small cube)"),
drawtype = "nodebox",
tiles = {
'homedecor_glowlight_cube_white_tb.png',
'homedecor_glowlight_cube_white_tb.png',
'homedecor_glowlight_cube_white_sides.png',
'homedecor_glowlight_cube_white_sides.png',
'homedecor_glowlight_cube_white_sides.png',
'homedecor_glowlight_cube_white_sides.png'
},
selection_box = {
type = "fixed",
fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
},
node_box = {
type = "fixed",
fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
},
sunlight_propagates = false,
paramtype = "light",
paramtype2 = "facedir",
walkable = true,
groups = { snappy = 3 },
light_source = LIGHT_MAX-1,
2013-03-17 00:46:30 +01:00
sounds = default.node_sound_wood_defaults(),
on_place = function(itemstack, placer, pointed_thing)
if not homedecor:node_is_owned(pointed_thing.under, placer)
and not homedecor:node_is_owned(pointed_thing.above, placer) then
lib_6d:rotate_and_place(itemstack, placer, pointed_thing, homedecor.expect_infinite_stacks)
end
return itemstack
end
})