popupMiniMap_coords = { top = 150, left = 50, width = 200, height = 128, testClick = function( self, x, y ) if( ( x > self.left) and ( x < (self.left + self.width)) and ( y < self.top) and ( y > (self.top - self.height)) )then return true else return false end end}function main()endfunction OnDraw_Windows()dr_sim_total_weight = xp.getDataref("sim/flightmodel/weight/m_total")g_total_weight = xp.getFloat(dr_sim_total_weight) * 2.20462262get_ALTG_ft = acf.getAltAgl() * 3.28 -- Aircraft altitude above ground level in meters. Then meter to Ftget_altA_ft = acf.getAltMsl() * 3.28 -- Aircraft altitude above mean-sea-level in meters. Then meter to Ftget_IAS=acf.getKIAS() -- Aircraft Indicated Air Speed in Knots.VSI = xp.getDataref("sim/cockpit2/gauges/indicators/vvi_fpm_pilot") get_VSI = xp.getFloat(VSI)get_heading = acf.getHeading()temperature = xp.getDataref("sim/weather/temperature_le_c") -- The air temperature at the leading edge of the wings in degrees C.get_temperature = xp.getFloat(temperature)N1 = xp.getDataref("sim/cockpit2/engine/indicators/N1_percent")get_N1 = xp.getFloatV(N1,1,4)N2 = xp.getDataref("sim/cockpit2/engine/indicators/N2_percent")get_N2 = xp.getFloatV(N2,1,4)fuel = xp.getDataref("sim/flightmodel/weight/m_fuel_total")get_fuel = xp.getFloat(fuel) * 2.20462262way_point_distance = xp.getDataref("sim/cockpit2/radios/indicators/gps_dme_distance_nm")get_way_point_distance = xp.getFloat(way_point_distance)local pc = popupMiniMap_coords --grab a local reference for a fraction more speed, and shorthandgfx.texOff()gfx.setColor(1,0,0,1)--draw a box, coordinates are left, top, width, heightgfx.drawBox( pc.left, pc.top-pc.height, pc.width, pc.height )gfx.setColor(0,0.1,0,0.5)gfx.drawFilledBox( pc.left, pc.top-pc.height, pc.width, pc.height )width,height = gfx.getScreenSize()gfx.setColor(1,1,1,1)gfx.drawString(string.format("IAS Knots: %0.0f",get_IAS),pc.left+10,pc.top -10 ) gfx.drawString(string.format("Heading: %0.0f",get_heading),pc.left+10,pc.top -20)gfx.drawString(string.format("Altitude Ft AGL: %0.0f",get_ALTG_ft),pc.left+10,pc.top -30 ) gfx.drawString(string.format("Altitude Ft AMSL: %0.0f",get_altA_ft),pc.left+10,pc.top -40 )gfx.drawString(string.format("Vertical Speed Ft/min: %0.0f",get_VSI),pc.left+10,pc.top -50 )gfx.drawString(string.format("Peso Total Lbs: %0.0f",g_total_weight),pc.left+10,pc.top -60)gfx.drawString(string.format("Temperature C: %0.0f",get_temperature),pc.left+10,pc.top -70)gfx.drawString(string.format("N1: %0.1f",get_N1 ),pc.left+10,pc.top -80)gfx.drawString(string.format("N2: %0.1f",get_N2),pc.left+10,pc.top -90)gfx.drawString(string.format("Fuel: %0.0f",get_fuel),pc.left+10,pc.top -100 )gfx.drawString(string.format("Way Point nm: %0.1f",get_way_point_distance),pc.left+10,pc.top -110 ) endlast_mx = -1last_my = -1drag_in_progress = falsefunction OnMouseClick() --sound.say("click: " .. mouse.click.x .. " / " .. mouse.click.y .. " / " .. mouse.click.e ) --sound.say( popupMiniMap_coords:testClick(mouse.click.x,mouse.click.y) ) --events; 1 = Down 2 = Drag 3 = Up if( popupMiniMap_coords:testClick(mouse.click.x,mouse.click.y) or drag_in_progress )then if( last_mx == -1 )then last_mx = mouse.click.x last_my = mouse.click.y end --sound.say("eat click" .. mouse.click.e) --test to see if the user is dragging if( mouse.click.e == 2 )then drag_in_progress = true --the user is mouse dragging inside our bounds. --calculate the mouse movement deltas and apply them to our origin point if( mouse.click.x ~= last_mx )then local mxd = mouse.click.x - last_mx popupMiniMap_coords.left = popupMiniMap_coords.left + mxd end if( mouse.click.y ~= last_my )then local myd = mouse.click.y - last_my popupMiniMap_coords.top = popupMiniMap_coords.top + myd end --store the last known mouse location last_mx = mouse.click.x last_my = mouse.click.y else drag_in_progress = false if( mouse.click.e == 3 )then --mouse was released, reset vars last_mx = -1 last_my = -1 end end return 1 else --sound.say("ignore click") end end
popupMiniMap_coords = { top = 150, left = 50, width = 200, height = 135, testClick = function( self, x, y ) if( ( x > self.left) and ( x < (self.left + self.width)) and ( y < self.top) and ( y > (self.top - self.height)) )then return true else return false end end}function main()endfunction OnDraw_Windows()dr_sim_total_weight = xp.getDataref("sim/flightmodel/weight/m_total")g_total_weight = xp.getFloat(dr_sim_total_weight) * 2.20462262get_ALTG_ft = acf.getAltAgl() * 3.28 -- Aircraft altitude above ground level in meters. Then meter to Ftget_altA_ft = acf.getAltMsl() * 3.28 -- Aircraft altitude above mean-sea-level in meters. Then meter to Ftget_IAS=acf.getKIAS() -- Aircraft Indicated Air Speed in Knots.VSI = xp.getDataref("sim/cockpit2/gauges/indicators/vvi_fpm_pilot") get_VSI = xp.getFloat(VSI)get_heading = acf.getHeading()temperature = xp.getDataref("sim/weather/temperature_le_c") -- The air temperature at the leading edge of the wings in degrees C.get_temperature = xp.getFloat(temperature)N1 = xp.getDataref("sim/cockpit2/engine/indicators/N1_percent")get_N1 = xp.getFloatV(N1,1,4)N2 = xp.getDataref("sim/cockpit2/engine/indicators/N2_percent")get_N2 = xp.getFloatV(N2,1,4)fuel = xp.getDataref("sim/flightmodel/weight/m_fuel_total")get_fuel = xp.getFloat(fuel) * 2.20462262way_point_distance = xp.getDataref("sim/cockpit2/radios/indicators/gps_dme_distance_nm")get_way_point_distance = xp.getFloat(way_point_distance)distance=xp.getDataref("sim/flightmodel/controls/dist")get_distance = xp.getFloat(distance) /1982 -- Meters to nmete = xp.getDataref("sim/cockpit2/radios/indicators/gps_dme_time_min")get_ete = xp.getFloat(ete) * 60 -- segundosHoras = math.modf(get_ete / 3600) segundos_restantes = get_ete - Horas * 3600Minutos = math.modf(segundos_restantes / 60) Sec = segundos_restantes - Minutos * 60 local pc = popupMiniMap_coords --grab a local reference for a fraction more speed, and shorthandgfx.texOff()gfx.setColor(1,0,0,1)--draw a box, coordinates are left, top, width, heightgfx.drawBox( pc.left, pc.top-pc.height, pc.width, pc.height )gfx.setColor(0,0.1,0,0.5)gfx.drawFilledBox( pc.left, pc.top-pc.height, pc.width, pc.height )width,height = gfx.getScreenSize()gfx.setColor(1,1,1,1)gfx.drawString(string.format("IAS Knots: %0.0f",get_IAS),pc.left+10,pc.top -10 ) gfx.drawString(string.format("Heading: %0.0f",get_heading),pc.left+10,pc.top -20)gfx.drawString(string.format("Altitude Ft AGL: %0.0f",get_ALTG_ft),pc.left+10,pc.top -30 ) gfx.drawString(string.format("Altitude Ft AMSL: %0.0f",get_altA_ft),pc.left+10,pc.top -40 )gfx.drawString(string.format("Vertical Speed Ft/min: %0.0f",get_VSI),pc.left+10,pc.top -50 )gfx.drawString(string.format("Peso Total Lbs: %0.0f",g_total_weight),pc.left+10,pc.top -60)gfx.drawString(string.format("Temperature C: %0.0f",get_temperature),pc.left+10,pc.top -70)gfx.drawString(string.format("N1: %0.1f",get_N1 ),pc.left+10,pc.top -80)gfx.drawString(string.format("N2: %0.1f",get_N2),pc.left+10,pc.top -90)gfx.drawString(string.format("Fuel: %0.0f",get_fuel),pc.left+10,pc.top -100 )gfx.drawString(string.format("Way Point nm: %0.1f",get_way_point_distance),pc.left+10,pc.top -110 )gfx.drawString(string.format("Distance travel nm: %0.1f",get_distance),pc.left+10,pc.top -120 ) gfx.drawString(string.format("ETA hh/mm/ss : %0.0f",Horas),pc.left+10,pc.top -130)gfx.drawString(string.format(": %0.0f",Minutos),pc.left+110,pc.top -130)gfx.drawString(string.format(": %0.0f",Sec),pc.left+130,pc.top -130)endlast_mx = -1last_my = -1drag_in_progress = falsefunction OnMouseClick() --sound.say("click: " .. mouse.click.x .. " / " .. mouse.click.y .. " / " .. mouse.click.e ) --sound.say( popupMiniMap_coords:testClick(mouse.click.x,mouse.click.y) ) --events; 1 = Down 2 = Drag 3 = Up if( popupMiniMap_coords:testClick(mouse.click.x,mouse.click.y) or drag_in_progress )then if( last_mx == -1 )then last_mx = mouse.click.x last_my = mouse.click.y end --sound.say("eat click" .. mouse.click.e) --test to see if the user is dragging if( mouse.click.e == 2 )then drag_in_progress = true --the user is mouse dragging inside our bounds. --calculate the mouse movement deltas and apply them to our origin point if( mouse.click.x ~= last_mx )then local mxd = mouse.click.x - last_mx popupMiniMap_coords.left = popupMiniMap_coords.left + mxd end if( mouse.click.y ~= last_my )then local myd = mouse.click.y - last_my popupMiniMap_coords.top = popupMiniMap_coords.top + myd end --store the last known mouse location last_mx = mouse.click.x last_my = mouse.click.y else drag_in_progress = false if( mouse.click.e == 3 )then --mouse was released, reset vars last_mx = -1 last_my = -1 end end return 1 else --sound.say("ignore click") end end
-- CHT limits. 250 deg C max 15 min if get(cht_1) > 250 then CHT_1_counter = CHT_1_counter + passed else CHT_1_counter = CHT_1_counter - passed end if get(cht_2) > 250 then CHT_2_counter = CHT_2_counter + passed else CHT_2_counter = CHT_2_counter - passed end if CHT_1_counter > 15 * 60 then CHT_1_counter = 30 cht_1_fail = true print("eng_1 out of CHT limit") end if CHT_2_counter > 15 * 60 then CHT_2_counter = 30 cht_2_fail = true print("eng_2 out of CHT limit") end if CHT_1_counter < 0 then CHT_1_counter = 0 cht_1_fail = false end if CHT_2_counter < 0 then CHT_2_counter = 0 cht_2_fail = false end-- Todas las fallas que queramos poner --Aqui hacemos que falle el motor-- final engine failure logic -- calculate failre if rpm_1_fail or cht_1_fail or in_oil_1_fail or out_oil_1_fail then left_eng_must_fail = true -- if at least one of parameters is fail else left_eng_must_fail = false end if rpm_2_fail or cht_2_fail or in_oil_2_fail or out_oil_2_fail then right_eng_must_fail = true -- if at least one of parameters is fail else right_eng_must_fail = false end -- set fail if it must fail or set work if all parameters are fine if left_eng_must_fail ~= left_eng_last then if left_eng_must_fail then set(left_eng_fail, 6) else set(left_eng_fail, 0) end end if right_eng_must_fail ~= right_eng_last then if right_eng_must_fail then set(right_eng_fail, 6) else set(right_eng_fail, 0) end endPor que set(right_eng_fail, 6) por que X plane tiene estos parámetros de Fallo The failure method used in X-Plane has 7 modes-1. always working [0 in lua]2. mean time until failure [1]3. exact time until failure [2]4. fail at exact speed KIAS [3]5. fail at exact altitude AGL [4]6. fail if CTRL f or JOY [5]7. inoperative [6]
-- autopilot command handler (turn left)function command_ap_left(phase) if 1 == phase then local a = get(roll_need) - 0.25 if a < -30 then a = -30 end set(roll_need, a) endreturn 0end
popupMiniMap_coords = { top = 150, left = 50, width = 200, height = 175, testClick = function( self, x, y ) if( ( x > self.left) and ( x < (self.left + self.width)) and ( y < self.top) and ( y > (self.top - self.height)) )then return true else return false end end}---- Para calcular la cantidad de combustible consumido FuelConsumido = 0Fuelinicial = xp.getDataref("sim/flightmodel/weight/m_fuel_total")get_Fuelinicial = xp.getFloat(fuelinicial) * 2.20462262------ Data ref Para el control de la aproximacion por ILS y GSEFIS_map_range_selector=xp.getDataref("sim/cockpit/switches/EFIS_map_range_selector")EFIS_shows_waypoints = xp.getDataref("sim/cockpit/switches/EFIS_shows_waypoints")EFIS_shows_VORs = xp.getDataref("sim/cockpit/switches/EFIS_shows_VORs")EFIS_shows_NDBs = xp.getDataref("sim/cockpit/switches/EFIS_shows_NDBs")-- hora = xp.getDataref("sim/cockpit2/clock_timer/local_time_hours")get_hora=xp.getInt(hora)-- Control del piloto automaticoAUTOPILOT = xp.getDataref("sim/cockpit/autopilot/autopilot_mode")ALTG= xp.getDataref("sim/flightmodel/position/y_agl") get_ALTG=xp.getFloat(ALTG)get_ALTG_ft = get_ALTG*3.28 -- Meters to Ft-- parametros del piloto automaticoaltitude_a = xp.getDataref("sim/cockpit/autopilot/altitude")get_altitude_a = xp.getFloatV(altitude_a)airspeed_a = xp.getDataref("sim/cockpit/autopilot/airspeed")get_airspeed_a = xp.getFloatV(airspeed_a )N1 = xp.getDataref("sim/cockpit2/engine/indicators/N1_percent")get_N1 = xp.getFloatV(N1,1,4)thro=xp.getDataref("sim/flightmodel/engine/ENGN_thro") get_thro=xp.getFloatV(thro,1,4) --caution here you need to give your engine count : 4 engines -> xp.getFloatV(thro,1,4)distance_wp = 0destination = 0 function OnDraw_Windows()-- Coloca los rangos de los mapas y deja visible unicamente el Aeropuertoappr=xp.getDataref("sim/cockpit2/autopilot/approach_status") -- Cero (0) No esta en aproximacion, Uno (1) Armado, Dos (2) Engagedget_appr=xp.getInt(appr)if (get_appr == 2 ) then -- Si el avion esta en LOC y GS entonces Configura el mapa quita los FIX, VOR Y NDB xp.setInt(EFIS_map_range_selector,0)xp.setInt(EFIS_shows_waypoints,0)xp.setInt(EFIS_shows_VORs,0)xp.setInt(EFIS_shows_NDBs,0)end-- hasta aqui configuracion de los mapas y opciones del mapathro=xp.getDataref("sim/flightmodel/engine/ENGN_thro") -- La Posicion del Acelerador del avion get_thro=xp.getFloatV(thro,1,4) --caution here you need to give your engine count : 4 engines -> xp.getFloatV(thro,1,4)dr_sim_total_weight = xp.getDataref("sim/flightmodel/weight/m_total") -- Peso total del Avion incluido el combustibleg_total_weight = xp.getFloat(dr_sim_total_weight) * 2.20462262get_ALTG_ft = acf.getAltAgl() * 3.28 -- Aircraft altitude above ground level in meters. Then meter to Ftget_altA_ft = acf.getAltMsl() * 3.28 -- Aircraft altitude above mean-sea-level in meters. Then meter to Ftget_IAS=acf.getKIAS() -- Aircraft Indicated Air Speed in Knots.VSI = xp.getDataref("sim/cockpit2/gauges/indicators/vvi_fpm_pilot") -- Velocidad vertical en Pies/minutoget_VSI = xp.getFloat(VSI)get_heading = acf.getHeading() -- Heading del avion temperature = xp.getDataref("sim/weather/temperature_le_c") -- The air temperature at the leading edge of the wings in degrees C.get_temperature = xp.getFloat(temperature)N1 = xp.getDataref("sim/cockpit2/engine/indicators/N1_percent") -- N1 %get_N1 = xp.getFloatV(N1,1,4)N2 = xp.getDataref("sim/cockpit2/engine/indicators/N2_percent") -- N2 %get_N2 = xp.getFloatV(N2,1,4)fuel = xp.getDataref("sim/flightmodel/weight/m_fuel_total") -- Peso total del combustible a bordoget_fuel = xp.getFloat(fuel) * 2.20462262way_point_distance = xp.getDataref("sim/cockpit2/radios/indicators/gps_dme_distance_nm") -- DIstancia que falta para llegar al proximo waypointget_way_point_distance = xp.getFloat(way_point_distance)distance=xp.getDataref("sim/flightmodel/controls/dist") -- Distancia Total recorridaget_distance = xp.getFloat(distance) /1982 -- Meters to nmete = xp.getDataref("sim/cockpit2/radios/indicators/gps_dme_time_min") -- Tiempo estimado a llegar al proximo Waypointget_ete = xp.getFloat(ete) * 60 -- segundosHoras = math.modf(get_ete / 3600) segundos_restantes = get_ete - Horas * 3600Minutos = math.modf(segundos_restantes / 60) Sec = segundos_restantes - Minutos * 60 FuelConsumido = get_Fuelinicial - get_fuel -- Calculo del Consumo de combustibleplane_actual_position = string.format("Posicion Actual %0.2f/%0.2f", acf.getLat(), acf.getLon()) --Posicion Latitud Y longitud Actual del Aviondestination = fmc.getCount() -1 -- Mira Cuantos Way points Hay en el Plan de Vuelo navaid_type, NavAid_ID_String, navaid_id, Latitude, Longitude, Altitude = fmc.getInfo(destination)--Longitude, Altitude = fmc.getInfo(destination)plane_destination_waypoint = string.format("Posicion de Destino %0.2f/%0.2f", Latitude, Longitude) --Posicion Latitud Y longitud Del destino del avion-- Arnaud Formula for distance calculationlat_a = acf.getLat()lon_a = acf.getLon()lat_b = Latitudelon_b = Longitudea = math.pi / 180lat1 = lat_a * alat2 = lat_b * alon1 = lon_a * alon2 = lon_b * at1 = math.sin(lat1) * math.sin(lat2)t2 = math.cos(lat1) * math.cos(lat2)t3 = math.cos(lon1 - lon2)t4 = t2 * t3t5 = t1 + t4rad_dist = math.atan(-t5/math.sqrt(-t5 * t5 +1)) + 2 * math.atan(1)--route_distance = rad_dist * 3437.74677 * 1.1508 * 1.6093470878864446 -- In Kilometersroute_distance = rad_dist * 3437.74677 * 1.1508 -- End of Arnaud Formuladistance_wp = trig.distanceBetweenPoints( acf.getLat(),acf.getLon(),Latitude,Longitude) * 60.1 -- Gizmo API--- Calculo del Tiempo de Vuelotiempodevuelo= xp.getDataref("sim/time/total_flight_time_sec")get_tiempodevuelo = xp.getFloat(tiempodevuelo)Horas_tv = math.modf(get_tiempodevuelo / 3600) segundos_restantes_tv = get_tiempodevuelo - Horas_tv * 3600Minutos_tv = math.modf(segundos_restantes_tv / 60)--- Para evitar fluctuaciones de datos en pantallaif (get_way_point_distance >1000) then -- X plane no permite Way point muy largos Horas = 0Minutos = 0Sec =0get_way_point_distance = 0end if (get_VSI > - 10 and get_VSI < 10) then -- Quitar fluctuaciones a Baja velocidadget_VSI = 0endif (get_IAS > -1 and get_IAS < 1) then -- Quitar fluctuaciones a Baja velocidadget_IAS = 0Horas = 0Minutos = 0Sec =0endif (destination <0 ) then distance_wp = 0 -- Ben Formularoute_distance = 0 --Arnaud Formulaendif (Latitude = 0 and Longitude = 0) then -- No way point datadistance_wp = 0 -- Ben Formularoute_distance = 0 --Arnaud Formulaend local pc = popupMiniMap_coords --grab a local reference for a fraction more speed, and shorthandgfx.texOff()gfx.setColor(1,0,0,1)--draw a box, coordinates are left, top, width, heightgfx.drawBox( pc.left, pc.top-pc.height, pc.width, pc.height )gfx.setColor(0,0.1,0,0.5)gfx.drawFilledBox( pc.left, pc.top-pc.height, pc.width, pc.height )width,height = gfx.getScreenSize()gfx.setColor(1,1,1,1)gfx.drawString(string.format("IAS Knots: %0.0f",get_IAS),pc.left+10,pc.top -10 ) gfx.drawString(string.format("Heading: %0.0f",get_heading),pc.left+120,pc.top -10)gfx.drawString(string.format("Altitude Ft AGL: %0.0f",get_ALTG_ft),pc.left+10,pc.top -20 ) gfx.drawString(string.format("Altitude Ft AMSL: %0.0f",get_altA_ft),pc.left+10,pc.top -30 )gfx.drawString(string.format("Vertical Speed Ft/min: %0.0f",get_VSI),pc.left+10,pc.top -40 )gfx.drawString(string.format("Total weight Lbs: %0.0f",g_total_weight),pc.left+10,pc.top -50)gfx.drawString(string.format("Temperature C: %0.0f",get_temperature),pc.left+10,pc.top -60)gfx.drawString(string.format("N1 : %0.1f",get_N1 ),pc.left+10,pc.top -70)gfx.drawString(string.format("N2 : %0.1f",get_N2),pc.left+80,pc.top -70)gfx.drawString(string.format("Fuel lbs: %0.0f",get_fuel),pc.left+10,pc.top -80 )gfx.drawString(string.format("Way Point nm: %0.1f",get_way_point_distance,"nm"),pc.left+10,pc.top -90 )gfx.drawString(string.format("Total fly distance nm: %0.1f",get_distance),pc.left+10,pc.top -100 ) gfx.drawString(string.format("ETA hh/mm/ss : %0.0f",Horas),pc.left+10,pc.top -110)gfx.drawString(string.format(": %0.0f",Minutos),pc.left+120,pc.top -110)gfx.drawString(string.format(": %0.0f",Sec),pc.left+140,pc.top -110)gfx.drawString(string.format("Burn fuel lbs: %0.1f",FuelConsumido),pc.left+10,pc.top -120)gfx.drawString(string.format("Tiempo de Vuelo: %0.0f ",Horas_tv),pc.left+10,pc.top -130)gfx.drawString(string.format(": %0.0f",Minutos_tv),pc.left+120,pc.top -130)gfx.drawString(plane_actual_position ,pc.left+10,pc.top -140)--gfx.drawString(string.format("Numero de Wypoints %0.0f",destination),pc.left+10,pc.top -150)gfx.drawString(plane_destination_waypoint,pc.left+10,pc.top -150)gfx.drawString(string.format("Distancia %0.2f",distance_wp),pc.left+10,pc.top -160)gfx.drawString(string.format("Distancia ARNO %0.2f",route_distance),pc.left+10,pc.top -170)endlast_mx = -1last_my = -1drag_in_progress = falsefunction OnMouseClick() --sound.say("click: " .. mouse.click.x .. " / " .. mouse.click.y .. " / " .. mouse.click.e ) --sound.say( popupMiniMap_coords:testClick(mouse.click.x,mouse.click.y) ) --events; 1 = Down 2 = Drag 3 = Up if( popupMiniMap_coords:testClick(mouse.click.x,mouse.click.y) or drag_in_progress )then if( last_mx == -1 )then last_mx = mouse.click.x last_my = mouse.click.y end --sound.say("eat click" .. mouse.click.e) --test to see if the user is dragging if( mouse.click.e == 2 )then drag_in_progress = true --the user is mouse dragging inside our bounds. --calculate the mouse movement deltas and apply them to our origin point if( mouse.click.x ~= last_mx )then local mxd = mouse.click.x - last_mx popupMiniMap_coords.left = popupMiniMap_coords.left + mxd end if( mouse.click.y ~= last_my )then local myd = mouse.click.y - last_my popupMiniMap_coords.top = popupMiniMap_coords.top + myd end --store the last known mouse location last_mx = mouse.click.x last_my = mouse.click.y else drag_in_progress = false if( mouse.click.e == 3 )then --mouse was released, reset vars last_mx = -1 last_my = -1 end end return 1 else --sound.say("ignore click") end end
--list some things you want to trigger failuresdr_sim_ITT_c = xp.getDataref("sim/flightmodel/engine/ENGN_ITT_c")--list what failure datarefs you want to faildr_sim_engine_fail1 = xp.getDataref("sim/operation/failures/rel_engfir1")function engineOverStress()--build a timer that begins when the limit is reached, but is destroyed if the limit is no longer reached before the timer goes offlocal timer_overStress = nillocal ITT = xp.getFloatV(dr_sim_ITT_c, 1, 2) --either of my engines in this case--start an argumentif ITT >600 then if (timer_overStress == nil) then timer_overStress = timer.newOneShot("failEngine", 15) --calls failEngine() in 15 seconds unless the pilot reduces ITT! endelseif ITT <600 then if (timer_overStress ~= nil) then timer.stop(timer_overStress) --stops the timer when pilot corrects his erroneous ways end endend------function failEngine()--the dirty work...xp.setInt(dr_sim_engine_fail1, 6) --thanks Jim!--[[Ok, here is what I had wrong:The failure method used in X-Plane has 7 modes-1. always working [0 in lua]2. mean time until failure [1]3. exact time until failure [2]4. fail at exact speed KIAS [3]5. fail at exact altitude AGL [4]6. fail if CTRL f or JOY [5]7. inoperative [6]]]--end
popupMiniMap_coords = { top = 150, left = 50, width = 200, height = 175, testClick = function( self, x, y ) if( ( x > self.left) and ( x < (self.left + self.width)) and ( y < self.top) and ( y > (self.top - self.height)) )then return true else return false end end}---- Para calcular la cantidad de combustible consumido FuelConsumido = 0Fuelinicial = xp.getDataref("sim/flightmodel/weight/m_fuel_total")get_Fuelinicial = xp.getFloat(fuelinicial) * 2.20462262------ Data ref Para el control de la aproximacion por ILS y GSEFIS_map_range_selector=xp.getDataref("sim/cockpit/switches/EFIS_map_range_selector")EFIS_shows_waypoints = xp.getDataref("sim/cockpit/switches/EFIS_shows_waypoints")EFIS_shows_VORs = xp.getDataref("sim/cockpit/switches/EFIS_shows_VORs")EFIS_shows_NDBs = xp.getDataref("sim/cockpit/switches/EFIS_shows_NDBs")-- hora = xp.getDataref("sim/cockpit2/clock_timer/local_time_hours")get_hora=xp.getInt(hora)-- Control del piloto automaticoAUTOPILOT = xp.getDataref("sim/cockpit/autopilot/autopilot_mode")ALTG= xp.getDataref("sim/flightmodel/position/y_agl") get_ALTG=xp.getFloat(ALTG)get_ALTG_ft = get_ALTG*3.28 -- Meters to Ft-- parametros del piloto automaticoaltitude_a = xp.getDataref("sim/cockpit/autopilot/altitude")get_altitude_a = xp.getFloatV(altitude_a)airspeed_a = xp.getDataref("sim/cockpit/autopilot/airspeed")get_airspeed_a = xp.getFloatV(airspeed_a )N1 = xp.getDataref("sim/cockpit2/engine/indicators/N1_percent")get_N1 = xp.getFloatV(N1,1,4)thro=xp.getDataref("sim/flightmodel/engine/ENGN_thro") get_thro=xp.getFloatV(thro,1,4) --caution here you need to give your engine count : 4 engines -> xp.getFloatV(thro,1,4)distance_wp = 0destination = 0 function OnDraw_Windows()-- Coloca los rangos de los mapas y deja visible unicamente el Aeropuertoappr=xp.getDataref("sim/cockpit2/autopilot/approach_status") -- Cero (0) No esta en aproximacion, Uno (1) Armado, Dos (2) Engagedget_appr=xp.getInt(appr)if (get_appr == 2 ) then -- Si el avion esta en LOC y GS entonces Configura el mapa quita los FIX, VOR Y NDB xp.setInt(EFIS_map_range_selector,0)xp.setInt(EFIS_shows_waypoints,0)xp.setInt(EFIS_shows_VORs,0)xp.setInt(EFIS_shows_NDBs,0)end-- hasta aqui configuracion de los mapas y opciones del mapathro=xp.getDataref("sim/flightmodel/engine/ENGN_thro") -- La Posicion del Acelerador del avion get_thro=xp.getFloatV(thro,1,4) --caution here you need to give your engine count : 4 engines -> xp.getFloatV(thro,1,4)dr_sim_total_weight = xp.getDataref("sim/flightmodel/weight/m_total") -- Peso total del Avion incluido el combustibleg_total_weight = xp.getFloat(dr_sim_total_weight) * 2.20462262get_ALTG_ft = acf.getAltAgl() * 3.28 -- Aircraft altitude above ground level in meters. Then meter to Ftget_altA_ft = acf.getAltMsl() * 3.28 -- Aircraft altitude above mean-sea-level in meters. Then meter to Ftget_IAS=acf.getKIAS() -- Aircraft Indicated Air Speed in Knots.VSI = xp.getDataref("sim/cockpit2/gauges/indicators/vvi_fpm_pilot") -- Velocidad vertical en Pies/minutoget_VSI = xp.getFloat(VSI)get_heading = acf.getHeading() -- Heading del avion temperature = xp.getDataref("sim/weather/temperature_le_c") -- The air temperature at the leading edge of the wings in degrees C.get_temperature = xp.getFloat(temperature)N1 = xp.getDataref("sim/cockpit2/engine/indicators/N1_percent") -- N1 %get_N1 = xp.getFloatV(N1,1,4)N2 = xp.getDataref("sim/cockpit2/engine/indicators/N2_percent") -- N2 %get_N2 = xp.getFloatV(N2,1,4)fuel = xp.getDataref("sim/flightmodel/weight/m_fuel_total") -- Peso total del combustible a bordoget_fuel = xp.getFloat(fuel) * 2.20462262way_point_distance = xp.getDataref("sim/cockpit2/radios/indicators/gps_dme_distance_nm") -- DIstancia que falta para llegar al proximo waypointget_way_point_distance = xp.getFloat(way_point_distance)distance=xp.getDataref("sim/flightmodel/controls/dist") -- Distancia Total recorridaget_distance = xp.getFloat(distance) /1982 -- Meters to nmete = xp.getDataref("sim/cockpit2/radios/indicators/gps_dme_time_min") -- Tiempo estimado a llegar al proximo Waypointget_ete = xp.getFloat(ete) * 60 -- segundosHoras = math.modf(get_ete / 3600) segundos_restantes = get_ete - Horas * 3600Minutos = math.modf(segundos_restantes / 60) Sec = segundos_restantes - Minutos * 60 FuelConsumido = get_Fuelinicial - get_fuel -- Calculo del Consumo de combustibleplane_actual_position = string.format("Posicion Actual %0.2f/%0.2f", acf.getLat(), acf.getLon()) --Posicion Latitud Y longitud Actual del Aviondestination = fmc.getCount() -1 -- Mira Cuantos Way points Hay en el Plan de Vuelo navaid_type, NavAid_ID_String, navaid_id, Latitude, Longitude, Altitude = fmc.getInfo(destination)--Longitude, Altitude = fmc.getInfo(destination)plane_destination_waypoint = string.format("Posicion de Destino %0.2f/%0.2f", Latitude, Longitude) --Posicion Latitud Y longitud Del destino del avionlat_a = acf.getLat()lon_a = acf.getLon()lat_b = Latitudelon_b = Longitudea = math.pi / 180lat1 = lat_a * alat2 = lat_b * alon1 = lon_a * alon2 = lon_b * at1 = math.sin(lat1) * math.sin(lat2)t2 = math.cos(lat1) * math.cos(lat2)t3 = math.cos(lon1 - lon2)t4 = t2 * t3t5 = t1 + t4rad_dist = math.atan(-t5/math.sqrt(-t5 * t5 +1)) + 2 * math.atan(1)--route_distance = rad_dist * 3437.74677 * 1.1508 * 1.6093470878864446 -- In Kilometersroute_distance = rad_dist * 3437.74677 * 1.1508 distance_wp = trig.distanceBetweenPoints( acf.getLat(),acf.getLon(),Latitude,Longitude) * 60.1 -- Gizmo API--- Calculo del Tiempo de Vuelotiempodevuelo= xp.getDataref("sim/time/total_flight_time_sec")get_tiempodevuelo = xp.getFloat(tiempodevuelo)Horas_tv = math.modf(get_tiempodevuelo / 3600) segundos_restantes_tv = get_tiempodevuelo - Horas_tv * 3600Minutos_tv = math.modf(segundos_restantes_tv / 60)--- Para evitar fluctuaciones de datos en pantallaif (get_way_point_distance >1000) then -- X plane no permite Way point muy largos Horas = 0Minutos = 0Sec =0get_way_point_distance = 0end if (get_VSI > - 10 and get_VSI < 10) then -- Quitar fluctuaciones a Baja velocidadget_VSI = 0endif (get_IAS > -1 and get_IAS < 1) then -- Quitar fluctuaciones a Baja velocidadget_IAS = 0Horas = 0Minutos = 0Sec =0endif (destination <0 ) then distance_wp = 0 endlocal pc = popupMiniMap_coords --grab a local reference for a fraction more speed, and shorthandgfx.texOff()gfx.setColor(1,0,0,1)--draw a box, coordinates are left, top, width, heightgfx.drawBox( pc.left, pc.top-pc.height, pc.width, pc.height )gfx.setColor(0,0.1,0,0.5)gfx.drawFilledBox( pc.left, pc.top-pc.height, pc.width, pc.height )width,height = gfx.getScreenSize()gfx.setColor(1,1,1,1)gfx.drawString(string.format("IAS Knots: %0.0f",get_IAS),pc.left+10,pc.top -10 ) gfx.drawString(string.format("Heading: %0.0f",get_heading),pc.left+120,pc.top -10)gfx.drawString(string.format("Altitude Ft AGL: %0.0f",get_ALTG_ft),pc.left+10,pc.top -20 ) gfx.drawString(string.format("Altitude Ft AMSL: %0.0f",get_altA_ft),pc.left+10,pc.top -30 )gfx.drawString(string.format("Vertical Speed Ft/min: %0.0f",get_VSI),pc.left+10,pc.top -40 )gfx.drawString(string.format("Total weight Lbs: %0.0f",g_total_weight),pc.left+10,pc.top -50)gfx.drawString(string.format("Temperature C: %0.0f",get_temperature),pc.left+10,pc.top -60)gfx.drawString(string.format("N1 : %0.1f",get_N1 ),pc.left+10,pc.top -70)gfx.drawString(string.format("N2 : %0.1f",get_N2),pc.left+80,pc.top -70)gfx.drawString(string.format("Fuel lbs: %0.0f",get_fuel),pc.left+10,pc.top -80 )gfx.drawString(string.format("Way Point nm: %0.1f",get_way_point_distance,"nm"),pc.left+10,pc.top -90 )gfx.drawString(string.format("Total fly distance nm: %0.1f",get_distance),pc.left+10,pc.top -100 ) gfx.drawString(string.format("ETA hh/mm/ss : %0.0f",Horas),pc.left+10,pc.top -110)gfx.drawString(string.format(": %0.0f",Minutos),pc.left+120,pc.top -110)gfx.drawString(string.format(": %0.0f",Sec),pc.left+140,pc.top -110)gfx.drawString(string.format("Burn fuel lbs: %0.1f",FuelConsumido),pc.left+10,pc.top -120)gfx.drawString(string.format("Tiempo de Vuelo: %0.0f ",Horas_tv),pc.left+10,pc.top -130)gfx.drawString(string.format(": %0.0f",Minutos_tv),pc.left+120,pc.top -130)gfx.drawString(plane_actual_position ,pc.left+10,pc.top -140)--gfx.drawString(string.format("Numero de Wypoints %0.0f",destination),pc.left+10,pc.top -150)gfx.drawString(plane_destination_waypoint,pc.left+10,pc.top -150)gfx.drawString(string.format("Distancia %0.2f",distance_wp),pc.left+10,pc.top -160)gfx.drawString(string.format("Distancia ARNO %0.2f",route_distance),pc.left+10,pc.top -170)endlast_mx = -1last_my = -1drag_in_progress = falsefunction OnMouseClick() --sound.say("click: " .. mouse.click.x .. " / " .. mouse.click.y .. " / " .. mouse.click.e ) --sound.say( popupMiniMap_coords:testClick(mouse.click.x,mouse.click.y) ) --events; 1 = Down 2 = Drag 3 = Up if( popupMiniMap_coords:testClick(mouse.click.x,mouse.click.y) or drag_in_progress )then if( last_mx == -1 )then last_mx = mouse.click.x last_my = mouse.click.y end --sound.say("eat click" .. mouse.click.e) --test to see if the user is dragging if( mouse.click.e == 2 )then drag_in_progress = true --the user is mouse dragging inside our bounds. --calculate the mouse movement deltas and apply them to our origin point if( mouse.click.x ~= last_mx )then local mxd = mouse.click.x - last_mx popupMiniMap_coords.left = popupMiniMap_coords.left + mxd end if( mouse.click.y ~= last_my )then local myd = mouse.click.y - last_my popupMiniMap_coords.top = popupMiniMap_coords.top + myd end --store the last known mouse location last_mx = mouse.click.x last_my = mouse.click.y else drag_in_progress = false if( mouse.click.e == 3 )then --mouse was released, reset vars last_mx = -1 last_my = -1 end end return 1 else --sound.say("ignore click") end end