From 818cbb2f485573d7345d497adfea68dc7e790c86 Mon Sep 17 00:00:00 2001 From: kabou Date: Wed, 9 Mar 2022 12:11:59 +0100 Subject: [PATCH] Add check for unknown nodes. * Check if node has a definition table before attempting to evaluate its attributes. * Define local variable to cache multiple accesses to `registered_nodes[]` and improve readability. --- mods/ENTITIES/mcl_minecarts/init.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mods/ENTITIES/mcl_minecarts/init.lua b/mods/ENTITIES/mcl_minecarts/init.lua index 119a135230..d894f97226 100644 --- a/mods/ENTITIES/mcl_minecarts/init.lua +++ b/mods/ENTITIES/mcl_minecarts/init.lua @@ -432,7 +432,8 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick, o -- Slow down or speed up local acc = dir.y * -1.8 local friction = 0.4 - local speed_mod = minetest.registered_nodes[minetest.get_node(pos).name]._rail_acceleration + local ndef = minetest.registered_nodes[minetest.get_node(pos).name] + local speed_mod = ndef and ndef._rail_acceleration acc = acc - friction @@ -860,4 +861,4 @@ if has_mcl_wip then mcl_wip.register_wip_item("mcl_minecarts:furnace_minecart") mcl_wip.register_wip_item("mcl_minecarts:command_block_minecart") mcl_wip.register_wip_item("mcl_minecarts:hopper_minecart") -end \ No newline at end of file +end