mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-16 16:11:06 +01:00
Disable compass+clock updates in Nether, End, Void
This commit is contained in:
parent
c97a14e969
commit
c7fc3845c1
4 changed files with 27 additions and 17 deletions
|
@ -1,3 +1,4 @@
|
||||||
mcl_core
|
mcl_init
|
||||||
|
mcl_util
|
||||||
mesecons
|
mesecons
|
||||||
doc?
|
doc?
|
||||||
|
|
|
@ -76,11 +76,15 @@ minetest.register_globalstep(function(dtime)
|
||||||
local players = minetest.get_connected_players()
|
local players = minetest.get_connected_players()
|
||||||
for p, player in ipairs(players) do
|
for p, player in ipairs(players) do
|
||||||
for s, stack in ipairs(player:get_inventory():get_list("main")) do
|
for s, stack in ipairs(player:get_inventory():get_list("main")) do
|
||||||
local count = stack:get_count()
|
local _, dim = mcl_util.y_to_layer(player:getpos().y)
|
||||||
if stack:get_name() == mcl_clock.stereotype then
|
-- Clocks do not work in the End, Nether or the Void
|
||||||
player:get_inventory():set_stack("main", s, "mcl_clock:clock_"..now.." "..count)
|
if dim ~= "end" and dim ~= "nether" and dim ~= "void" then
|
||||||
elseif string.sub(stack:get_name(), 1, 16) == "mcl_clock:clock_" then
|
local count = stack:get_count()
|
||||||
player:get_inventory():set_stack("main", s, "mcl_clock:clock_"..now.." "..count)
|
if stack:get_name() == mcl_clock.stereotype then
|
||||||
|
player:get_inventory():set_stack("main", s, "mcl_clock:clock_"..now.." "..count)
|
||||||
|
elseif string.sub(stack:get_name(), 1, 16) == "mcl_clock:clock_" then
|
||||||
|
player:get_inventory():set_stack("main", s, "mcl_clock:clock_"..now.." "..count)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
mcl_core
|
mcl_core
|
||||||
|
mcl_util
|
||||||
mesecons
|
mesecons
|
||||||
doc?
|
doc?
|
||||||
|
|
|
@ -26,18 +26,22 @@ minetest.register_globalstep(function(dtime)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local pos = player:getpos()
|
local pos = player:getpos()
|
||||||
local dir = player:get_look_horizontal()
|
local _, dim = mcl_util.y_to_layer(pos.y)
|
||||||
local angle_north = math.deg(math.atan2(spawn.x - pos.x, spawn.z - pos.z))
|
-- Compasses do not work in the End, Nether or the Void
|
||||||
if angle_north < 0 then angle_north = angle_north + 360 end
|
if dim ~= "end" and dim ~= "nether" and dim ~= "void" then
|
||||||
local angle_dir = -math.deg(dir)
|
local dir = player:get_look_horizontal()
|
||||||
local angle_relative = (angle_north - angle_dir + 180) % 360
|
local angle_north = math.deg(math.atan2(spawn.x - pos.x, spawn.z - pos.z))
|
||||||
local compass_image = math.floor((angle_relative/11.25) + 0.5)%32
|
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
|
||||||
|
local compass_image = math.floor((angle_relative/11.25) + 0.5)%32
|
||||||
|
|
||||||
for j,stack in ipairs(player:get_inventory():get_list("main")) do
|
for j,stack in ipairs(player:get_inventory():get_list("main")) do
|
||||||
if minetest.get_item_group(stack:get_name(), "compass") ~= 0 and
|
if minetest.get_item_group(stack:get_name(), "compass") ~= 0 and
|
||||||
minetest.get_item_group(stack:get_name(), "compass")-1 ~= compass_image then
|
minetest.get_item_group(stack:get_name(), "compass")-1 ~= compass_image then
|
||||||
local count = stack:get_count()
|
local count = stack:get_count()
|
||||||
player:get_inventory():set_stack("main", j, ItemStack("mcl_compass:"..compass_image.." "..count))
|
player:get_inventory():set_stack("main", j, ItemStack("mcl_compass:"..compass_image.." "..count))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue