Skip to content

Commit

Permalink
Adds an option to restrict the crosshair to interior views
Browse files Browse the repository at this point in the history
  • Loading branch information
JT8D-17 committed May 8, 2024
1 parent 694d934 commit ae1ab0c
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 4 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ AUTO_ENABLE,999
ANGLE_BARS_MAX_SPD,50
# Parameter identifier, set to 1 if the angle bars are to be exclusively tied to the landing lights switch
ANGLE_BARS_ON_LAND_LIGHT,1
# Parameter identifier, set to 1 if the crosshair should be hidden in the exterior view
INTERIOR_ONLY,1
#
# All rotations in degrees, all offsets in meters
# Parameter identifier, visibility, offset x (sim/aircraft/view/acf_peX), offset y (sim/aircraft/view/acf_peZ), offset z (sim/aircraft/view/acf_peY)
Expand All @@ -108,7 +110,8 @@ Item|Description
-|-
Toggle Crosshair|Main switch to toggle the crosshair on and off.
Toggle Reference Object|Toggles the visibility of the reference object so that it can be positioned
Angle Bars On Land. Lts.|When active ties the visibility of the angle bars to the landing lights instead of a velocity range
Angle Bars On Land. Lts.|When active, ties the visibility of the angle bars to the landing lights instead of a velocity range
Interior View Only|When active, the crosshair will only be shown in interior views
Reload Settings|Will reload _settings.cfg_

 
Expand Down
8 changes: 8 additions & 0 deletions cockpit_crosshair/cockpit_crosshair.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ VARIABLES
]]
Folder_Path = "" -- Stores the path to the cockpit_crosshair folder; KEEP EMPTY!
Angle_Bars_On_LandLight = 0 -- Angle bars tied to landing light?
Interior_Only = 0 -- Hide crosshair in exterior view?
--[[
DATAREFS
Expand All @@ -37,6 +38,7 @@ simDR_pos_ias = find_dataref("sim/flightmodel/position/indicated_airspeed")
simDR_pos_head_x = find_dataref("sim/graphics/view/pilots_head_x") -- Head position lateral
simDR_pos_head_y = find_dataref("sim/graphics/view/pilots_head_y") -- Head position vertical
simDR_pos_head_z = find_dataref("sim/graphics/view/pilots_head_z") -- Head position horizontal
simDR_sound_interior = find_dataref("sim/operation/sound/inside_any") -- Used to determine if view is interior or exterior
--[[
CUSTOM DATAREFS
Expand Down Expand Up @@ -76,6 +78,12 @@ end
--[[ This stuff runs in the timer below ]]
function Run_In_Timer()
Menu_Timed() -- See core_menu.lua
-- Check if restriction is on and if view is exterior and if yes, hide crosshair
if Interior_Only == 1 and simDR_sound_interior == 0 then
Dref_Crosshair_In[0] = 0 -- Crosshair is not visible
else
Dref_Crosshair_In[0] = 1 -- Crosshair is visible
end
-- Control crosshair visbility
if Dref_Crosshair_In[0] == 1 then -- Check if crosshair visibility is desired
if simDR_pos_ias < Dref_Crosshair_AutoEnableIAS then
Expand Down
13 changes: 13 additions & 0 deletions cockpit_crosshair/core_instancing.lua
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,19 @@ function Instance_Read_Settings()
end
print("Cockpit Crosshair: ANGLE_BARS_ON_LAND_LIGHT initial value: "..Angle_Bars_On_LandLight)
end
-- INTERIOR ONLY
if splitvalues[1] == "INTERIOR_ONLY" then -- Look for this string
if #splitvalues == 2 then
if tonumber(splitvalues[2]) ~= nil then
Interior_Only = tonumber(splitvalues[2])
else
print("Cockpit Crosshair: ERROR! Value "..j.." in the INTERIOR_ONLY line of "..filename.." is not a number!")
end
else
print("Cockpit Crosshair: ERROR! Malformed INTERIOR_ONLY line in "..filename..", 2 items required!")
end
print("Cockpit Crosshair: INTERIOR_ONLY initial value: "..Interior_Only)
end
-- REFERENCE
if splitvalues[1] == "REFERENCE" then -- Look for this string
if #splitvalues == 5 then
Expand Down
13 changes: 10 additions & 3 deletions cockpit_crosshair/core_menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ local Menu_Items = {
"Toggle Crosshair", -- 2
"Toggle Reference Object", -- 3
"Angle Bars On Land. Lts.", -- 4
"[Separator]", -- 5
"Reload Settings", -- 6
"Interior View Only", -- 5
"[Separator]", -- 6
"Reload Settings", -- 7
}
--[[
Expand Down Expand Up @@ -64,7 +65,10 @@ function Menu_Callbacks(itemref)
if i == 4 then
if Angle_Bars_On_LandLight == 0 then Angle_Bars_On_LandLight = 1 else Angle_Bars_On_LandLight = 0 end
end
if i == 6 then
if i == 5 then
if Interior_Only == 0 then Interior_Only = 1 else Interior_Only = 0 end
end
if i == 7 then
Instance_Read_Settings()
end
Menu_Watchdog(Menu_Items,i)
Expand All @@ -82,6 +86,9 @@ function Menu_Watchdog(intable,index)
if index == 4 then
if Angle_Bars_On_LandLight == 1 then Menu_CheckItem(Menu_ID,index,"Activate") else Menu_CheckItem(Menu_ID,index,"Deactivate") end
end
if index == 5 then
if Interior_Only == 1 then Menu_CheckItem(Menu_ID,index,"Activate") else Menu_CheckItem(Menu_ID,index,"Deactivate") end
end
end
--[[
Expand Down
2 changes: 2 additions & 0 deletions cockpit_crosshair/settings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ AUTO_ENABLE,999
ANGLE_BARS_MAX_SPD,50
# Parameter identifier, set to 1 if the angle bars are to be exclusively tied to the landing lights switch
ANGLE_BARS_ON_LAND_LIGHT,1
# Parameter identifier, set to 1 if the crosshair should be hidden in the exterior view
INTERIOR_ONLY,1
#
# All rotations in degrees, all offsets in meters
# Parameter identifier, visibility, offset x (sim/aircraft/view/acf_peX), offset y (sim/aircraft/view/acf_peZ), offset z (sim/aircraft/view/acf_peY)
Expand Down

0 comments on commit ae1ab0c

Please sign in to comment.