summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2024-04-27 12:56:41 -0500
committercheapie <no-email-for-you@example.com>2024-04-27 12:56:41 -0500
commit215af4ca8c3b2bc61cc282178e200e5774066c05 (patch)
tree561b7d9448760699e9db825e11688d08489fe697
parentd376cbf90e59105955e6d02cc62f32ba4ae33cff (diff)
downloadcelevator-215af4ca8c3b2bc61cc282178e200e5774066c05.tar
celevator-215af4ca8c3b2bc61cc282178e200e5774066c05.tar.gz
celevator-215af4ca8c3b2bc61cc282178e200e5774066c05.tar.bz2
celevator-215af4ca8c3b2bc61cc282178e200e5774066c05.tar.xz
celevator-215af4ca8c3b2bc61cc282178e200e5774066c05.zip
Prevent pairing a machine to a car that already has one
-rw-r--r--drive_entity.lua7
1 files changed, 7 insertions, 0 deletions
diff --git a/drive_entity.lua b/drive_entity.lua
index 3c3f555..5a2eed8 100644
--- a/drive_entity.lua
+++ b/drive_entity.lua
@@ -836,6 +836,13 @@ minetest.register_node("celevator:machine",{
local carid = tonumber(fields.carid)
local carinfo = minetest.deserialize(celevator.storage:get_string(string.format("car%d",carid)))
if not carinfo then return end
+ local oldmachinepos = carinfo.machinepos
+ if oldmachinepos then
+ local oldmachine = celevator.get_node(oldmachinepos)
+ if oldmachine.name == "celevator:machine" then
+ return
+ end
+ end
carinfo.machinepos = pos
celevator.storage:set_string(string.format("car%d",carid),minetest.serialize(carinfo))
local meta = minetest.get_meta(pos)