diff options
author | cheapie <no-email-for-you@example.com> | 2024-04-25 14:00:54 -0500 |
---|---|---|
committer | cheapie <no-email-for-you@example.com> | 2024-04-25 14:00:54 -0500 |
commit | c5954749b7cba8f17bb4ce551946f1537b803fc0 (patch) | |
tree | 1bb3359fa7c65cae80c7039ab29ba57324aca9d1 | |
parent | 219811a0c0f97cd1caa5208ffc78785d0dbd68f3 (diff) | |
download | celevator-c5954749b7cba8f17bb4ce551946f1537b803fc0.tar celevator-c5954749b7cba8f17bb4ce551946f1537b803fc0.tar.gz celevator-c5954749b7cba8f17bb4ce551946f1537b803fc0.tar.bz2 celevator-c5954749b7cba8f17bb4ce551946f1537b803fc0.tar.xz celevator-c5954749b7cba8f17bb4ce551946f1537b803fc0.zip |
Add door light curtain
-rw-r--r-- | car.lua | 30 | ||||
-rw-r--r-- | controllerfw.lua | 8 | ||||
-rw-r--r-- | doors.lua | 4 |
3 files changed, 42 insertions, 0 deletions
@@ -73,6 +73,36 @@ local pieces = { "celevator_car_wallpaper.png^celevator_car_wall_bottom.png^celevator_car_switch_panel.png", "celevator_cabinet_sides.png", }, + on_timer = function(pos) + local carid = minetest.get_meta(pos):get_int("carid") + local carinfo = minetest.deserialize(celevator.storage:get_string(string.format("car%d",carid))) + if not (carinfo and carinfo.controllerpos) then return end + local yaw = minetest.dir_to_yaw(minetest.fourdir_to_dir(minetest.get_node(pos).param2)) + local positions = { + vector.new(-0.25,-0.1,-0.5), + vector.new(0.25,-0.1,-0.5), + vector.new(0.75,-0.1,-0.5), + vector.new(1.25,-0.1,-0.5), + } + local playerseen = false + for _,searchpos in ipairs(positions) do + local rotatedpos = vector.rotate_around_axis(searchpos,vector.new(0,1,0),yaw) + local erefs = minetest.get_objects_inside_radius(vector.add(pos,rotatedpos),0.5) + for _,ref in pairs(erefs) do + if ref:is_player() then + playerseen = true + break + end + end + if playerseen then break end + end + if playerseen then + celevator.controller.run(carinfo.controllerpos,{ + type = "lightcurtain", + }) + end + return true + end, }, { _position = "001", diff --git a/controllerfw.lua b/controllerfw.lua index 9f12981..dedb182 100644 --- a/controllerfw.lua +++ b/controllerfw.lua @@ -675,6 +675,14 @@ elseif event.type == "remotemsg" then elseif event.channel == "carcall" and mem.carstate == "normal" then mem.carcalls[event.msg] = true end +elseif event.type == "lightcurtain" then + if mem.carstate == "normal" or mem.carstate == "indep" then + if mem.doorstate == "closing" then + open() + elseif mem.doorstate == "open" and mem.carstate == "normal" then + interrupt(mem.params.doortimer,"close") + end + end end local oldstate = mem.carstate @@ -430,6 +430,8 @@ function celevator.doors.carstep(dtime) end celevator.get_meta(data.positions[1]):set_string("doorstate","closed") cardoors_moving[hash] = nil + local cartimer = minetest.get_node_timer(data.positions[1]) + cartimer:stop() end end else @@ -490,6 +492,8 @@ end function celevator.doors.caropen(pos) local cardoors_moving = minetest.deserialize(celevator.storage:get_string("cardoors_moving")) or {} local hash = minetest.hash_node_position(pos) + local cartimer = minetest.get_node_timer(pos) + cartimer:start(0.25) if not cardoors_moving[hash] then local fdir = minetest.fourdir_to_dir(celevator.get_node(pos).param2) local otherpanel = vector.add(pos,vector.rotate_around_axis(fdir,vector.new(0,1,0),-math.pi/2)) |