2019-03-04 23:49:16 -05:00
|
|
|
-- LUALOCALS < ---------------------------------------------------------
|
2019-03-07 10:04:32 -05:00
|
|
|
local minetest, nodecore, vector
|
|
|
|
= minetest, nodecore, vector
|
2019-03-04 23:49:16 -05:00
|
|
|
-- LUALOCALS > ---------------------------------------------------------
|
|
|
|
|
|
|
|
local modname = minetest.get_current_modname()
|
|
|
|
|
2019-03-07 00:58:37 -05:00
|
|
|
local function prism_check(pos, node, check)
|
|
|
|
local face = nodecore.facedirs[node.param2]
|
|
|
|
|
|
|
|
local power = (check(face.f) or check(face.r))
|
|
|
|
and (not check(face.t)) and (not check(face.b))
|
|
|
|
|
|
|
|
if power then
|
2019-03-12 20:22:42 -04:00
|
|
|
return modname .. ":prism_on", {face.k, face.l}
|
2019-03-07 00:58:37 -05:00
|
|
|
end
|
2019-03-12 20:22:42 -04:00
|
|
|
return modname .. ":prism"
|
2019-03-07 00:58:37 -05:00
|
|
|
end
|
|
|
|
|
2019-03-07 19:26:53 -05:00
|
|
|
local txr = modname .. "_glass_frost.png"
|
|
|
|
|
2019-03-07 00:58:37 -05:00
|
|
|
local basedef = {
|
|
|
|
description = "Prism",
|
|
|
|
drawtype = "nodebox",
|
|
|
|
node_box = nodecore.fixedbox(
|
|
|
|
{-3/8, -3/8, -0.5, -0.25, 3/8, -3/8},
|
|
|
|
{3/8, -3/8, 0.25, 0.5, 3/8, 3/8},
|
|
|
|
{-3/8, -0.5, -0.5, 0.5, -3/8, 3/8},
|
|
|
|
{-3/8, 3/8, -0.5, 0.5, 0.5, 3/8},
|
|
|
|
{-3/8, -3/8, -3/8, 3/8, 3/8, 3/8},
|
|
|
|
{-0.25, -0.25, 3/8, 0.25, 0.25, 0.5},
|
|
|
|
{-0.5, -0.25, -0.25, -3/8, 0.25, 0.25}
|
|
|
|
),
|
2019-03-30 21:23:02 -04:00
|
|
|
selection_box = nodecore.fixedbox(
|
|
|
|
{-3/8, -0.5, -0.5, 0.5, 0.5, 3/8}
|
|
|
|
),
|
2019-03-07 00:58:37 -05:00
|
|
|
tiles = {
|
2019-03-07 19:26:53 -05:00
|
|
|
txr,
|
|
|
|
txr,
|
|
|
|
txr .. "^" .. modname .. "_prism_in.png",
|
|
|
|
txr .. "^" .. modname .. "_lens_out.png",
|
|
|
|
txr .. "^" .. modname .. "_lens_out.png",
|
|
|
|
txr .. "^(" .. modname .. "_prism_in.png^[transformFX)",
|
2019-03-07 00:58:37 -05:00
|
|
|
},
|
|
|
|
groups = {
|
2019-03-09 19:40:02 -05:00
|
|
|
silica = 1,
|
2019-03-07 00:58:37 -05:00
|
|
|
optic_check = 1,
|
2019-03-07 19:26:53 -05:00
|
|
|
cracky = 3
|
2019-03-07 00:58:37 -05:00
|
|
|
},
|
|
|
|
drop = modname .. ":prism",
|
|
|
|
on_construct = nodecore.optic_check,
|
|
|
|
on_destruct = nodecore.optic_check,
|
2019-03-07 01:40:26 -05:00
|
|
|
on_spin = nodecore.optic_check,
|
2019-03-07 10:04:32 -05:00
|
|
|
optic_check = prism_check,
|
2019-03-07 00:58:37 -05:00
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "facedir",
|
2019-03-07 10:04:32 -05:00
|
|
|
on_rightclick = nodecore.node_spin_filtered(function(a, b)
|
|
|
|
return vector.equals(a.f, b.r)
|
|
|
|
and vector.equals(a.r, b.f)
|
2019-03-14 20:13:37 -04:00
|
|
|
end),
|
|
|
|
sounds = nodecore.sounds("nc_optics_glassy")
|
2019-03-07 00:58:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
local function reg(suff, def)
|
|
|
|
minetest.register_node(modname .. ":prism" .. suff,
|
|
|
|
nodecore.underride(def, basedef))
|
|
|
|
end
|
|
|
|
reg("", {})
|
2019-03-07 19:26:53 -05:00
|
|
|
reg("_on", {
|
|
|
|
description = "Active Prism",
|
|
|
|
light_source = 2
|
|
|
|
})
|