diff options
author | 1F616EMO <root@1f616emo.xyz> | 2024-09-14 07:36:45 +0800 |
---|---|---|
committer | orwell <orwell@bleipb.de> | 2024-11-09 22:06:38 +0100 |
commit | 86e80e4cfb0d7017ff962e40ab99a4ab6addf8f2 (patch) | |
tree | c35078278efef987873fba25dc585cf4de6a6c72 /advtrains | |
parent | 671cb16e9599f9989cf5b12f76f1eb0a21252172 (diff) | |
download | advtrains-86e80e4cfb0d7017ff962e40ab99a4ab6addf8f2.tar.gz advtrains-86e80e4cfb0d7017ff962e40ab99a4ab6addf8f2.tar.bz2 advtrains-86e80e4cfb0d7017ff962e40ab99a4ab6addf8f2.zip |
Fix crashing when train hitting objects without armor group
Diffstat (limited to 'advtrains')
-rw-r--r-- | advtrains/trainlogic.lua | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua index ce646da..796aae9 100644 --- a/advtrains/trainlogic.lua +++ b/advtrains/trainlogic.lua @@ -796,9 +796,12 @@ function advtrains.train_step_c(id, train, dtime) if is_loaded_area then local objs = minetest.get_objects_inside_radius(rcollpos, 2) for _,obj in ipairs(objs) do - if not obj:is_player() and obj:get_armor_groups().fleshy and obj:get_armor_groups().fleshy > 0 - and obj:get_luaentity() and obj:get_luaentity().name~="signs_lib:text" then - obj:punch(obj, 1, { full_punch_interval = 1.0, damage_groups = {fleshy = 1000}, }, nil) + if not obj:is_player() then + local armor = obj:get_armor_groups() + local luaentity = obj:get_luaentity() + if armor.fleshy and armor.fleshy > 0 and luaentity and luaentity.name ~= "signs_lib:text" then + obj:punch(obj, 1, { full_punch_interval = 1.0, damage_groups = {fleshy = 1000}, }, nil) + end end end end |