summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2024-04-21 13:21:48 -0500
committercheapie <no-email-for-you@example.com>2024-04-21 13:21:48 -0500
commit881611953862e8b5a0489ea8c31d03ace364d68e (patch)
tree088d464d713dfe4c414a0c7b428e929149b86f92
parent2020bfb967ed94439261a60ddaeda0b9c13f2adf (diff)
downloadcelevator-881611953862e8b5a0489ea8c31d03ace364d68e.tar
celevator-881611953862e8b5a0489ea8c31d03ace364d68e.tar.gz
celevator-881611953862e8b5a0489ea8c31d03ace364d68e.tar.bz2
celevator-881611953862e8b5a0489ea8c31d03ace364d68e.tar.xz
celevator-881611953862e8b5a0489ea8c31d03ace364d68e.zip
Include current door state in ETA calculation
This accounts for the time the doors take to open and close
-rw-r--r--dispatcherfw.lua9
1 files changed, 8 insertions, 1 deletions
diff --git a/dispatcherfw.lua b/dispatcherfw.lua
index fcee154..083d755 100644
--- a/dispatcherfw.lua
+++ b/dispatcherfw.lua
@@ -251,7 +251,14 @@ end
local function calculateeta(carid,floor,direction)
local sequence = buildstopsequence(carid,getpos(carid),mem.carstatus[carid].direction,floor,direction)
- local eta = 0
+ local doorstate = mem.carstatus[carid].doorstate
+ local doortimes = {
+ closed = 0,
+ closing = 3,
+ open = 10,
+ opening = 13,
+ }
+ local eta = doortimes[doorstate] or 0
for k,v in ipairs(sequence) do
eta = eta+estimatetraveltime(carid,v.src,v.dest)
if k < #sequence then