1
0
Fork 0

Merge pull request 'Refactor compass code.' (#2197) from get-compass-image-fix into master

Reviewed-on: MineClone2/MineClone2#2197
Reviewed-by: cora <cora@noreply.git.minetest.land>
Reviewed-by: chmodsayshello <chmodsayshello@hotmail.com>
This commit is contained in:
cora 2022-05-12 21:37:16 +00:00
commit 729159f631
11 changed files with 281 additions and 151 deletions

View File

@ -418,7 +418,11 @@ minetest.register_entity(":__builtin:item", {
end end
local stack = ItemStack(itemstring) local stack = ItemStack(itemstring)
if minetest.get_item_group(stack:get_name(), "compass") > 0 then if minetest.get_item_group(stack:get_name(), "compass") > 0 then
stack:set_name("mcl_compass:16") if string.find(stack:get_name(), "_lodestone") then
stack:set_name("mcl_compass:18_lodestone")
else
stack:set_name("mcl_compass:18")
end
itemstring = stack:to_string() itemstring = stack:to_string()
self.itemstring = itemstring self.itemstring = itemstring
end end

View File

@ -0,0 +1,20 @@
# mcl_compass
# Compass API
##mcl_compass.stereotype = "mcl_compass:" .. stereotype_frame
Default compass craftitem. This is also the image that is shown in the inventory.
##mcl_compass/init.lua:function mcl_compass.get_compass_itemname(pos, dir, itemstack)
Returns the itemname of a compass with needle direction matching the
current compass position.
pos: position of the compass;
dir: rotational orientation of the compass;
itemstack: the compass including its optional lodestone metadata.
##mcl_compass/init.lua:function mcl_compass.get_compass_image(pos, dir)
-- Returns partial itemname of a compass with needle direction matching compass position.
-- Legacy compatibility function for mods using older api.

View File

@ -1,16 +1,56 @@
local stereotype_frame = 18
local S = minetest.get_translator(minetest.get_current_modname()) local S = minetest.get_translator(minetest.get_current_modname())
mcl_compass = {} mcl_compass = {}
local compass_types = {
{
name = "compass",
desc = S("Compass"),
tt = S("Points to the world origin"),
longdesc = S("Compasses are tools which point to the world origin (X=0, Z=0) or the spawn point in the Overworld."),
usagehelp = S("A Compass always points to the world spawn point when the player is in the overworld. In other dimensions, it spins randomly."),
},
{
name = "compass_lodestone",
desc = S("Lodestone Compass"),
tt = S("Points to a lodestone"),
longdesc = S("Lodestone compasses resemble regular compasses, but they point to a specific lodestone."),
usagehelp = S("A Lodestone compass can be made from an ordinary compass by using it on a lodestone. After becoming a lodestone compass, it always points to its linked lodestone, provided that they are in the same dimension. If not in the same dimension, the lodestone compass spins randomly, similarly to a regular compass when outside the overworld. A lodestone compass can be relinked with another lodestone."),
}
}
-- Number of dynamic compass images (and items registered.)
local compass_frames = 32 local compass_frames = 32
-- The image/item that is craftable and shown in inventories.
local stereotype_frame = 18
-- random compass spinning tick in seconds.
-- Increase if there are performance problems.
local spin_timer_tick = 0.5
-- Local aliases to globals for better lua performance
local m_deg = math.deg
local m_atan2 = math.atan2
local m_floor = math.floor
local m_rnd = math.random
local vec_new = vector.new
local string_find = string.find
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
local compass_works = mcl_worlds.compass_works
local y_to_layer = mcl_worlds.y_to_layer
-- Initialize random compass frame for spinning compass. It is updated in
-- the compass globalstep function.
local random_frame = m_rnd(0, compass_frames-1)
local function get_far_node(pos, itemstack) --code from minetest dev wiki: https://dev.minetest.net/minetest.get_node, some edits have been made to add a cooldown for force loads local function get_far_node(pos, itemstack) --code from minetest dev wiki: https://dev.minetest.net/minetest.get_node, some edits have been made to add a cooldown for force loads
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
if node.name == "ignore" then if node.name == "ignore" then
tstamp = tonumber(itemstack:get_meta():get_string("last_forceload")) local tstamp = tonumber(itemstack:get_meta():get_string("last_forceload"))
if tstamp == nil then --this is only relevant for new lodestone compasses, the ones that have never performes a forceload yet if tstamp == nil then --this is only relevant for new lodestone compasses, the ones that have never performes a forceload yet
itemstack:get_meta():set_string("last_forceload", tostring(os.time(os.date("!*t")))) itemstack:get_meta():set_string("last_forceload", tostring(os.time(os.date("!*t"))))
tstamp = tonumber(os.time(os.date("!*t"))) tstamp = tonumber(os.time(os.date("!*t")))
@ -26,154 +66,183 @@ local function get_far_node(pos, itemstack) --code from minetest dev wiki: https
return node return node
end end
--- Get compass needle angle.
-- Returns the angle that the compass needle should point at expressed in
-- 360 degrees divided by the number of possible compass image frames..
--
-- pos: position of the compass;
-- target: position that the needle points towards;
-- dir: rotational direction of the compass.
--
local function get_compass_angle(pos, target, dir)
local angle_north = m_deg(m_atan2(target.x - pos.x, target.z - pos.z))
if angle_north < 0 then angle_north = angle_north + 360 end
local angle_dir = -m_deg(dir)
local angle_relative = (angle_north - angle_dir + 180) % 360
return m_floor((angle_relative/11.25) + 0.5) % compass_frames
end
--Not sure spawn point should be dymanic (is it in mc?) --- Get compass image frame.
--local default_spawn_settings = minetest.settings:get("static_spawnpoint") -- Returns the compass image frame with the needle direction matching the
-- compass' current position.
-- Timer for random compass spinning --
local random_timer = 0 -- pos: position of the compass;
local random_timer_trigger = 0.5 -- random compass spinning tick in seconds. Increase if there are performance problems -- dir: rotational direction of the compass.
-- itemstack: the compass including its optional lodestone metadata.
local random_frame = math.random(0, compass_frames-1) --
local function get_compass_frame(pos, dir, itemstack)
function mcl_compass.get_compass_image(pos, dir, itemstack) if not string_find(itemstack:get_name(), "_lodestone") then -- normal compass
if not itemstack then -- Compasses only work in the overworld
minetest.log("WARNING: mcl_compass.get_compass_image() was called without itemstack, returning random frame!") if compass_works(pos) then
return random_frame local spawn_pos = setting_get_pos("static_spawnpoint")
end or vec_new(0, 0, 0)
return get_compass_angle(pos, spawn_pos, dir)
local lodestone_pos = minetest.string_to_pos(itemstack:get_meta():get_string("pointsto")) else
return random_frame
if lodestone_pos then --lodestone meta present end
local _, dim = mcl_worlds.y_to_layer(lodestone_pos.y) else -- lodestone compass
local _, playerdim = mcl_worlds.y_to_layer(pos.y) local lpos_str = itemstack:get_meta():get_string("pointsto")
local lpos = string_to_pos(lpos_str)
if dim == playerdim then --Check if player and compass target are in the same dimension, above check is just if the diemension is valid for the non lodestone compass if not lpos then
minetest.log("warning", "mcl_compass: invalid lodestone position!")
if get_far_node(lodestone_pos, itemstack).name == "mcl_compass:lodestone" then --check if lodestone still exists return random_frame
local angle_north = math.deg(math.atan2(lodestone_pos.x - pos.x, lodestone_pos.z - pos.z)) end
if angle_north < 0 then angle_north = angle_north + 360 end local _, l_dim = y_to_layer(lpos.y)
local angle_dir = -math.deg(dir) local _, p_dim = y_to_layer(pos.y)
local angle_relative = (angle_north - angle_dir + 180) % 360 -- compass and lodestone must be in the same dimension
return math.floor((angle_relative/11.25) + 0.5) % compass_frames .. "_lodestone" if l_dim == p_dim then
else -- lodestone got destroyed --check if lodestone still exists
return random_frame .. "_lodestone" if get_far_node(lpos, itemstack).name == "mcl_compass:lodestone" then
end return get_compass_angle(pos, lpos, dir)
else else -- lodestone got destroyed
return random_frame .. "_lodestone" return random_frame
end end
else --no lodestone meta, normal compass....
local spawn = {x = 0, y=0, z=0} --before you guys tell me that the normal compass no points to real spawn, it always pointed to 0 0
local ssp = minetest.setting_get_pos("static_spawnpoint")
if ssp then
spawn = ssp
if type(spawn) ~= "table" or type(spawn.x) ~= "number" or type(spawn.y) ~= "number" or type(spawn.z) ~= "number" then
spawn = {x=0,y=0,z=0}
end
end
if mcl_worlds.compass_works(pos) then --is the player in the overworld?
local angle_north = math.deg(math.atan2(spawn.x - pos.x, spawn.z - pos.z))
if angle_north < 0 then angle_north = angle_north + 360 end
local angle_dir = -math.deg(dir)
local angle_relative = (angle_north - angle_dir + 180) % 360
return math.floor((angle_relative/11.25) + 0.5) % compass_frames
else else
return random_frame return random_frame
end end
end end
end end
minetest.register_globalstep(function(dtime) -- Export stereotype item for other mods to use
random_timer = random_timer + dtime mcl_compass.stereotype = "mcl_compass:" .. stereotype_frame
if random_timer >= random_timer_trigger then --- Get partial compass itemname.
random_frame = (random_frame + math.random(-1, 1)) % compass_frames -- Returns partial itemname of a compass with needle direction matching compass position.
random_timer = 0 -- Legacy compatibility function for mods using older api.
--
function mcl_compass.get_compass_image(pos, dir)
minetest.log("warning", "mcl_compass: deprecated function " ..
"get_compass_image() called, use get_compass_itemname().")
local itemstack = ItemStack(mcl_compass.stereotype)
return get_compass_frame(pos, dir, itemstack)
end
--- Get compass itemname.
-- Returns the itemname of a compass with needle direction matching the
-- current compass position.
--
-- pos: position of the compass;
-- dir: rotational orientation of the compass;
-- itemstack: the compass including its optional lodestone metadata.
--
function mcl_compass.get_compass_itemname(pos, dir, itemstack)
if not itemstack then
minetest.log("warning", "mcl_compass.get_compass_image called without itemstack!")
return "mcl_compass:" .. stereotype_frame
end end
for _,player in pairs(minetest.get_connected_players()) do local frame = get_compass_frame(pos, dir, itemstack)
local function has_compass(player) if itemstack:get_meta():get_string("pointsto") ~= "" then
for _,stack in pairs(player:get_inventory():get_list("main")) do return "mcl_compass:" .. frame .. "_lodestone"
if minetest.get_item_group(stack:get_name(), "compass") ~= 0 then else
return true return "mcl_compass:" .. frame
end end
end end
return false
end
if has_compass(player) then
local pos = player:get_pos()
for j,stack in pairs(player:get_inventory():get_list("main")) do -- Timer for randomly spinning compass.
if minetest.get_item_group(stack:get_name(), "compass") ~= 0 then -- Gets updated and checked in the globalstep function.
local compass_image = mcl_compass.get_compass_image(pos, player:get_look_horizontal(), stack) local spin_timer = 0
if minetest.get_item_group(stack:get_name(), "compass")-1 ~= compass_image and minetest.get_item_group(stack:get_name(), "compass")-1 .. "_lodestone" ~=compass_image then --Explaination: First check for normal compasses, secound check for lodestone ones
local itemname = "mcl_compass:"..compass_image -- Compass globalstep function.
--minetest.log(os.time(os.date("!*t"))) -- * updates random spin counter and random frame of spinning compasses;
stack:set_name(itemname) -- * updates all compasses in player's inventories to match the correct
player:get_inventory():set_stack("main", j, stack) -- needle orientations for their current positions.
--
minetest.register_globalstep(function(dtime)
spin_timer = spin_timer + dtime
if spin_timer >= spin_timer_tick then
random_frame = (random_frame + m_rnd(-1, 1)) % compass_frames
spin_timer = 0
end
local compass_nr, compass_frame
local pos, dir, inv
for _, player in pairs(get_connected_players()) do
pos = player:get_pos()
dir = player:get_look_horizontal()
inv = player:get_inventory()
for j, stack in pairs(inv:get_list("main")) do
compass_nr = get_item_group(stack:get_name(), "compass")
if compass_nr ~= 0 then
-- check if current compass image still matches true orientation
compass_frame = get_compass_frame(pos, dir, stack)
if compass_nr - 1 ~= compass_frame then
if string_find(stack:get_name(), "_lodestone") then
stack:set_name("mcl_compass:" .. compass_frame .. "_lodestone")
else
stack:set_name("mcl_compass:" .. compass_frame)
end end
inv:set_stack("main", j, stack)
end end
end end
end end
end end
end) end)
local images = {} --
for frame = 0, compass_frames-1 do -- Node and craftitem definitions
local s = string.format("%02d", frame) --
table.insert(images, "mcl_compass_compass_"..s..".png")
end
local doc_mod = minetest.get_modpath("doc") local doc_mod = minetest.get_modpath("doc")
for i,img in ipairs(images) do for _, item in pairs(compass_types) do
local inv = 1 local name_fmt, img_fmt
if i == stereotype_frame then if item.name == "compass" then
inv = 0 name_fmt = "mcl_compass:%d"
img_fmt = "mcl_compass_compass_%02d.png"
elseif item.name == "compass_lodestone" then
name_fmt = "mcl_compass:%d_lodestone"
img_fmt = "mcl_compass_compass_%02d.png^[colorize:purple:50"
end end
local use_doc, longdesc, tt for i = 0, compass_frames - 1 do
--Why is there no usage help? This should be fixed. local itemstring = string.format(name_fmt, i)
--local usagehelp local def = {
use_doc = i == stereotype_frame description = item.desc,
if use_doc then _tt_help = item.tt,
tt = S("Points to the world origin") inventory_image = string.format(img_fmt, i),
longdesc = S("Compasses are tools which point to the world origin (X=0, Z=0) or the spawn point in the Overworld.") wield_image = string.format(img_fmt, i),
end groups = {compass = i + 1, tool = 1, disable_repair = 1},
local itemstring = "mcl_compass:"..(i-1) }
minetest.register_craftitem(itemstring, { if i == stereotype_frame then
description = S("Compass"), def._doc_items_longdesc = item.longdesc
_tt_help = tt, def._doc_items_usagehelp = item.usagehelp
_doc_items_create_entry = use_doc, if string.match(itemstring, "lodestone") then
_doc_items_longdesc = longdesc, def.groups.not_in_creative_inventory = 1
--_doc_items_usagehelp = usagehelp, end
inventory_image = img, else
wield_image = img, def._doc_items_create_entry = false
stack_max = 64, def.groups.not_in_creative_inventory = 1
groups = {not_in_creative_inventory=inv, compass=i, tool=1, disable_repair=1 } end
}) minetest.register_craftitem(itemstring, table.copy(def))
minetest.register_craftitem(itemstring .. "_lodestone", {
description = S("Lodestone Compass"),
_tt_help = tt,
_doc_items_create_entry = use_doc,
_doc_items_longdesc = longdesc,
--_doc_items_usagehelp = usagehelp,
inventory_image = img .. "^[colorize:purple:50",
wield_image = img .. "^[colorize:purple:50",
stack_max = 64,
groups = {not_in_creative_inventory=1, compass=i, tool=1, disable_repair=1 }
})
-- Help aliases. Makes sure the lookup tool works correctly -- Help aliases. Makes sure the lookup tool works correctly
if not use_doc and doc_mod then if doc_mod and i ~= stereotype_frame then
doc.add_entry_alias("craftitems", "mcl_compass:"..(stereotype_frame-1), "craftitems", itemstring) doc.add_entry_alias("craftitems", "mcl_compass:"..(stereotype_frame), "craftitems", itemstring)
end
end end
end end
minetest.register_craft({ minetest.register_craft({
output = "mcl_compass:"..stereotype_frame, output = "mcl_compass:" .. stereotype_frame,
recipe = { recipe = {
{"", "mcl_core:iron_ingot", ""}, {"", "mcl_core:iron_ingot", ""},
{"mcl_core:iron_ingot", "mesecons:redstone", "mcl_core:iron_ingot"}, {"mcl_core:iron_ingot", "mesecons:redstone", "mcl_core:iron_ingot"},
@ -181,27 +250,19 @@ minetest.register_craft({
} }
}) })
minetest.register_craft({ minetest.register_alias("mcl_compass:compass", "mcl_compass:" .. stereotype_frame)
output = "mcl_compass:lodestone",
recipe = {
{"mcl_core:stonebrickcarved","mcl_core:stonebrickcarved","mcl_core:stonebrickcarved"},
{"mcl_core:stonebrickcarved", "mcl_core:diamondblock", "mcl_core:stonebrickcarved"},
{"mcl_core:stonebrickcarved", "mcl_core:stonebrickcarved", "mcl_core:stonebrickcarved"}
}
})
minetest.register_alias("mcl_compass:compass", "mcl_compass:"..stereotype_frame)
-- Export stereotype item for other mods to use
mcl_compass.stereotype = "mcl_compass:"..tostring(stereotype_frame)
minetest.register_node("mcl_compass:lodestone",{ minetest.register_node("mcl_compass:lodestone",{
description=S("Lodestone"), description=S("Lodestone"),
on_rightclick = function(pos, node, player, itemstack) on_rightclick = function(pos, node, player, itemstack)
if itemstack.get_name(itemstack).match(itemstack.get_name(itemstack),"mcl_compass:") then local name = itemstack.get_name(itemstack)
if itemstack.get_name(itemstack) ~= "mcl_compass:lodestone" then if string_find(name,"mcl_compass:") then
if name ~= "mcl_compass:lodestone" then
itemstack:get_meta():set_string("pointsto", minetest.pos_to_string(pos)) itemstack:get_meta():set_string("pointsto", minetest.pos_to_string(pos))
local dir = player:get_look_horizontal()
local frame = get_compass_frame(pos, dir, itemstack)
itemstack:set_name("mcl_compass:" .. frame .. "_lodestone")
end end
end end
end, end,
@ -218,3 +279,12 @@ minetest.register_node("mcl_compass:lodestone",{
_mcl_blast_resistance = 6, _mcl_blast_resistance = 6,
sounds = mcl_sounds.node_sound_stone_defaults() sounds = mcl_sounds.node_sound_stone_defaults()
}) })
minetest.register_craft({
output = "mcl_compass:lodestone",
recipe = {
{"mcl_core:stonebrickcarved","mcl_core:stonebrickcarved","mcl_core:stonebrickcarved"},
{"mcl_core:stonebrickcarved", "mcl_core:diamondblock", "mcl_core:stonebrickcarved"},
{"mcl_core:stonebrickcarved", "mcl_core:stonebrickcarved", "mcl_core:stonebrickcarved"}
}
})

View File

@ -1,4 +1,9 @@
# textdomain: mcl_compass # textdomain: mcl_compass
Compasses are tools which point to the world origin (X@=0, Z@=0) or the spawn point in the Overworld.=Kompasse sind Werkzeuge, die zum Ursprungspunkt der Welt (X@=0, Z@=0) oder zum Einstiegspunkt der Welt zeigen.
Compass=Kompass Compass=Kompass
Points to the world origin=Zeigt zum Startpunkt der Welt Points to the world origin=Zeigt zum Startpunkt der Welt
Compasses are tools which point to the world origin (X@=0, Z@=0) or the spawn point in the Overworld.=Kompasse sind Werkzeuge, die zum Ursprungspunkt der Welt (X@=0, Z@=0) oder zum Einstiegspunkt der Welt zeigen.
A Compass always points to the world spawn point when the player is in the overworld. In other dimensions, it spins randomly.=Ein Kompass zeigt immer zum Weltspawn in der Oberwelt. In sämtlichen anderen Dimensionen dreht er sich zufällig.
Lodestone Compass=Leitstein Kompass
Points to a lodestone=Zeigt zu einem Leitstein
Lodestone compasses resemble regular compasses, but they point to a specific lodestone.=Leitstein Kompasse ähneln normalen Kompassen, aber sie zeigen zu einen spezifischen Leitstein.
A Lodestone compass can be made from an ordinary compass by using it on a lodestone. After becoming a lodestone compass, it always points to its linked lodestone, provided that they are in the same dimension. If not in the same dimension, the lodestone compass spins randomly, similarly to a regular compass when outside the overworld. A lodestone compass can be relinked with another lodestone.=Ein Leitstein Kompass kann mit einem normalen Kompass erstellt werden indem man ihn auf einem Leitstein benutzt. Nachdem er ein Leitstein Kompass geworden ist, wird er immer zu seinem Leitstein zeigen, sofern sie in der selben Dimension sind. Wenn sie nicht in der selben Dimension sind, dreht sich der Leitstein Kompass zufällig, wie ein normaler Kompass außerhalb der Oberwelt. Ein Leitstein Kompass kann mit einem anderem Leitstein verknüpft werden.

View File

@ -1,3 +1,9 @@
# textdomain: mcl_compass # textdomain: mcl_compass
Compass=Brújula
Points to the world origin=
Compasses are tools which point to the world origin (X@=0, Z@=0) or the spawn point in the Overworld.=Las brújulas son herramientas que apuntan al origen del mundo (X @ = 0, Z @ = 0) o al punto de generación en el mundo. Compasses are tools which point to the world origin (X@=0, Z@=0) or the spawn point in the Overworld.=Las brújulas son herramientas que apuntan al origen del mundo (X @ = 0, Z @ = 0) o al punto de generación en el mundo.
Compass=Brújula A Compass always points to the world spawn point when the player is in the overworld. In other dimensions, it spins randomly.=
Lodestone Compass=
Points to a lodestone=
Lodestone compasses resemble regular compasses, but they point to a specific lodestone.=
A Lodestone compass can be made from an ordinary compass by using it on a lodestone. After becoming a lodestone compass, it always points to its linked lodestone, provided that they are in the same dimension. If not in the same dimension, the lodestone compass spins randomly, similarly to a regular compass when outside the overworld. A lodestone compass can be relinked with another lodestone.=

View File

@ -1,4 +1,9 @@
# textdomain: mcl_compass # textdomain: mcl_compass
Compasses are tools which point to the world origin (X@=0, Z@=0) or the spawn point in the Overworld.=Les boussoles sont des outils qui pointent vers l'origine du monde (X@=0,Z@=0) ou le point d'apparition dans l'Overworld.
Compass=Boussole Compass=Boussole
Points to the world origin=Pointe vers l'origine mondiale Points to the world origin=Pointe vers l'origine mondiale
Compasses are tools which point to the world origin (X@=0, Z@=0) or the spawn point in the Overworld.=Les boussoles sont des outils qui pointent vers l'origine du monde (X@=0,Z@=0) ou le point d'apparition dans l'Overworld.
A Compass always points to the world spawn point when the player is in the overworld. In other dimensions, it spins randomly.=
Lodestone Compass=
Points to a lodestone=
Lodestone compasses resemble regular compasses, but they point to a specific lodestone.=
A Lodestone compass can be made from an ordinary compass by using it on a lodestone. After becoming a lodestone compass, it always points to its linked lodestone, provided that they are in the same dimension. If not in the same dimension, the lodestone compass spins randomly, similarly to a regular compass when outside the overworld. A lodestone compass can be relinked with another lodestone.=

View File

@ -1,4 +1,9 @@
# textdomain: mcl_compass # textdomain: mcl_compass
Compasses are tools which point to the world origin (X@=0, Z@=0) or the spawn point in the Overworld.=Kompasy to narzędzia które wskazują na punkt początku świata (X@=0, Z@=0) lub na miejsce odrodzenia na Powierzchni.
Compass=Kompas Compass=Kompas
Points to the world origin=Wskazuje na początek świata Points to the world origin=Wskazuje na początek świata
Compasses are tools which point to the world origin (X@=0, Z@=0) or the spawn point in the Overworld.=Kompasy to narzędzia które wskazują na punkt początku świata (X@=0, Z@=0) lub na miejsce odrodzenia na Powierzchni.
A Compass always points to the world spawn point when the player is in the overworld. In other dimensions, it spins randomly.=
Lodestone Compass=
Points to a lodestone=
Lodestone compasses resemble regular compasses, but they point to a specific lodestone.=
A Lodestone compass can be made from an ordinary compass by using it on a lodestone. After becoming a lodestone compass, it always points to its linked lodestone, provided that they are in the same dimension. If not in the same dimension, the lodestone compass spins randomly, similarly to a regular compass when outside the overworld. A lodestone compass can be relinked with another lodestone.=

View File

@ -1,4 +1,9 @@
# textdomain: mcl_compass # textdomain: mcl_compass
Compasses are tools which point to the world origin (X@=0, Z@=0) or the spawn point in the Overworld.=Компас - инструмент, показывающий на начало мира (X@=0, Z@=0) или на точку возрождения в Верхнем Мире.
Compass=Компас Compass=Компас
Points to the world origin=Указывает на начало мира Points to the world origin=Указывает на начало мира
Compasses are tools which point to the world origin (X@=0, Z@=0) or the spawn point in the Overworld.=Компас - инструмент, показывающий на начало мира (X@=0, Z@=0) или на точку возрождения в Верхнем Мире.
A Compass always points to the world spawn point when the player is in the overworld. In other dimensions, it spins randomly.=
Lodestone Compass=
Points to a lodestone=
Lodestone compasses resemble regular compasses, but they point to a specific lodestone.=
A Lodestone compass can be made from an ordinary compass by using it on a lodestone. After becoming a lodestone compass, it always points to its linked lodestone, provided that they are in the same dimension. If not in the same dimension, the lodestone compass spins randomly, similarly to a regular compass when outside the overworld. A lodestone compass can be relinked with another lodestone.=

View File

@ -1,4 +1,9 @@
# textdomain: mcl_compass # textdomain: mcl_compass
Compasses are tools which point to the world origin (X@=0, Z@=0) or the spawn point in the Overworld.=指南針是指向世界原點X@=0Z@=0或主世界的出生點的工具。
Compass=指南針 Compass=指南針
Points to the world origin=指向世界原點 Points to the world origin=指向世界原點
Compasses are tools which point to the world origin (X@=0, Z@=0) or the spawn point in the Overworld.=指南針是指向世界原點X@=0Z@=0或主世界的出生點的工具。
A Compass always points to the world spawn point when the player is in the overworld. In other dimensions, it spins randomly.=
Lodestone Compass=
Points to a lodestone=
Lodestone compasses resemble regular compasses, but they point to a specific lodestone.=
A Lodestone compass can be made from an ordinary compass by using it on a lodestone. After becoming a lodestone compass, it always points to its linked lodestone, provided that they are in the same dimension. If not in the same dimension, the lodestone compass spins randomly, similarly to a regular compass when outside the overworld. A lodestone compass can be relinked with another lodestone.=

View File

@ -1,4 +1,9 @@
# textdomain: mcl_compass # textdomain: mcl_compass
Compasses are tools which point to the world origin (X@=0, Z@=0) or the spawn point in the Overworld.=
Compass= Compass=
Points to the world origin= Points to the world origin=
Compasses are tools which point to the world origin (X@=0, Z@=0) or the spawn point in the Overworld.=
A Compass always points to the world spawn point when the player is in the overworld. In other dimensions, it spins randomly.=
Lodestone Compass=
Points to a lodestone=
Lodestone compasses resemble regular compasses, but they point to a specific lodestone.=
A Lodestone compass can be made from an ordinary compass by using it on a lodestone. After becoming a lodestone compass, it always points to its linked lodestone, provided that they are in the same dimension. If not in the same dimension, the lodestone compass spins randomly, similarly to a regular compass when outside the overworld. A lodestone compass can be relinked with another lodestone.=

View File

@ -222,7 +222,7 @@ minetest.register_node("mcl_itemframes:item_frame",{
put_itemstack:set_count(1) put_itemstack:set_count(1)
local itemname = put_itemstack:get_name() local itemname = put_itemstack:get_name()
if minetest.get_item_group(itemname, "compass") > 0 then if minetest.get_item_group(itemname, "compass") > 0 then
put_itemstack:set_name("mcl_compass:" .. mcl_compass.get_compass_image(pos, minetest.dir_to_yaw(minetest.facedir_to_dir(node.param2)), put_itemstack)) put_itemstack:set_name(mcl_compass.get_compass_itemname(pos, minetest.dir_to_yaw(minetest.facedir_to_dir(node.param2)), put_itemstack))
end end
if minetest.get_item_group(itemname, "clock") > 0 then if minetest.get_item_group(itemname, "clock") > 0 then
minetest.get_node_timer(pos):start(1.0) minetest.get_node_timer(pos):start(1.0)