~gpcf/advtrains-devel

Fix crashing when train hitting objects without armor group v1 PROPOSED

1F616EMO: 1
 Fix crashing when train hitting objects without armor group

 1 files changed, 6 insertions(+), 3 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~gpcf/advtrains-devel/patches/55032/mbox | git am -3
Learn more about email & git

[PATCH] Fix crashing when train hitting objects without armor group Export this patch

From: 1F616EMO <root@1f616emo.xyz>

---
 advtrains/trainlogic.lua | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua
index f136577..b672991 100644
--- a/advtrains/trainlogic.lua
+++ b/advtrains/trainlogic.lua
@@ -803,9 +803,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
-- 
2.46.0