Rotate optics and doors from NodeCore with ease.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.3 KiB

local ipairs
= ipairs
local minetest, nodecore
= minetest, nodecore
local rotate = include("rotate")
local LABEL_ROTATION_HINT = "rotation hint"
local TEX_ROTATE_CLOCKWISE = "nc_extended_rotating_hud_rotate_clockwise.png"
local TEX_ROTATE_COUNTER_CLOCKWISE = "nc_extended_rotating_hud_rotate_counter_clockwise.png"
local function do_player_rotating_checks(player, data)
local pt = data.raycast()
local node = pt and pt.type == "node" and minetest.get_node(pt.under)
if node and rotate.is_rotatable(node) then
local is_sneaking = player:get_player_control().sneak
local texture = is_sneaking and TEX_ROTATE_COUNTER_CLOCKWISE or TEX_ROTATE_CLOCKWISE
nodecore.hud_set(player, {
label = LABEL_ROTATION_HINT,
hud_elem_type = "image",
text = texture .. "^[opacity:" .. 192,
position = { x = 0.5, y = 0.5 },
offset = { x = 0, y = 0 },
alignment = { x = 0, y = 0 },
scale = { x = 1, y = 1 },
quick = true
})
else
nodecore.hud_set(player, {
label = LABEL_ROTATION_HINT,
ttl = 0
})
end
end
nodecore.register_playerstep({
label = "crosshair",
priority = -101,
action = do_player_rotating_checks,
})