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()`.
This commit is contained in:
kabou 2022-05-11 17:41:10 +02:00
parent 8a4b8707fa
commit bacc7613b5

View File

@ -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