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-08-31 09:26:53 -04:00
|
|
|
local function prism_check(_, node, check)
|
2019-03-07 00:58:37 -05:00
|
|
|
local face = nodecore.facedirs[node.param2]
|
|
|
|
|
2019-12-04 00:16:07 -05:00
|
|
|
if check(face.t) or check(face.b) then
|
|
|
|
return modname .. ":prism_gated"
|
|
|
|
end
|
|
|
|
if check(face.f) or check(face.r) 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-11-30 18:44:51 -05:00
|
|
|
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-12-04 00:16:07 -05:00
|
|
|
local shin = modname .. "_shine_end.png"
|
|
|
|
local dark = modname .. "_port_input.png"
|
2019-03-07 19:26:53 -05:00
|
|
|
|
2019-03-07 00:58:37 -05:00
|
|
|
local basedef = {
|
|
|
|
description = "Prism",
|
2019-11-30 18:04:28 -05:00
|
|
|
drawtype = "mesh",
|
|
|
|
mesh = "nc_optics_prism.obj",
|
2019-03-30 21:23:02 -04:00
|
|
|
selection_box = nodecore.fixedbox(
|
2019-12-03 23:49:08 -05:00
|
|
|
{-7/16, -7/16, -7/16, 7/16, 7/16, 7/16}
|
2019-03-30 21:23:02 -04:00
|
|
|
),
|
2019-03-07 00:58:37 -05:00
|
|
|
tiles = {
|
2019-03-07 19:26:53 -05:00
|
|
|
txr,
|
2019-11-30 18:44:51 -05:00
|
|
|
txr .. "^" .. pout,
|
|
|
|
txr .. "^" .. pinp
|
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,
|
2020-02-05 07:34:28 -05:00
|
|
|
cracky = 3,
|
2020-03-29 08:13:41 -04:00
|
|
|
silica_prism = 1,
|
|
|
|
scaling_time = 125
|
2019-03-07 00:58:37 -05:00
|
|
|
},
|
2020-05-31 09:25:03 -04:00
|
|
|
silktouch = false,
|
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",
|
2019-11-30 18:44:51 -05:00
|
|
|
tiles = {
|
2019-11-30 19:50:19 -05:00
|
|
|
txr .. "^(" .. pact .. "^[opacity:96)",
|
2019-11-30 18:44:51 -05:00
|
|
|
txr .. "^" .. pact .. "^" .. pout,
|
|
|
|
txr .. "^" .. pinp .. "^" .. pina
|
|
|
|
},
|
2019-03-07 19:26:53 -05:00
|
|
|
light_source = 2
|
|
|
|
})
|
2019-12-04 00:16:07 -05:00
|
|
|
reg("_gated", {
|
|
|
|
description = "Gated Prism",
|
|
|
|
tiles = {
|
|
|
|
txr .. "^" .. shin .. "^" .. pout,
|
|
|
|
txr .. "^" .. shin .. "^" .. dark,
|
|
|
|
txr .. "^" .. shin .. "^" .. dark
|
|
|
|
},
|
2019-12-04 19:51:39 -05:00
|
|
|
light_source = 3
|
2019-12-04 00:16:07 -05:00
|
|
|
})
|