diff options
Diffstat (limited to 'advtrains')
-rw-r--r-- | advtrains/wagons.lua | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/advtrains/wagons.lua b/advtrains/wagons.lua index 02e0709..c307d92 100644 --- a/advtrains/wagons.lua +++ b/advtrains/wagons.lua @@ -1351,12 +1351,14 @@ function advtrains.register_wagon(sysname_p, prototype, desc, inv_img, nincreati sysname = "advtrains:"..sysname_p end ch_core.upgrade_entity_properties(prototype, {keep_fields = false, base_properties = wagon_base_initial_properties}) - if prototype.initial_properties ~= nil and prototype.initial_properties.collisionbox ~= nil and prototype.initial_properties.selectionbox == nil then - local new_selection_box = table.copy(prototype.initial_properties.collisionbox) - if new_selection_box.rotate == nil then - new_selection_box.rotate = true + if prototype.initial_properties ~= nil then + local ip = prototype.initial_properties + if ip.selectionbox == nil or ip.selectionbox.rotate == nil then + assert(prototype.wagon_span ~= nil) + assert(type(prototype.wagon_span) == "number") + local wagon_span = prototype.wagon_span + ip.selectionbox = {-0.9, 0, -wagon_span + 0.25, 0.9, 2.25, wagon_span - 0.25, rotate = true} end - prototype.initial_properties.selectionbox = new_selection_box end setmetatable(prototype, {__index=wagon}) minetest.register_entity(":"..sysname,prototype) |