2021-07-31 08:43:38 -04:00
|
|
|
-- LUALOCALS < ---------------------------------------------------------
|
2021-08-14 23:21:52 -04:00
|
|
|
local nodecore
|
|
|
|
= nodecore
|
2021-07-31 08:43:38 -04:00
|
|
|
-- LUALOCALS > ---------------------------------------------------------
|
|
|
|
|
2021-08-14 23:21:52 -04:00
|
|
|
local function crosshair(player, fade)
|
2021-07-31 08:43:38 -04:00
|
|
|
nodecore.hud_set(player, {
|
|
|
|
label = "crosshair",
|
|
|
|
hud_elem_type = "image",
|
|
|
|
position = {x = 0.5, y = 0.5},
|
2021-08-14 23:21:52 -04:00
|
|
|
text = "nc_player_hud_crosshair.png^[opacity:"
|
|
|
|
.. (fade and 32 or 192),
|
2021-07-31 08:43:38 -04:00
|
|
|
direction = 0,
|
|
|
|
alignment = {x = 0, y = 0},
|
|
|
|
scale = {x = 1, y = 1},
|
|
|
|
offset = {x = 0, y = 0},
|
2021-07-31 15:54:11 -04:00
|
|
|
z_index = -275,
|
2021-07-31 08:43:38 -04:00
|
|
|
quick = true
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
nodecore.register_playerstep({
|
|
|
|
label = "crosshair",
|
2021-07-31 15:54:11 -04:00
|
|
|
priority = -101,
|
|
|
|
action = function(player, data)
|
2021-08-06 21:33:23 -04:00
|
|
|
local pt = data.raycast()
|
|
|
|
if pt then
|
2021-11-27 09:24:28 -05:00
|
|
|
if pt.type == "node" and nodecore.within_map_limits(pt.under) then
|
2021-08-22 08:53:01 -04:00
|
|
|
local llu = nodecore.get_node_light(pt.under) or 0
|
|
|
|
local lla = nodecore.get_node_light(pt.above) or 0
|
|
|
|
local ll = (llu > lla) and llu or lla
|
|
|
|
return crosshair(player, ll <= 0)
|
2021-08-11 06:44:40 -04:00
|
|
|
elseif pt.type == "object" then
|
2021-08-22 08:53:01 -04:00
|
|
|
local ll = nodecore.get_node_light(pt.ref:get_pos()) or 0
|
|
|
|
return crosshair(player, ll <= 0)
|
2021-08-06 21:33:23 -04:00
|
|
|
end
|
2021-07-31 08:43:38 -04:00
|
|
|
end
|
2021-08-14 23:21:52 -04:00
|
|
|
return crosshair(player, true)
|
2021-07-31 08:43:38 -04:00
|
|
|
end
|
|
|
|
})
|