aboutsummaryrefslogtreecommitdiff
path: root/advtrains/wagons.lua
diff options
context:
space:
mode:
authorSingularis <singularis@volny.cz>2025-01-18 07:24:37 +0100
committerorwell <orwell@bleipb.de>2025-05-27 20:22:01 +0200
commit4ad37ae721a9db5754ce0489dc68ad66e6fad9b6 (patch)
treefe320ade76335e7551581d88a6654617442a5678 /advtrains/wagons.lua
parent239a86b39389f03f4cee43c9b7b32d8972b0d4af (diff)
downloadadvtrains-4ad37ae721a9db5754ce0489dc68ad66e6fad9b6.tar.gz
advtrains-4ad37ae721a9db5754ce0489dc68ad66e6fad9b6.tar.bz2
advtrains-4ad37ae721a9db5754ce0489dc68ad66e6fad9b6.zip
[advtrains,...] nové optimální výběrové boxy pro všechny lokomotivy a vagony
Diffstat (limited to 'advtrains/wagons.lua')
-rw-r--r--advtrains/wagons.lua12
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)