SUCCESS! I made it beyond the limit (stopped climbing at 18K, no hypoxia effect):
Here is my script:
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- Script: O2_on.lua
-- Version: 1.1
-- Date: 2019-01-30
-- By: LongEzDreamer
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
--[[ Notes:
developer.x-plane.com/article/the-x-plane-oxygen-system/ To equip an aircraft with a crew oxygen system, go to the second equipment tab of Plane Maker,
and enter the crew oxygen bottle capacity in liter. (Use 415)
Note that this refers to the volume of compressed oxygen in a typical 1800psi bottle.
For reference, a popular Mountain High Oxygen system in a Cirrus SR22 has a capacity of 415 liter,
and that will supply three people for about one hour and ten minutes at 18.000 feet.
www.mhoxygen.com/index.php/component/attachments/download/57 To use the oxygen system in your panel or plugin, you can then use the following datarefs:
sim/cockpit2/oxygen/actuators/o2_valve_on - this turns on the valve that allows oxygen to flow from the bottle through the pressure reducer to the ports.
sim/cockpit2/oxygen/actuators/num_plugged_in_o2 - this is how many people have masks plugged into those ports and are using them
sim/cockpit2/oxygen/actuators/demand_flow_setting - this is how the oxygen flow to the masks is regulated.
0: Off - no flow
1: Unregulated - the masks are plugged in directly, there is no pulse demand regulator. 415liters: 2h at 20k
2: N - the pulse demand regulator is in N mode 415liters: 6.5h at 20k
3: D5 - the pulse demand regulator is in D5 mode (starts delivery at 5000 feet)
4: D10 - the pulse demand regulator is in D10 mode (starts delivery at 10000 feet)
5: F1 - the pulse demand regulator is in F1 mode (small mask)
6: F2 - the pulse demand regulator is in F2 mode (small mask more O2 or medium mask)
7: F3 - the pulse demand regulator is in F3 mode (medium mask more O2 or large mask)
8: F4 - the pulse demand regulator is in F4 mode (large mask more O2)
]]--
-- -- -- -- -- -- -- -- -- -- -- -- -- -- --
dataref( "O2VALVEON", "sim/cockpit2/oxygen/actuators/o2_valve_on", "writeable")
dataref( "O2REG", "sim/cockpit2/oxygen/actuators/demand_flow_setting", "writable")
dataref( "O2USERS", "sim/cockpit2/oxygen/actuators/num_plugged_in_o2", "writable")
dataref( "O2CAP", "sim/aircraft/overflow/acf_o2_bottle_cap_liters")
function switch_o2_on()
logMsg("switch_o2_on executing")
O2VALVEON = 1
O2USERS = 1
O2REG = 7
end
function switch_o2_off()
logMsg("switch_o2_off executing")
O2VALVEON = 0
end
function print_o2_settings()
if O2VALVEON == 1 then
logMsg("O2VALVEON is 1")
else
logMsg("O2VALVEON is not 1")
end
if O2REG == 7 then
logMsg("pilot regulator set to 7")
else
logMsg("pilot regulator not set")
end
if O2CAP > 400 then
logMsg("o2 capacity is good")
else
logMsg("o2 capacity not set")
end
end
switch_o2_off()
print_o2_settings()
switch_o2_on()
print_o2_settings()