2012-10-02 01:22:54 +02:00
|
|
|
|
|
|
|
-- 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 (minetest.get_modpath("intllib")) then
|
|
|
|
dofile(minetest.get_modpath("intllib").."/intllib.lua")
|
|
|
|
S = intllib.Getter(minetest.get_current_modname())
|
|
|
|
else
|
|
|
|
S = function ( s ) return s end
|
|
|
|
end
|
|
|
|
|
2013-04-24 18:30:21 +02:00
|
|
|
local dirs1 = { 20, 23, 22, 21 }
|
|
|
|
local dirs2 = { 9, 18, 7, 12 }
|
|
|
|
|
|
|
|
function homedecor_rotate_and_place(itemstack, placer, pointed_thing)
|
2013-06-07 20:11:42 +02:00
|
|
|
if not homedecor_node_is_owned(pointed_thing.under, placer)
|
|
|
|
and not homedecor_node_is_owned(pointed_thing.above, placer) then
|
2013-07-01 05:55:07 +02:00
|
|
|
local node = minetest.get_node(pointed_thing.under)
|
2013-06-07 20:11:42 +02:00
|
|
|
if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].on_rightclick then
|
2013-04-24 18:30:21 +02:00
|
|
|
|
2013-06-07 20:11:42 +02:00
|
|
|
local above = pointed_thing.above
|
|
|
|
local under = pointed_thing.under
|
|
|
|
local pitch = placer:get_look_pitch()
|
2013-07-01 05:55:07 +02:00
|
|
|
local pname = minetest.get_node(under).name
|
|
|
|
local node = minetest.get_node(above)
|
2013-06-07 20:11:42 +02:00
|
|
|
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
|
|
|
|
local wield_name = itemstack:get_name()
|
2013-04-24 18:30:21 +02:00
|
|
|
|
2013-06-07 20:11:42 +02:00
|
|
|
if not minetest.registered_nodes[pname]
|
|
|
|
or not minetest.registered_nodes[pname].on_rightclick then
|
2013-04-24 18:30:21 +02:00
|
|
|
|
2013-06-07 20:11:42 +02:00
|
|
|
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)
|
|
|
|
local pos1 = above
|
2013-04-24 18:30:21 +02:00
|
|
|
|
2013-06-07 20:11:42 +02:00
|
|
|
if minetest.registered_nodes[pname]["buildable_to"] then
|
|
|
|
pos1 = under
|
|
|
|
iswall = false
|
|
|
|
end
|
2013-04-24 18:30:21 +02:00
|
|
|
|
2013-07-01 05:55:07 +02:00
|
|
|
if not minetest.registered_nodes[minetest.get_node(pos1).name]["buildable_to"] then return end
|
2013-04-24 18:30:21 +02:00
|
|
|
|
2013-06-07 20:11:42 +02:00
|
|
|
if iswall then
|
2013-07-01 05:55:07 +02:00
|
|
|
minetest.add_node(pos1, {name = wield_name, param2 = dirs2[fdir+1] }) -- place wall variant
|
2013-06-07 20:11:42 +02:00
|
|
|
elseif isceiling then
|
2013-07-01 05:55:07 +02:00
|
|
|
minetest.add_node(pos1, {name = wield_name, param2 = 20 }) -- place upside down variant
|
2013-06-07 20:11:42 +02:00
|
|
|
else
|
2013-07-01 05:55:07 +02:00
|
|
|
minetest.add_node(pos1, {name = wield_name, param2 = 0 }) -- place right side up
|
2013-06-07 20:11:42 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
if not homedecor_expect_infinite_stacks then
|
|
|
|
itemstack:take_item()
|
|
|
|
return itemstack
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack)
|
2013-04-24 18:30:21 +02:00
|
|
|
end
|
|
|
|
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)
|
2013-07-01 05:55:07 +02:00
|
|
|
minetest.add_node(pos, {name = "homedecor:glowlight_quarter_"..color, param2 = 20})
|
2013-04-24 18:30:21 +02:00
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_abm({
|
|
|
|
nodenames = { "homedecor:glowlight_thick_"..color },
|
|
|
|
interval = 1,
|
|
|
|
chance = 1,
|
|
|
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
2013-07-01 05:55:07 +02:00
|
|
|
minetest.add_node(pos, {name = "homedecor:glowlight_half_"..color, param2 = 20})
|
2013-04-24 18:30:21 +02:00
|
|
|
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]
|
2013-07-01 05:55:07 +02:00
|
|
|
minetest.add_node(pos, {name = "homedecor:glowlight_quarter_"..color, param2 = nfdir})
|
2013-04-24 18:30:21 +02:00
|
|
|
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]
|
2013-07-01 05:55:07 +02:00
|
|
|
minetest.add_node(pos, {name = "homedecor:glowlight_half_"..color, param2 = nfdir})
|
2013-04-24 18:30:21 +02:00
|
|
|
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)
|
2013-07-01 05:55:07 +02:00
|
|
|
minetest.add_node(pos, {name = "homedecor:glowlight_small_cube_"..color, param2 = 20})
|
2013-04-24 18:30:21 +02:00
|
|
|
end,
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
2012-10-02 01:22:54 +02:00
|
|
|
-- Yellow
|
|
|
|
|
2013-04-24 18:30:21 +02:00
|
|
|
minetest.register_node('homedecor:glowlight_half_yellow', {
|
2013-03-05 08:18:56 +01:00
|
|
|
description = S("Yellow Glowlight (thick)"),
|
2012-10-02 01:22:54 +02:00
|
|
|
drawtype = "nodebox",
|
|
|
|
tiles = {
|
|
|
|
'homedecor_glowlight_yellow_tb.png',
|
|
|
|
'homedecor_glowlight_yellow_tb.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",
|
2013-04-24 18:30:21 +02:00
|
|
|
fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
|
2012-10-02 01:22:54 +02:00
|
|
|
},
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
2013-04-24 18:30:21 +02:00
|
|
|
fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
|
2012-10-02 01:22:54 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
sunlight_propagates = false,
|
|
|
|
paramtype = "light",
|
2013-04-24 18:30:21 +02:00
|
|
|
paramtype2 = "facedir",
|
2012-10-02 01:22:54 +02:00
|
|
|
walkable = true,
|
|
|
|
groups = { snappy = 3 },
|
|
|
|
light_source = LIGHT_MAX,
|
2013-03-17 00:46:30 +01:00
|
|
|
sounds = default.node_sound_wood_defaults(),
|
2013-04-14 21:45:21 +02:00
|
|
|
|
|
|
|
on_place = function(itemstack, placer, pointed_thing)
|
2013-04-24 18:30:21 +02:00
|
|
|
homedecor_rotate_and_place(itemstack, placer, pointed_thing)
|
2013-06-07 19:15:54 +02:00
|
|
|
return itemstack
|
2013-04-14 21:45:21 +02:00
|
|
|
end
|
2012-10-02 01:22:54 +02:00
|
|
|
})
|
|
|
|
|
2013-04-24 18:30:21 +02:00
|
|
|
minetest.register_node('homedecor:glowlight_quarter_yellow', {
|
2013-03-05 08:18:56 +01:00
|
|
|
description = S("Yellow Glowlight (thin)"),
|
2012-10-02 01:22:54 +02:00
|
|
|
drawtype = "nodebox",
|
|
|
|
tiles = {
|
|
|
|
'homedecor_glowlight_yellow_tb.png',
|
|
|
|
'homedecor_glowlight_yellow_tb.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",
|
2013-04-24 18:30:21 +02:00
|
|
|
fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
|
2012-10-02 01:22:54 +02:00
|
|
|
},
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
2013-04-24 18:30:21 +02:00
|
|
|
fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
|
2012-10-02 01:22:54 +02:00
|
|
|
},
|
|
|
|
|
2012-10-04 00:53:17 +02:00
|
|
|
sunlight_propagates = false,
|
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "facedir",
|
|
|
|
walkable = true,
|
2012-10-02 01:22:54 +02:00
|
|
|
groups = { snappy = 3 },
|
|
|
|
light_source = LIGHT_MAX-1,
|
2013-03-17 00:46:30 +01:00
|
|
|
sounds = default.node_sound_wood_defaults(),
|
2013-04-14 21:45:21 +02:00
|
|
|
on_place = function(itemstack, placer, pointed_thing)
|
2013-04-24 18:30:21 +02:00
|
|
|
homedecor_rotate_and_place(itemstack, placer, pointed_thing)
|
2013-06-07 19:15:54 +02:00
|
|
|
return itemstack
|
2013-04-14 21:45:21 +02:00
|
|
|
end
|
2012-10-02 01:22:54 +02:00
|
|
|
})
|
|
|
|
|
2013-04-14 22:22:08 +02:00
|
|
|
|
2012-10-02 03:06:10 +02:00
|
|
|
|
2012-10-02 01:22:54 +02:00
|
|
|
-- White
|
|
|
|
|
2013-04-24 18:30:21 +02:00
|
|
|
minetest.register_node('homedecor:glowlight_half_white', {
|
2013-03-05 08:18:56 +01:00
|
|
|
description = S("White Glowlight (thick)"),
|
2012-10-02 01:22:54 +02:00
|
|
|
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",
|
2013-04-24 18:30:21 +02:00
|
|
|
fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
|
2012-10-02 01:22:54 +02:00
|
|
|
},
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
2013-04-24 18:30:21 +02:00
|
|
|
fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
|
2012-10-02 01:22:54 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
sunlight_propagates = false,
|
|
|
|
paramtype = "light",
|
2013-04-24 18:30:21 +02:00
|
|
|
paramtype2 = "facedir",
|
2012-10-02 01:22:54 +02:00
|
|
|
walkable = true,
|
|
|
|
groups = { snappy = 3 },
|
|
|
|
light_source = LIGHT_MAX,
|
2013-03-17 00:46:30 +01:00
|
|
|
sounds = default.node_sound_wood_defaults(),
|
2013-04-14 21:45:21 +02:00
|
|
|
on_place = function(itemstack, placer, pointed_thing)
|
2013-04-24 18:30:21 +02:00
|
|
|
homedecor_rotate_and_place(itemstack, placer, pointed_thing)
|
2013-06-07 19:15:54 +02:00
|
|
|
return itemstack
|
2013-04-14 21:45:21 +02:00
|
|
|
end
|
2012-10-02 01:22:54 +02:00
|
|
|
})
|
|
|
|
|
2013-04-24 18:30:21 +02:00
|
|
|
minetest.register_node('homedecor:glowlight_quarter_white', {
|
2013-03-05 08:18:56 +01:00
|
|
|
description = S("White Glowlight (thin)"),
|
2012-10-02 01:22:54 +02:00
|
|
|
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",
|
2013-04-24 18:30:21 +02:00
|
|
|
fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
|
2012-10-02 01:22:54 +02:00
|
|
|
},
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
2013-04-24 18:30:21 +02:00
|
|
|
fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
|
2012-10-02 01:22:54 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
sunlight_propagates = false,
|
|
|
|
paramtype = "light",
|
2013-04-24 18:30:21 +02:00
|
|
|
paramtype2 = "facedir",
|
2012-10-02 01:22:54 +02:00
|
|
|
walkable = true,
|
|
|
|
groups = { snappy = 3 },
|
|
|
|
light_source = LIGHT_MAX-1,
|
2013-03-17 00:46:30 +01:00
|
|
|
sounds = default.node_sound_wood_defaults(),
|
2013-04-14 21:45:21 +02:00
|
|
|
on_place = function(itemstack, placer, pointed_thing)
|
2013-04-24 18:30:21 +02:00
|
|
|
homedecor_rotate_and_place(itemstack, placer, pointed_thing)
|
2013-06-07 19:15:54 +02:00
|
|
|
return itemstack
|
2013-04-14 21:45:21 +02:00
|
|
|
end
|
2012-10-02 01:22:54 +02:00
|
|
|
})
|
|
|
|
|
2013-04-24 18:30:21 +02:00
|
|
|
-- Glowlight "cubes"
|
|
|
|
|
|
|
|
minetest.register_node('homedecor:glowlight_small_cube_yellow', {
|
|
|
|
description = S("Yellow Glowlight (small cube)"),
|
2012-10-04 00:53:17 +02:00
|
|
|
drawtype = "nodebox",
|
|
|
|
tiles = {
|
2013-04-24 18:30:21 +02:00
|
|
|
'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'
|
2012-10-04 00:53:17 +02:00
|
|
|
},
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
2013-04-24 18:30:21 +02:00
|
|
|
fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
|
2012-10-04 00:53:17 +02:00
|
|
|
},
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
2013-04-24 18:30:21 +02:00
|
|
|
fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
|
2012-10-04 00:53:17 +02:00
|
|
|
},
|
2013-04-24 18:30:21 +02:00
|
|
|
|
2012-10-04 00:53:17 +02:00
|
|
|
sunlight_propagates = false,
|
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "facedir",
|
|
|
|
walkable = true,
|
2013-04-24 18:30:21 +02:00
|
|
|
groups = { snappy = 3 },
|
2012-10-04 00:53:17 +02:00
|
|
|
light_source = LIGHT_MAX-1,
|
2013-03-17 00:46:30 +01:00
|
|
|
sounds = default.node_sound_wood_defaults(),
|
2013-04-14 22:22:08 +02:00
|
|
|
|
2013-04-24 18:30:21 +02:00
|
|
|
on_place = function(itemstack, placer, pointed_thing)
|
|
|
|
homedecor_rotate_and_place(itemstack, placer, pointed_thing)
|
2013-06-07 19:15:54 +02:00
|
|
|
return itemstack
|
2013-04-24 18:30:21 +02:00
|
|
|
end
|
2012-10-04 00:53:17 +02:00
|
|
|
})
|
|
|
|
|
2012-10-02 01:22:54 +02:00
|
|
|
minetest.register_node('homedecor:glowlight_small_cube_white', {
|
2013-03-05 08:18:56 +01:00
|
|
|
description = S("White Glowlight (small cube)"),
|
2012-10-02 01:22:54 +02:00
|
|
|
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",
|
2013-04-24 18:30:21 +02:00
|
|
|
paramtype2 = "facedir",
|
2012-10-02 01:22:54 +02:00
|
|
|
walkable = true,
|
|
|
|
groups = { snappy = 3 },
|
|
|
|
light_source = LIGHT_MAX-1,
|
2013-03-17 00:46:30 +01:00
|
|
|
sounds = default.node_sound_wood_defaults(),
|
2013-04-14 21:45:21 +02:00
|
|
|
on_place = function(itemstack, placer, pointed_thing)
|
2013-04-24 18:30:21 +02:00
|
|
|
homedecor_rotate_and_place(itemstack, placer, pointed_thing)
|
2013-06-07 19:15:54 +02:00
|
|
|
return itemstack
|
2013-04-14 21:45:21 +02:00
|
|
|
end
|
2012-10-02 01:22:54 +02:00
|
|
|
})
|
2012-10-02 03:06:10 +02:00
|
|
|
|