diff options
author | cheapie <no-email-for-you@example.com> | 2024-04-20 01:04:40 -0500 |
---|---|---|
committer | cheapie <no-email-for-you@example.com> | 2024-04-20 01:04:40 -0500 |
commit | 0dd7fc056ace58af9c66e562ca612c36bbca3343 (patch) | |
tree | 64982200595516618e5e84c34c2b2d7517ef4f2c /callbuttons.lua | |
parent | e5f08e26f152bb4262d0f19bd534739472855085 (diff) | |
download | celevator-0dd7fc056ace58af9c66e562ca612c36bbca3343.tar celevator-0dd7fc056ace58af9c66e562ca612c36bbca3343.tar.gz celevator-0dd7fc056ace58af9c66e562ca612c36bbca3343.tar.bz2 celevator-0dd7fc056ace58af9c66e562ca612c36bbca3343.tar.xz celevator-0dd7fc056ace58af9c66e562ca612c36bbca3343.zip |
Add basic dispatching functionality
Diffstat (limited to 'callbuttons.lua')
-rw-r--r-- | callbuttons.lua | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/callbuttons.lua b/callbuttons.lua index 6858c10..4dfe056 100644 --- a/callbuttons.lua +++ b/callbuttons.lua @@ -185,20 +185,38 @@ for _,state in ipairs(validstates) do if carid == 0 then return end local carinfo = minetest.deserialize(celevator.storage:get_string(string.format("car%d",carid))) if not carinfo then return end - local controllerpos = carinfo.controllerpos + local controllerpos = carinfo.controllerpos or carinfo.dispatcherpos + local isdispatcher = carinfo.dispatcherpos + if not controllerpos then return end local controllermeta = minetest.get_meta(controllerpos) if controllermeta:get_int("carid") ~= carid then return end local landing = meta:get_int("landing") if state[1] == "up" then - celevator.controller.handlecallbutton(controllerpos,landing,"up") + if isdispatcher then + celevator.dispatcher.handlecallbutton(controllerpos,landing,"up") + else + celevator.controller.handlecallbutton(controllerpos,landing,"up") + end elseif state[1] == "down" then - celevator.controller.handlecallbutton(controllerpos,landing,"down") + if isdispatcher then + celevator.dispatcher.handlecallbutton(controllerpos,landing,"down") + else + celevator.controller.handlecallbutton(controllerpos,landing,"down") + end elseif state[1] == "both" then local dir = disambiguatedir(pos,clicker) if dir == "up" then - celevator.controller.handlecallbutton(controllerpos,landing,"up") + if isdispatcher then + celevator.dispatcher.handlecallbutton(controllerpos,landing,"up") + else + celevator.controller.handlecallbutton(controllerpos,landing,"up") + end elseif dir == "down" then - celevator.controller.handlecallbutton(controllerpos,landing,"down") + if isdispatcher then + celevator.dispatcher.handlecallbutton(controllerpos,landing,"down") + else + celevator.controller.handlecallbutton(controllerpos,landing,"down") + end end end end, |