From 215af4ca8c3b2bc61cc282178e200e5774066c05 Mon Sep 17 00:00:00 2001 From: cheapie Date: Sat, 27 Apr 2024 12:56:41 -0500 Subject: Prevent pairing a machine to a car that already has one --- drive_entity.lua | 7 +++++++ 1 file changed, 7 insertions(+) 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) -- cgit v1.2.3