|
|
|
@ -4,6 +4,11 @@ local ipairs |
|
|
|
|
local minetest, vector |
|
|
|
|
= minetest, vector |
|
|
|
|
|
|
|
|
|
local rotate = include("rotate") |
|
|
|
|
|
|
|
|
|
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 player_huds = {} |
|
|
|
|
|
|
|
|
|
local function do_player_rotating_checks(player) |
|
|
|
@ -11,6 +16,7 @@ local function do_player_rotating_checks(player) |
|
|
|
|
|
|
|
|
|
local hud_index = player_huds[name] |
|
|
|
|
if hud_index then |
|
|
|
|
-- FIXME: Only remove / update HUD elements when necessary. |
|
|
|
|
player:hud_remove(hud_index) |
|
|
|
|
player_huds[name] = nil |
|
|
|
|
end |
|
|
|
@ -27,13 +33,20 @@ local function do_player_rotating_checks(player) |
|
|
|
|
|
|
|
|
|
local node = nil |
|
|
|
|
local ray = minetest.raycast(eye_pos, eye_pos + look_dir * reach, false, false) |
|
|
|
|
for pointed_thing in ray do node = pointed_thing end |
|
|
|
|
for pointed_thing in ray do |
|
|
|
|
if pointed_thing.type == "node" then |
|
|
|
|
node = minetest.get_node(pointed_thing.under) |
|
|
|
|
break |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
if node then |
|
|
|
|
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 |
|
|
|
|
hud_index = player:hud_add({ |
|
|
|
|
hud_elem_type = "image", |
|
|
|
|
name = "rotation hint", |
|
|
|
|
text = "nc_extended_rotating_hud_rotate_clockwise.png", |
|
|
|
|
text = texture, |
|
|
|
|
position = { x = 0.5, y = 0.5 }, |
|
|
|
|
offset = { x = 0, y = 0 }, |
|
|
|
|
alignment = { x = 0, y = 0 }, |
|
|
|
|