mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-12-26 09:59:33 +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
|
||||
doc?
|
||||
|
|
|
@ -76,11 +76,15 @@ minetest.register_globalstep(function(dtime)
|
|||
local players = minetest.get_connected_players()
|
||||
for p, player in ipairs(players) do
|
||||
for s, stack in ipairs(player:get_inventory():get_list("main")) do
|
||||
local count = stack:get_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)
|
||||
local _, dim = mcl_util.y_to_layer(player:getpos().y)
|
||||
-- Clocks do not work in the End, Nether or the Void
|
||||
if dim ~= "end" and dim ~= "nether" and dim ~= "void" then
|
||||
local count = stack:get_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
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
mcl_core
|
||||
mcl_util
|
||||
mesecons
|
||||
doc?
|
||||
|
|
|
@ -26,18 +26,22 @@ minetest.register_globalstep(function(dtime)
|
|||
end
|
||||
end
|
||||
local pos = player:getpos()
|
||||
local dir = player:get_look_horizontal()
|
||||
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
|
||||
local compass_image = math.floor((angle_relative/11.25) + 0.5)%32
|
||||
local _, dim = mcl_util.y_to_layer(pos.y)
|
||||
-- Compasses do not work in the End, Nether or the Void
|
||||
if dim ~= "end" and dim ~= "nether" and dim ~= "void" then
|
||||
local dir = player:get_look_horizontal()
|
||||
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
|
||||
local compass_image = math.floor((angle_relative/11.25) + 0.5)%32
|
||||
|
||||
for j,stack in ipairs(player:get_inventory():get_list("main")) do
|
||||
if minetest.get_item_group(stack:get_name(), "compass") ~= 0 and
|
||||
minetest.get_item_group(stack:get_name(), "compass")-1 ~= compass_image then
|
||||
local count = stack:get_count()
|
||||
player:get_inventory():set_stack("main", j, ItemStack("mcl_compass:"..compass_image.." "..count))
|
||||
for j,stack in ipairs(player:get_inventory():get_list("main")) do
|
||||
if minetest.get_item_group(stack:get_name(), "compass") ~= 0 and
|
||||
minetest.get_item_group(stack:get_name(), "compass")-1 ~= compass_image then
|
||||
local count = stack:get_count()
|
||||
player:get_inventory():set_stack("main", j, ItemStack("mcl_compass:"..compass_image.." "..count))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue