From bacc7613b55c4564c7f910e062ab510e4c51d135 Mon Sep 17 00:00:00 2001 From: kabou Date: Wed, 11 May 2022 17:41:10 +0200 Subject: [PATCH] Fix crash in mt 5.4 with vector ops. * `vector.from_string()` is not available in mt pre-5.5. Replace with `minetest.string_to_pos()`. --- mods/ITEMS/mcl_compass/init.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/mcl_compass/init.lua b/mods/ITEMS/mcl_compass/init.lua index 89231709c..00a2d43b8 100644 --- a/mods/ITEMS/mcl_compass/init.lua +++ b/mods/ITEMS/mcl_compass/init.lua @@ -35,7 +35,7 @@ local m_atan2 = math.atan2 local m_floor = math.floor local m_rnd = math.random local vec_new = vector.new -local vec_from_str = vector.from_string +local string_to_pos = minetest.string_to_pos local get_connected_players = minetest.get_connected_players local get_item_group = minetest.get_item_group local setting_get_pos = minetest.setting_get_pos @@ -101,7 +101,11 @@ local function get_compass_frame(pos, dir, itemstack) return random_frame end else -- lodestone compass - local lpos = vec_from_str(lpos_str) + local lpos = string_to_pos(lpos_str) + if not lpos then + minetest.log("warning", "mcl_compass: invalid lodestone position!") + return random_frame + end local _, l_dim = y_to_layer(lpos.y) local _, p_dim = y_to_layer(pos.y) -- compass and lodestone must be in the same dimension