G60 G60
Páginas: [1]   Ir Abajo
  Imprimir  
Autor Tema: Mi primer SCRIPT  (Leído 12208 veces)
0 Usuarios y 1 Visitante están viendo este tema.
09 Junio, 2011, 01:21:29
CarlosGarcia
Usuario Frecuente
*****
Desconectado Desconectado

Mensajes: 663



En línea
Mi primer SCRIPT

Bueno quiero compartir mi primer Script completo en GIZMO, que hace ??   ...

Te muestra en pantalla datos que a veces son dificil de ver  Huh? en los instrumentos y otros como el peso del avion que no estan disponibles en los instrumentos de X Plane...

Muestra : IAS, Altura AGL, Altura MSL, velocidad vertical, Temperatura externa en las alas del avion, N1, N2, Peso del Avion total, Cantidad de Combustible, Distancia en Nm al proximo Way point del GPS y el Rumbo.

Este script usa una parte del codigo del mini mapa de Ben Rusell en cuanto a la facilidad de mover la ventana a cualquier parte de la pantalla.

Pueden ver unas fotos aqui forums.x-plane.org/index.php?showtopic=23517&view=findpost&p=581051


Código:
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()
end

function OnDraw_Windows()
dr_sim_total_weight = xp.getDataref("sim/flightmodel/weight/m_total")
g_total_weight =  xp.getFloat(dr_sim_total_weight)  * 2.20462262

get_ALTG_ft = acf.getAltAgl() * 3.28 --  Aircraft altitude above ground level in meters. Then meter to Ft

get_altA_ft = acf.getAltMsl() * 3.28 -- Aircraft altitude above mean-sea-level in meters. Then meter to Ft

get_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.20462262

way_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 shorthand
gfx.texOff()
gfx.setColor(1,0,0,1)
--draw a box, coordinates are left, top, width, height
gfx.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 )

end

last_mx = -1
last_my = -1

drag_in_progress = false

function 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

Para los que les interesa GIZMO esta es la pagina y los datos

Esta es la pagina .
http://www.x-plugins.com/home
y este es el foro.
http://forums.x-pilot.com/index.php?board=108.0
Y este es el SDK
https://github.com/benrussell/Gizmo-SDK

A ver España a DESARROLLAR Scripts .....  Cheesy
« Última modificación: 24 Junio, 2011, 04:14:25 por suministros »

09 Junio, 2011, 17:56:30 #1
cescll
Usuario Ocasional
***
Desconectado Desconectado

Mensajes: 44



En línea
Re: Mi primer SCRIPT

Enhorabuena. Instalaré Gizmo y lo probaré junto al del 'control remoto'.

Saludos

24 Junio, 2011, 04:17:13 #2
CarlosGarcia
Usuario Frecuente
*****
Desconectado Desconectado

Mensajes: 663



En línea
Re: Mi primer SCRIPT

Bueno le agregue Espacio en Nm que el avion ha recorrido en el vuelo actual y el tiempo en Horas / minutos / segundos en alcanzar el proximo Waypoint programado en el FMS.

Código:
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()
end

function OnDraw_Windows()
dr_sim_total_weight = xp.getDataref("sim/flightmodel/weight/m_total")
g_total_weight =  xp.getFloat(dr_sim_total_weight)  * 2.20462262

get_ALTG_ft = acf.getAltAgl() * 3.28 --  Aircraft altitude above ground level in meters. Then meter to Ft

get_altA_ft = acf.getAltMsl() * 3.28 -- Aircraft altitude above mean-sea-level in meters. Then meter to Ft

get_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.20462262

way_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 nm

ete = xp.getDataref("sim/cockpit2/radios/indicators/gps_dme_time_min")
get_ete = xp.getFloat(ete) * 60 -- segundos

Horas = math.modf(get_ete / 3600)
segundos_restantes = get_ete - Horas * 3600
Minutos =  math.modf(segundos_restantes / 60)
Sec =  segundos_restantes - Minutos * 60

local pc = popupMiniMap_coords --grab a local reference for a fraction more speed, and shorthand
gfx.texOff()
gfx.setColor(1,0,0,1)
--draw a box, coordinates are left, top, width, height
gfx.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)
end
last_mx = -1
last_my = -1

drag_in_progress = false

function 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



Fotos de Como se ve en pantalla : http://forums.x-plane.org/index.php?showtopic=23517&view=findpost&p=583867
« Última modificación: 24 Junio, 2011, 14:34:34 por suministros »

25 Junio, 2011, 00:19:40 #3
CarlosGarcia
Usuario Frecuente
*****
Desconectado Desconectado

Mensajes: 663



En línea
Re: Mi primer SCRIPT

Bueno, yo mismo me voy a actualizar el POST  Avergonzado

El próximo paso de mi Script es hacer Algo parecido al TROJAN, simular los daños en el avión basados en la forma como el piloto lo maneje.

Por ejemplo Fallar el motor si el piloto usa full Throttle por mas de 10 Minutos, en algunos aviones sera menos me imagino.

Simular daños en el sistema electrico, si llueve y se inunda el avion, o le cae un rayo....  Huh?

Simular Baja presión de Aceite, Batería Baja, Temperatura ITT, EGT, presion de combustible,
 fallo del sistema Eléctrico, fallo en los generadores... en fin todo lo que puede fallar.

Ahora lo que me toca averiguar es que factores, pueden llevar al fallo de los sistemas, por que la verdad el fallo aleatorio la tiene implementado el X plane.

Aqui la idea es por ejemplo, si el piloto le prende todas las luces al avión, conecta el Ipod, la cámara, el televisor, el portátil, el reproductor de DVD, y el amperaje del BUS 1 se Recarga entonces, produzca un daño en el Generador 1 .....  o algo así Girar ojos ....

Tengo que investigar mas al respecto.... o alguien que tenga el TROJAN me diga que fallos simula por mal manejo del piloto.....

Gracias Carlos tu idea esta interesante  Cheesy

DONDE ESTAN LOS PROGRAMADORES QUE HABLAN ESPAÑOL..... Perdon este keyboard esta fallando se le queda pegado el Caps LOCK ( otra vez fallo)  Llorar

25 Junio, 2011, 08:12:09 #4
qumake
Usuario Habitual
******
Desconectado Desconectado

Mensajes: 1239




En línea
Re: Mi primer SCRIPT

Creo que ese será el mejor plugin que se ha hecho para X-Plane... un gestor de fallos (¿medio universal?)... el antiguo plugin RealEngine no sé como actuaría ahora con tantos aviones con sus propios plugins.

Si hablamos de motor, frenos...lo interesante es que tuviera una memoria -un log por avión- de regímenes anteriores y crear así un factor desgaste del motor para el mismo avión.

Los errores ¿aleatorios? de X-plane...pfff... no sé yo... SIEMPRE (desde la 8.20) tengo los mismos fallos (humo en cabina, pinchazo de rueda, fuego en motor...y no te creas que muchos mas)... que comparándolo con la extensísima lista de sistemas susceptibles al fallo pues da que pensar.

Parece que fueran aleatorios dentro de un grupo muy concreto y reducido de errores... supongo que habrá un cierto factor de corrección para hacer semejante el número de fallos de ciertos sistemas con lo que ocurre en la realidad... p.ej... es mas frecuente el engelamiento o que se pinche una rueda a que una antena VOR se quede pelada o se te apaguen las luces de pista en corta final.

Fallo ---> Pinchazo en neumático = {f x c x T} =  (0.150 x c x T)
Fallo ---> VOR fuera de cobertura =                =  (0.001 x c x T)

//  f= factor de frecuencia ; c = otros factores; T = intervalo de errores -lo que ponemos en X-Plane-

Digo yo!...  Girar ojos

ánimo en tu proyecto...

P.D.: ¿a través de esos scripts se puede modificar lo que se hace en PlaneMaker?... creo que no... pero por preguntar.
Por ejemplo: quiero que la velocidad de giro del timón de navegación sea, no sólo no-lineal y mas lenta, si no que siga una un función velocidad según el grado de giro...digamos... algo de amortiguamineto Avergonzado... vale...hay unas opciones de control de deflexión en PM... pero como lo que quiero hacer es otra cosa distinta al timón... pues tampoco me sirve.
« Última modificación: 25 Junio, 2011, 08:46:24 por qumake »


25 Junio, 2011, 10:38:06 #5
Dragun
Usuario Frecuente
*****
Desconectado Desconectado

Mensajes: 679



WWW
En línea
Re: Mi primer SCRIPT

Bueno le agregue Espacio en Nm que el avion ha recorrido en el vuelo actual y el tiempo en Horas / minutos / segundos en alcanzar el proximo Waypoint programado en el FMS.

Código:
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()
end

function OnDraw_Windows()
dr_sim_total_weight = xp.getDataref("sim/flightmodel/weight/m_total")
g_total_weight =  xp.getFloat(dr_sim_total_weight)  * 2.20462262

get_ALTG_ft = acf.getAltAgl() * 3.28 --  Aircraft altitude above ground level in meters. Then meter to Ft

get_altA_ft = acf.getAltMsl() * 3.28 -- Aircraft altitude above mean-sea-level in meters. Then meter to Ft

get_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.20462262

way_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 nm

ete = xp.getDataref("sim/cockpit2/radios/indicators/gps_dme_time_min")
get_ete = xp.getFloat(ete) * 60 -- segundos

Horas = math.modf(get_ete / 3600)
segundos_restantes = get_ete - Horas * 3600
Minutos =  math.modf(segundos_restantes / 60)
Sec =  segundos_restantes - Minutos * 60

local pc = popupMiniMap_coords --grab a local reference for a fraction more speed, and shorthand
gfx.texOff()
gfx.setColor(1,0,0,1)
--draw a box, coordinates are left, top, width, height
gfx.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)
end
last_mx = -1
last_my = -1

drag_in_progress = false

function 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



Fotos de Como se ve en pantalla : http://forums.x-plane.org/index.php?showtopic=23517&view=findpost&p=583867


Felicidades ...gran trabajo


25 Junio, 2011, 14:22:35 #6
CarlosGarcia
Usuario Frecuente
*****
Desconectado Desconectado

Mensajes: 663



En línea
Re: Mi primer SCRIPT

Gracias por su apoyo... me estaba haciendo falta....  Sonreir

qumake :

 ¿a través de esos scripts se puede modificar lo que se hace en PlaneMaker? Que quieres Modificar ?

Hay cosas que se pueden modificar, por ejemplo las animaciones en 3D, puedes cargar de forma dinamica objetos, algo como si el motor uno le fallo la presion de aceite y se incendio, entonces carga el objeto X, que simula fuego en el motor.

Podemos cambiar las especificaciones del Avion de forma dinamica como el peso, la cantidad de combustibe, altura critica, en fin todas las DATAREF de X plane que sean Escribibles se pueden modificar a tu antojo  

Me imagino que ya tu conoces esta pagina http://www.xsquawkbox.net/xpsdk/docs/DataRefs.html, pues todas las DATAREF que digan Writable las puedes modificar a tu antojo de acuerdo a los condicionales que quieras

Por ejemplo : si la presión de combustible esta baja entonces reducirle la potencia al motor en un 20 %.... cosas así se pueden hacer.

Con respecto al timón de navegación, si se puede controlar sin ningun problema, es mas el caso de los aviones FBW usan de cierto modo algun tipo de Plug in para simularlo y tener mejor control de las deflexiones de las superficies de control. De tal forma que puedes controlar los angulos de ataque, el radio de giro, fuerzas de gravedad máxima.

Mira este ejemplo es en  SASL que es casi lo mismo que GIZMO,

Este es el codigo para la falla si la temperatura CHT es mas de 250 Grados por mas de 15 minutos. Este codigo pertenece al Ilyiushin-14 de Felis.

Es un simple contador que cuando los condicionales de CHT son mayores de 250 empieza a contar y si esa situación perdura por mas de 15 minutos entonces le dice al Motor que falle...  En este caso como son dos motores usan CHT_1 y CHT_2

Código:
-- 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
   end

Por 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]


Eso con respecto a los fallos del avion, con respecto a la modificacion de los parametros del timón de navegación

Por ejemplo se podría manipular como lo ves aqui en este ejemplo, pero en este caso están manipulando al Auto piloto.

Código:
-- 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)
    end
return 0
end


Si quieres ver un buen control de FBW, que es mas o menos la idea que pienso que tienes, un buen avión que controla los parámetros que el usuario esta utilizando en el Jooystick por ejemplo es el SSJ-100, ahí puedes mirar la lógica de control del script.

No se puede publicar aqui por, ya tu sabes problemas de derecho de autor y demás.

En fin tanto como en GIZMO como en SASL se pueden hacer maravillas.

Mira este avión lo bajas y miras el directorio CUSTOM AVIONICS como te das cuenta se pueden hacer hasta los instrumentos de control en la cabina.... Mucho poder pero muy poco conocimiento de mi parte....

http://forums.x-plane.org/index.php?app=downloads&showfile=13170 Es el IL-14 de Felis, el código esta bien documentado en Ingles

Bueno me emocione mucho.... Espero te sirva la información.  Sonrisa
 
« Última modificación: 25 Junio, 2011, 15:19:48 por suministros »

25 Junio, 2011, 14:30:26 #7
Dragun
Usuario Frecuente
*****
Desconectado Desconectado

Mensajes: 679



WWW
En línea
Re: Mi primer SCRIPT

Gracias a que tu te 'emocionas' , los demas nos animamos jejeje...otra vez felicidades por tus aportes sobre el Gizmo ..


16 Julio, 2011, 04:39:06 #8
CarlosGarcia
Usuario Frecuente
*****
Desconectado Desconectado

Mensajes: 663



En línea
Re: Mi primer SCRIPT

Ok ya he avanzado un poco en el Script , ahora puedo ver la Distancia Total que el avion a recorrido, el consumo de combustibe, la posicion actual del Avion (Latitud y Longitud) Y si se pone un Plan de Vuelo en el FMS te da la distancia en tiempo real entre el Avion y el punto final o way point del FMS

La idea es crear un script que durante el vuelo y al final de el tengas una estadística del peso del Avion, el uso del Combustible y el tiempo total del vuelo y los tiempos estimados de llegada a los Way points...

Cuando estas probando un avion que quieres conocer el PERFORMANCE estos datos como el peso y el uso del Combustible, del N1 es muy importante y por eso decidí hacer este Script para tener esta información disponible en la pantalla.

Ademas cuando ya esta en la aproximacion Final, le baja automaticamente el rango de EFIS MAP y solo deja visible el Aeropuerto. Esto era para mi por que a veces no es facil ver donde esta el Aeropuerto por que have muchos Fix y VOR y NDB cerca al aeropuerto.

Bueno la verdad No he encontrado apoyo en Xplane.es para este tipo de desarrollo o sea que es la Ultima Actualizacion que hago del Script.

Gracias a todos los que se interesaron...

Código:
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 = 0
Fuelinicial = 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 GS
EFIS_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 automatico
AUTOPILOT = 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 automatico
altitude_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 = 0
destination = 0

function OnDraw_Windows()

-- Coloca los rangos de los mapas y deja visible unicamente el Aeropuerto
appr=xp.getDataref("sim/cockpit2/autopilot/approach_status") -- Cero (0) No esta en aproximacion, Uno (1) Armado, Dos (2) Engaged
get_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 mapa


thro=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 combustible
g_total_weight =  xp.getFloat(dr_sim_total_weight)  * 2.20462262

get_ALTG_ft = acf.getAltAgl() * 3.28 --  Aircraft altitude above ground level in meters. Then meter to Ft

get_altA_ft = acf.getAltMsl() * 3.28 -- Aircraft altitude above mean-sea-level in meters. Then meter to Ft

get_IAS=acf.getKIAS() -- Aircraft Indicated Air Speed in Knots.

VSI = xp.getDataref("sim/cockpit2/gauges/indicators/vvi_fpm_pilot") -- Velocidad vertical en Pies/minuto
get_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 bordo
get_fuel = xp.getFloat(fuel) * 2.20462262

way_point_distance = xp.getDataref("sim/cockpit2/radios/indicators/gps_dme_distance_nm") -- DIstancia que falta para llegar al proximo waypoint
get_way_point_distance = xp.getFloat(way_point_distance)

distance=xp.getDataref("sim/flightmodel/controls/dist") -- Distancia Total recorrida
get_distance = xp.getFloat(distance) /1982 -- Meters to nm

ete = xp.getDataref("sim/cockpit2/radios/indicators/gps_dme_time_min") -- Tiempo estimado a llegar al proximo Waypoint
get_ete = xp.getFloat(ete) * 60 -- segundos

Horas = math.modf(get_ete / 3600)
segundos_restantes = get_ete - Horas * 3600
Minutos =  math.modf(segundos_restantes / 60)
Sec =  segundos_restantes - Minutos * 60

FuelConsumido = get_Fuelinicial - get_fuel -- Calculo del Consumo de combustible

plane_actual_position = string.format("Posicion Actual %0.2f/%0.2f", acf.getLat(), acf.getLon()) --Posicion Latitud Y longitud Actual del Avion
destination = 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 calculation
lat_a = acf.getLat()
lon_a = acf.getLon()
lat_b = Latitude
lon_b = Longitude

a = math.pi / 180
lat1 = lat_a * a
lat2 = lat_b * a
lon1 = lon_a * a
lon2 = lon_b * a
t1 = math.sin(lat1) * math.sin(lat2)
t2 = math.cos(lat1) * math.cos(lat2)
t3 = math.cos(lon1 - lon2)
t4 = t2 * t3
t5 = t1 + t4
rad_dist = math.atan(-t5/math.sqrt(-t5 * t5 +1)) + 2 * math.atan(1)
--route_distance = rad_dist * 3437.74677 * 1.1508 * 1.6093470878864446 -- In Kilometers
route_distance = rad_dist * 3437.74677 * 1.1508
-- End of Arnaud Formula

distance_wp = trig.distanceBetweenPoints( acf.getLat(),acf.getLon(),Latitude,Longitude) * 60.1 -- Gizmo API
--- Calculo del Tiempo de Vuelo
tiempodevuelo= 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 * 3600
Minutos_tv =  math.modf(segundos_restantes_tv / 60)

--- Para evitar fluctuaciones de datos en pantalla
if (get_way_point_distance >1000) then -- X plane no permite Way point muy largos
Horas = 0
Minutos = 0
Sec =0
get_way_point_distance = 0
end

if (get_VSI > - 10 and get_VSI < 10)  then -- Quitar fluctuaciones a Baja velocidad
get_VSI = 0
end

if (get_IAS > -1 and get_IAS < 1)  then -- Quitar fluctuaciones a Baja velocidad
get_IAS = 0
Horas = 0
Minutos = 0
Sec =0
end

if (destination <0 ) then
distance_wp = 0 -- Ben Formula
route_distance = 0 --Arnaud Formula
end

if (Latitude = 0 and Longitude = 0) then -- No way point data
distance_wp = 0 -- Ben Formula
route_distance = 0 --Arnaud Formula
end
 

local pc = popupMiniMap_coords --grab a local reference for a fraction more speed, and shorthand
gfx.texOff()
gfx.setColor(1,0,0,1)
--draw a box, coordinates are left, top, width, height
gfx.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)
end
last_mx = -1
last_my = -1

drag_in_progress = false

function 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

21 Agosto, 2011, 11:45:27 #9
Dragun
Usuario Frecuente
*****
Desconectado Desconectado

Mensajes: 679



WWW
En línea
Re: Mi primer SCRIPT

Me pongo en serio con el Gizmo , asiq empezare a hacer preguntas .....gracias de antemano por tu ayuda y aportes ... Sonreir


22 Agosto, 2011, 15:36:39 #10
CarlosGarcia
Usuario Frecuente
*****
Desconectado Desconectado

Mensajes: 663



En línea
Re: Mi primer SCRIPT

Hola Dragun....  ( que pena no contestar antes  Avergonzado )

Las lecturas OBLIGADAS....

DATAREF de X-plane
http://www.xsquawkbox.net/xpsdk/docs/DataRefs.html

FOROS ( estan en ingles y hay muchos ejemplos practicos)
http://forums.x-pilot.com/index.php?/forum/114-general-discussion/

API ( los comandos de GIZMO y su uso)  ESTE ES EL MAS "IMPORTANTE"  Sonrisa
http://dl.dropbox.com/u/948813/Gizmo_API.htm

Ejemplos en los que puedes ver como se se estructura el lenguaje.
https://github.com/benrussell/Gizmo-SDK
https://github.com/benrussell/Gizmo-Scripts

La clave para poder desbloquear GIZMO ( No estoy pirateando el Mismo AUTOR lo publico)
http://forums.x-pilot.com/index.php?/topic/2385-free-gizmo-11x-serial-number/

find_all_the_cool_stuff@x-aviation.com:11-ab27-e8f4

Si tienes alguna pregunta especifica por favor me avisas. Mira mi perfil y me mandas un correo electronico.

Este creo que es el codigo por el cual debes iniciar : ( FALLAS DEL SISTEMA)

Código:
--list some things you want to trigger failures

dr_sim_ITT_c = xp.getDataref("sim/flightmodel/engine/ENGN_ITT_c")

--list what failure datarefs you want to fail

dr_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 off
local timer_overStress = nil
local ITT = xp.getFloatV(dr_sim_ITT_c, 1, 2) --either of my engines in this case


--start an argument
if ITT >600 then
  if (timer_overStress == nil) then
    timer_overStress = timer.newOneShot("failEngine", 15) --calls failEngine() in 15 seconds unless the pilot reduces ITT!

    end

elseif ITT <600 then
  if (timer_overStress ~= nil) then
    timer.stop(timer_overStress) --stops the timer when pilot corrects his erroneous ways
  end
  end
end


------

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

22 Agosto, 2011, 15:40:07 #11
CarlosGarcia
Usuario Frecuente
*****
Desconectado Desconectado

Mensajes: 663



En línea
Re: Mi primer SCRIPT

Y esto es lo ultimo que estoy haciendo, basado en la informacion del FMS, te calcula la distancia total entre el Primer Way Point y el Destino. Al momento estoy usando dos Formulas para mirar cual es mas precisa  Indeciso

 
Código:
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 = 0
Fuelinicial = 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 GS
EFIS_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 automatico
AUTOPILOT = 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 automatico
altitude_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 = 0
destination = 0

function OnDraw_Windows()

-- Coloca los rangos de los mapas y deja visible unicamente el Aeropuerto
appr=xp.getDataref("sim/cockpit2/autopilot/approach_status") -- Cero (0) No esta en aproximacion, Uno (1) Armado, Dos (2) Engaged
get_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 mapa


thro=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 combustible
g_total_weight =  xp.getFloat(dr_sim_total_weight)  * 2.20462262

get_ALTG_ft = acf.getAltAgl() * 3.28 --  Aircraft altitude above ground level in meters. Then meter to Ft

get_altA_ft = acf.getAltMsl() * 3.28 -- Aircraft altitude above mean-sea-level in meters. Then meter to Ft

get_IAS=acf.getKIAS() -- Aircraft Indicated Air Speed in Knots.

VSI = xp.getDataref("sim/cockpit2/gauges/indicators/vvi_fpm_pilot") -- Velocidad vertical en Pies/minuto
get_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 bordo
get_fuel = xp.getFloat(fuel) * 2.20462262

way_point_distance = xp.getDataref("sim/cockpit2/radios/indicators/gps_dme_distance_nm") -- DIstancia que falta para llegar al proximo waypoint
get_way_point_distance = xp.getFloat(way_point_distance)

distance=xp.getDataref("sim/flightmodel/controls/dist") -- Distancia Total recorrida
get_distance = xp.getFloat(distance) /1982 -- Meters to nm

ete = xp.getDataref("sim/cockpit2/radios/indicators/gps_dme_time_min") -- Tiempo estimado a llegar al proximo Waypoint
get_ete = xp.getFloat(ete) * 60 -- segundos

Horas = math.modf(get_ete / 3600)
segundos_restantes = get_ete - Horas * 3600
Minutos =  math.modf(segundos_restantes / 60)
Sec =  segundos_restantes - Minutos * 60

FuelConsumido = get_Fuelinicial - get_fuel -- Calculo del Consumo de combustible

plane_actual_position = string.format("Posicion Actual %0.2f/%0.2f", acf.getLat(), acf.getLon()) --Posicion Latitud Y longitud Actual del Avion
destination = 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

lat_a = acf.getLat()
lon_a = acf.getLon()
lat_b = Latitude
lon_b = Longitude

a = math.pi / 180
lat1 = lat_a * a
lat2 = lat_b * a
lon1 = lon_a * a
lon2 = lon_b * a
t1 = math.sin(lat1) * math.sin(lat2)
t2 = math.cos(lat1) * math.cos(lat2)
t3 = math.cos(lon1 - lon2)
t4 = t2 * t3
t5 = t1 + t4
rad_dist = math.atan(-t5/math.sqrt(-t5 * t5 +1)) + 2 * math.atan(1)

--route_distance = rad_dist * 3437.74677 * 1.1508 * 1.6093470878864446 -- In Kilometers
route_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 Vuelo
tiempodevuelo= 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 * 3600
Minutos_tv =  math.modf(segundos_restantes_tv / 60)

--- Para evitar fluctuaciones de datos en pantalla
if (get_way_point_distance >1000) then -- X plane no permite Way point muy largos
Horas = 0
Minutos = 0
Sec =0
get_way_point_distance = 0
end

if (get_VSI > - 10 and get_VSI < 10)  then -- Quitar fluctuaciones a Baja velocidad
get_VSI = 0
end

if (get_IAS > -1 and get_IAS < 1)  then -- Quitar fluctuaciones a Baja velocidad
get_IAS = 0
Horas = 0
Minutos = 0
Sec =0
end

if (destination <0 ) then
distance_wp = 0
end

local pc = popupMiniMap_coords --grab a local reference for a fraction more speed, and shorthand
gfx.texOff()
gfx.setColor(1,0,0,1)
--draw a box, coordinates are left, top, width, height
gfx.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)
end
last_mx = -1
last_my = -1

drag_in_progress = false

function 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

27 Agosto, 2011, 13:54:25 #12
Dragun
Usuario Frecuente
*****
Desconectado Desconectado

Mensajes: 679



WWW
En línea
Re: Mi primer SCRIPT

Lo vi durante las vacaciones , pero imposible trabajar desde el móvil , tocaba esperar ...acabo de llegar  ...me pongo al día a partir del lunes , muchas gracias por toda la info , aun así me e leído todo  lo q me lleve sobre Lua , pero esta claro q el tema es practicar .

Como el tema es fijarse una utilidad, empezare por mostrar info del estado de los motores , no tiene mucho sentido, pero me ayudara en el camino de aprender , despues le añadiré un menú de avería , algo mas rápido q el q trae el XP , y sin tener q salir a otra pantalla.

Asiq, este es el tema para aprender .... voy a imprimirme tus script y intentar desmenuzar lo, poco a poco...pero siempre motivado por el ofrecimiento de tu ayuda.

Lo dicho ....muchas gracias y esperemos , cuando lea esto dentro de unos meses , ver q e aprendido ....   A POR ELLO ¡¡¡ je je


Tags:
Páginas: [1]   Ir Arriba
  Imprimir  
 
Ir a:  

www.x-plane.es.
Página creada en 0.093 segundos con 18 queries.