Code: Select all
img_add_fullscreen("ignition_switch.png")
-- IGNITION KEY
ign_off = img_add("Off.png",67,34,325,325)
ign_left = img_add("Left.png",67,34,325,325)
ign_right = img_add("Right.png",67,34,325,325)
ign_both = img_add("Both.png",67,34,325,325)
ign_start = img_add("Prime.png",67,34,325,325)
visible(ign_off,true)
visible(ign_left,false)
visible(ign_right,false)
visible(ign_both,false)
visible(ign_start,false)
xpl_key_position="sim/cockpit2/engine/actuators/ignition_key"
xpl_key_type="INT[8]"
--
local ign_state = 0
function ignition_callback(direction)
if ign_state == 0 and direction == 1 then
xpl_dataref_write(xpl_key_position,xpl_key_type, 1)
elseif ign_state == 1 and direction == -1 then
xpl_dataref_write(xpl_key_position,xpl_key_type, 0)
elseif ign_state == 1 and direction == 1 then
xpl_dataref_write(xpl_key_position,xpl_key_type, 2)
elseif ign_state == 2 and direction == -1 then
xpl_dataref_write(xpl_key_position,xpl_key_type, 1)
elseif ign_state == 2 and direction == 1 then
xpl_dataref_write(xpl_key_position,xpl_key_type, 3)
elseif ign_state == 3 and direction == -1 then
xpl_dataref_write(xpl_key_position,xpl_key_type, 2)
elseif ign_state == 3 and direction == 1 then
xpl_dataref_write(xpl_key_position,xpl_key_type, 4)
elseif ign_state == 4 and direction == -1 then
xpl_dataref_write(xpl_key_position,xpl_key_type, 3)
end
end
ignition_sw = dial_add(nil,67,34,325,325,ignition_callback)
function new_ignition_xpl(ing_pos)
-- R44 MAGNETO POSITIONS
-- 0 = OFF
-- 1 = LEFT
-- 2 = RIGHT
-- 3 = BOTH
-- 4 = START
if ing_pos[1] == 0 then
ign_state = 0
elseif ing_pos[1] == 1 then
ign_state = 1
elseif ing_pos[1] == 2 then
ign_state = 2
elseif ing_pos[1] == 3 then
ign_state = 3
elseif ing_pos[1] == 4 then
ign_state = 4
end
visible(ign_off, ign_state == 0)
visible(ign_right, ign_state == 1)
visible(ign_left, ign_state == 2)
visible(ign_both, ign_state == 3)
visible(ign_start, ign_state == 4)
end
xpl_dataref_subscribe(xpl_key_position,xpl_key_type,new_ignition_xpl)