71 lines
1.8 KiB
Lua
Raw Normal View History

-- LUALOCALS < ---------------------------------------------------------
local minetest, nodecore, vector
= minetest, nodecore, vector
-- LUALOCALS > ---------------------------------------------------------
local modname = minetest.get_current_modname()
local function prism_check(_, 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
return modname .. ":prism_on", {face.k, face.l}
end
return modname .. ":prism"
end
2019-03-07 19:26:53 -05:00
local txr = modname .. "_glass_frost.png"
local pact = modname .. "_port_active.png"
local pout = modname .. "_port_output.png"
local pinp = modname .. "_port_wide.png"
local pina = modname .. "_port_wide_act.png"
2019-03-07 19:26:53 -05:00
local basedef = {
description = "Prism",
2019-11-30 18:04:28 -05:00
drawtype = "mesh",
mesh = "nc_optics_prism.obj",
selection_box = nodecore.fixedbox(
2019-11-30 18:04:28 -05:00
{-5/16, -0.5, -0.5, 0.5, 0.5, 5/16}
),
tiles = {
2019-03-07 19:26:53 -05:00
txr,
txr .. "^" .. pout,
txr .. "^" .. pinp
},
groups = {
silica = 1,
optic_check = 1,
2019-03-07 19:26:53 -05:00
cracky = 3
},
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,
optic_check = prism_check,
paramtype = "light",
paramtype2 = "facedir",
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")
}
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",
tiles = {
2019-11-30 19:50:19 -05:00
txr .. "^(" .. pact .. "^[opacity:96)",
txr .. "^" .. pact .. "^" .. pout,
txr .. "^" .. pinp .. "^" .. pina
},
2019-03-07 19:26:53 -05:00
light_source = 2
})