From 6152a079ab1c7583da32b71c7236cd079fe2810b Mon Sep 17 00:00:00 2001 From: cheapie Date: Sun, 14 Apr 2024 15:55:08 -0500 Subject: Add floor passing beep --- controller.lua | 2 ++ controllerfw.lua | 7 +++++++ drive_entity.lua | 16 ++++++++++++++++ drive_null.lua | 4 ++++ sounds/celevator_pi_beep.ogg | Bin 0 -> 4150 bytes 5 files changed, 29 insertions(+) create mode 100644 sounds/celevator_pi_beep.ogg diff --git a/controller.lua b/controller.lua index 90fd841..0912776 100644 --- a/controller.lua +++ b/controller.lua @@ -435,6 +435,8 @@ function celevator.controller.finish(pos,mem,changedinterrupts) celevator.drives[drivetype].movedoors(drivepos,"close") elseif command.command == "resetfault" then celevator.drives[drivetype].resetfault(drivepos) + elseif command.command == "pibeep" then + celevator.drives[drivetype].pibeep(drivepos) end end end diff --git a/controllerfw.lua b/controllerfw.lua index 8e5cb2d..b909a5f 100644 --- a/controllerfw.lua +++ b/controllerfw.lua @@ -852,6 +852,8 @@ else mem.showrunning = false end +local oldpifloor = mem.pifloor + mem.pifloor = mem.params.floornames[getpos(true)] local hidepi = { bfdemand = true, @@ -863,6 +865,11 @@ local hidepi = { inspconflict = true, } if hidepi[mem.carstate] then mem.pifloor = "--" end + +if mem.pifloor ~= oldpifloor and mem.carstate == "normal" then + drivecmd({command="pibeep"}) +end + local arrowenabled = { normal = true, fs1 = true, diff --git a/drive_entity.lua b/drive_entity.lua index d5b8287..35a4e71 100644 --- a/drive_entity.lua +++ b/drive_entity.lua @@ -563,6 +563,22 @@ function celevator.drives.entity.resetfault(pos) minetest.get_meta(pos):set_string("fault","") end +function celevator.drives.entity.pibeep(drivepos) + local drivemeta = minetest.get_meta(drivepos) + local origin = minetest.string_to_pos(drivemeta:get_string("origin")) + if not origin then + minetest.log("error","[celevator] [entity drive] Invalid origin for drive at "..minetest.pos_to_string(drivepos)) + drivemeta:set_string("fault","badorigin") + return + end + local apos = tonumber(drivemeta:get_string("apos")) or 0 + local beeppos = vector.add(origin,vector.new(0,apos+2,0)) + minetest.sound_play("celevator_pi_beep",{ + pos = beeppos, + gain = 1, + },true) +end + local function carsearch(pos) for i=1,500,1 do local searchpos = vector.subtract(pos,vector.new(0,i,0)) diff --git a/drive_null.lua b/drive_null.lua index db4e394..1a98970 100644 --- a/drive_null.lua +++ b/drive_null.lua @@ -234,3 +234,7 @@ end function celevator.drives.null.updatecopformspec() --No car means no COP end + +function celevator.drives.null.pibeep() + --No car means no PI, no PI means no beep +end diff --git a/sounds/celevator_pi_beep.ogg b/sounds/celevator_pi_beep.ogg new file mode 100644 index 0000000..17c1ce4 Binary files /dev/null and b/sounds/celevator_pi_beep.ogg differ -- cgit v1.2.3