summaryrefslogtreecommitdiff
path: root/decorations.lua
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2024-05-08 18:38:18 -0500
committercheapie <no-email-for-you@example.com>2024-05-08 18:38:18 -0500
commit79aae966416d5a5322d1bd74113382d16e997c54 (patch)
treeb44f5b5655a88ad9405502e3c5d605d03a0e0728 /decorations.lua
parent9fc3105444643f48b727d86843b235e7237d7f62 (diff)
downloadcelevator-79aae966416d5a5322d1bd74113382d16e997c54.tar
celevator-79aae966416d5a5322d1bd74113382d16e997c54.tar.gz
celevator-79aae966416d5a5322d1bd74113382d16e997c54.tar.bz2
celevator-79aae966416d5a5322d1bd74113382d16e997c54.tar.xz
celevator-79aae966416d5a5322d1bd74113382d16e997c54.zip
Add decorative tapehead
Spawns on top of the car in the corner opposite the PI if tape is present there, reads magnets on tape to control its LEDs but does not otherwise actually affect operation.
Diffstat (limited to 'decorations.lua')
-rw-r--r--decorations.lua227
1 files changed, 227 insertions, 0 deletions
diff --git a/decorations.lua b/decorations.lua
index 0728ba2..847c06a 100644
--- a/decorations.lua
+++ b/decorations.lua
@@ -245,3 +245,230 @@ minetest.register_node("celevator:tape_bracket",{
},
},
})
+
+minetest.register_entity("celevator:tapehead",{
+ initial_properties = {
+ visual = "wielditem",
+ visual_size = vector.new(0.667,0.667,0.667),
+ wield_item = "celevator:tapehead",
+ static_save = false,
+ pointable = false,
+ glow = minetest.LIGHT_MAX,
+ },
+ on_step = function(self)
+ local obj = self.object
+ if not obj then return end
+ local pos = obj:get_pos()
+ if not pos then return end
+ local roundpos = vector.round(pos)
+ local backdir = minetest.yaw_to_dir(obj:get_yaw())
+ local tapepos = vector.add(roundpos,backdir)
+ local tapename = minetest.get_node(tapepos).name
+ if tapename ~= "celevator:tape" and tapename ~= "celevator:tape_magnets" and tapename ~= "celevator:tape_bracket" then
+ obj:remove()
+ return
+ end
+ local ledstate = ""
+ if tapename == "celevator:tape_magnets" then
+ local offset = pos.y-roundpos.y
+ if offset > -0.45 and offset < 0.05 then
+ ledstate = ledstate.."_ulm"
+ end
+ if offset < 0.45 and offset > -0.05 then
+ ledstate = ledstate.."_dlm"
+ end
+ if offset > -0.3 and offset < 0.3 then
+ ledstate = ledstate.."_dz"
+ end
+ end
+ obj:set_properties({
+ wield_item = "celevator:tapehead"..ledstate,
+ })
+ end,
+})
+
+local function spawntapehead(pos)
+ local toppos = vector.add(pos,vector.new(0,1,0))
+ local entitiesnearby = minetest.get_objects_inside_radius(toppos,0.5)
+ for _,i in pairs(entitiesnearby) do
+ if i:get_luaentity() and i:get_luaentity().name == "celevator:tapehead" then
+ return
+ end
+ end
+ local entity = minetest.add_entity(pos,"celevator:tapehead")
+ local fdir = minetest.fourdir_to_dir(minetest.get_node(pos).param2)
+ fdir = vector.rotate_around_axis(fdir,vector.new(0,1,0),-math.pi/2)
+ entity:set_yaw(minetest.dir_to_yaw(fdir))
+ entity:set_pos(toppos)
+end
+
+minetest.register_abm({
+ label = "Spawn tapeheads",
+ nodenames = {"celevator:car_122"},
+ neighbors = {"celevator:tape","celevator:tape_magnets","celevator:tape_bracket"},
+ interval = 1,
+ chance = 1,
+ action = spawntapehead,
+})
+
+minetest.register_node("celevator:tapehead",{
+ description = "Elevator Positioning System Tapehead (off, you hacker you!)",
+ groups = {
+ not_in_creative_inventory = 1,
+ },
+ drop = "",
+ paramtype = "light",
+ paramtype2 = "4dir",
+ tiles = {
+ "celevator_tapehead_sides.png",
+ "celevator_tapehead_sides.png",
+ "celevator_tapehead_sides.png",
+ "celevator_tapehead_sides.png",
+ "celevator_tapehead_sides.png",
+ "celevator_tapehead_front_off.png",
+ },
+ drawtype = "nodebox",
+ use_texture_alpha = "clip",
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {-0.15,-0.4,0.62,0.15,0.1,0.72},
+ {-0.15,-0.4,0.42,0.15,-0.38,0.62},
+ },
+ },
+})
+
+minetest.register_node("celevator:tapehead_ulm",{
+ description = "Elevator Positioning System Tapehead (ULM on, you hacker you!)",
+ groups = {
+ not_in_creative_inventory = 1,
+ },
+ drop = "",
+ paramtype = "light",
+ paramtype2 = "4dir",
+ tiles = {
+ "celevator_tapehead_sides.png",
+ "celevator_tapehead_sides.png",
+ "celevator_tapehead_sides.png",
+ "celevator_tapehead_sides.png",
+ "celevator_tapehead_sides.png",
+ "celevator_tapehead_front_ulm.png",
+ },
+ drawtype = "nodebox",
+ use_texture_alpha = "clip",
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {-0.15,-0.4,0.62,0.15,0.1,0.72},
+ {-0.15,-0.4,0.42,0.15,-0.38,0.62},
+ },
+ },
+})
+
+minetest.register_node("celevator:tapehead_ulm_dz",{
+ description = "Elevator Positioning System Tapehead (ULM and DZ on, you hacker you!)",
+ groups = {
+ not_in_creative_inventory = 1,
+ },
+ drop = "",
+ paramtype = "light",
+ paramtype2 = "4dir",
+ tiles = {
+ "celevator_tapehead_sides.png",
+ "celevator_tapehead_sides.png",
+ "celevator_tapehead_sides.png",
+ "celevator_tapehead_sides.png",
+ "celevator_tapehead_sides.png",
+ "celevator_tapehead_front_ulm_dz.png",
+ },
+ drawtype = "nodebox",
+ use_texture_alpha = "clip",
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {-0.15,-0.4,0.62,0.15,0.1,0.72},
+ {-0.15,-0.4,0.42,0.15,-0.38,0.62},
+ },
+ },
+})
+
+minetest.register_node("celevator:tapehead_ulm_dlm_dz",{
+ description = "Elevator Positioning System Tapehead (ULM, DLM, and DZ on, you hacker you!)",
+ groups = {
+ not_in_creative_inventory = 1,
+ },
+ drop = "",
+ paramtype = "light",
+ paramtype2 = "4dir",
+ tiles = {
+ "celevator_tapehead_sides.png",
+ "celevator_tapehead_sides.png",
+ "celevator_tapehead_sides.png",
+ "celevator_tapehead_sides.png",
+ "celevator_tapehead_sides.png",
+ "celevator_tapehead_front_ulm_dlm_dz.png",
+ },
+ drawtype = "nodebox",
+ use_texture_alpha = "clip",
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {-0.15,-0.4,0.62,0.15,0.1,0.72},
+ {-0.15,-0.4,0.42,0.15,-0.38,0.62},
+ },
+ },
+})
+
+minetest.register_node("celevator:tapehead_dlm_dz",{
+ description = "Elevator Positioning System Tapehead (DLM and DZ on, you hacker you!)",
+ groups = {
+ not_in_creative_inventory = 1,
+ },
+ drop = "",
+ paramtype = "light",
+ paramtype2 = "4dir",
+ tiles = {
+ "celevator_tapehead_sides.png",
+ "celevator_tapehead_sides.png",
+ "celevator_tapehead_sides.png",
+ "celevator_tapehead_sides.png",
+ "celevator_tapehead_sides.png",
+ "celevator_tapehead_front_dlm_dz.png",
+ },
+ drawtype = "nodebox",
+ use_texture_alpha = "clip",
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {-0.15,-0.4,0.62,0.15,0.1,0.72},
+ {-0.15,-0.4,0.42,0.15,-0.38,0.62},
+ },
+ },
+})
+
+minetest.register_node("celevator:tapehead_dlm",{
+ description = "Elevator Positioning System Tapehead (DLM on, you hacker you!)",
+ groups = {
+ not_in_creative_inventory = 1,
+ },
+ drop = "",
+ paramtype = "light",
+ paramtype2 = "4dir",
+ tiles = {
+ "celevator_tapehead_sides.png",
+ "celevator_tapehead_sides.png",
+ "celevator_tapehead_sides.png",
+ "celevator_tapehead_sides.png",
+ "celevator_tapehead_sides.png",
+ "celevator_tapehead_front_dlm.png",
+ },
+ drawtype = "nodebox",
+ use_texture_alpha = "clip",
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {-0.15,-0.4,0.62,0.15,0.1,0.72},
+ {-0.15,-0.4,0.42,0.15,-0.38,0.62},
+ },
+ },
+})