ToLiSS_More_Commands.lua

--[[
	ToLiSS More Commands
	v1.0.1 FrankLFRS 2024
	
	Add commands you may assign to keys
	
	New commands in FlyWithLua/ToLiSS:
		Toggle Spoilers Armed
		Toggle Wipers
		Toggle Dome Light
		Toggle PFD & ND PopUps
		Toggle E/WD & SD PopUps
		
	For ToLiSS Airbuses
--]]


-- DataRef

DataRef("ToLiSS_Speedbrake_Ratio", "sim/cockpit2/controls/speedbrake_ratio", "writable") -- -0.5 = armed, 0.0 to 1.0
DataRef("ToLiSS_Left_Wiper_Switch", "AirbusFBW/LeftWiperSwitch", "writable") -- 0 = off, 1 = slow, 2 = fast
DataRef("ToLiSS_Right_Wiper_Switch", "AirbusFBW/RightWiperSwitch", "writable") -- 0 = off, 1 = slow, 2 = fast
DataRef("ToLiSS_Dome_Light", "ckpt/oh/domeLight/anim") -- 0 = off, 1 = dim, 2 = bright
ToLiSS_PopUpStateArray = dataref_table("AirbusFBW/PopUpStateArray") -- PFD1 = [2], ND1 = [4], E/WD = [6], SD = [7]


-- Toggle wipers OFF <-> SLOW

function ToLiSS_Toggle_Wipers()
	if(ToLiSS_Left_Wiper_Switch ~= 0 or ToLiSS_Right_Wiper_Switch ~= 0) then
		ToLiSS_Left_Wiper_Switch = 0
		ToLiSS_Right_Wiper_Switch = 0
	else
		ToLiSS_Left_Wiper_Switch = 1
		ToLiSS_Right_Wiper_Switch = 1
	end
end


-- Toggle Spoilers Armed ARMED <-> RETRACTED

function ToLiSS_Toggle_Spoilers_Armed()
	if(ToLiSS_Speedbrake_Ratio == -0.5) then
		ToLiSS_Speedbrake_Ratio = 0
	else
		ToLiSS_Speedbrake_Ratio = -0.5
	end
end


-- Toggle Dome Light OFF <-> DIM

function ToLiSS_Toggle_Dome_Light()
	if(ToLiSS_Dome_Light == 0) then
		command_once("toliss_airbus/lightcommands/DomeLightUp")
	elseif(ToLiSS_Dome_Light == 1) then
		command_once("toliss_airbus/lightcommands/DomeLightDown")
	else
		command_once("toliss_airbus/lightcommands/DomeLightDown")
		command_once("toliss_airbus/lightcommands/DomeLightDown")
	end
end


-- Toggle PFD & ND as a couple of popups

function ToLiSS_Toggle_PFD_ND_PopUps()
	if(ToLiSS_PopUpStateArray[2] == 1 or ToLiSS_PopUpStateArray[4] == 1) then
		if(ToLiSS_PopUpStateArray[2] == 1) then command_once("AirbusFBW/PopUpPFD1") end
		if(ToLiSS_PopUpStateArray[4] == 1) then command_once("AirbusFBW/PopUpND1") end
	else
		if(ToLiSS_PopUpStateArray[2] == 0) then command_once("AirbusFBW/PopUpPFD1") end
		if(ToLiSS_PopUpStateArray[4] == 0) then command_once("AirbusFBW/PopUpND1") end
	end
end


-- Toggle E/WD & SD as a couple of popups

function ToLiSS_Toggle_EWD_SD_PopUps()
	if(ToLiSS_PopUpStateArray[6] == 1 or ToLiSS_PopUpStateArray[7] == 1) then
		if(ToLiSS_PopUpStateArray[6] == 1) then command_once("AirbusFBW/PopUpEWD") end
		if(ToLiSS_PopUpStateArray[7] == 1) then command_once("AirbusFBW/PopUpSD") end
	else
		if(ToLiSS_PopUpStateArray[6] == 0) then command_once("AirbusFBW/PopUpEWD") end
		if(ToLiSS_PopUpStateArray[7] == 0) then command_once("AirbusFBW/PopUpSD") end
	end
end


-- Commands

create_command("FlyWithLua/ToLiSS/Toggle_Spoilers_Armed", "Toggle Spoilers Armed", "ToLiSS_Toggle_Spoilers_Armed()", "", "")
create_command("FlyWithLua/ToLiSS/Toggle_Wipers", "Toggle Wipers", "ToLiSS_Toggle_Wipers()", "", "")
create_command("FlyWithLua/ToLiSS/Toggle_Dome_Light", "Toggle Dome Light", "ToLiSS_Toggle_Dome_Light()", "", "")
create_command("FlyWithLua/ToLiSS/Toggle_PFD_ND_PopUps", "Toggle PFD & ND PopUps", "ToLiSS_Toggle_PFD_ND_PopUps()", "", "")
create_command("FlyWithLua/ToLiSS/Toggle_EWD_SD_PopUps", "Toggle E/WD & SD PopUps", "ToLiSS_Toggle_EWD_SD_PopUps()", "", "")