Jump to content
Sign in to follow this  
Colonel X

"Real Weather Visibility Limit 1.0"

Recommended Posts

Here's what the script (Python) does:

 

from XPLMDefs import *
from XPLMDisplay import *
from XPLMGraphics import *
from XPLMProcessing import *
from XPLMDataAccess import *
from XPLMUtilities import *
 
MAX_VISIBILITY = 45000.0 # maximal visibility for Real Weather in meters
 
class PythonInterface:
    def XPluginStart(self):
self.Name = "RW visibility limit"
        self.Sig = "Xplane.Python.RWVisLim"
        self.Desc = "A plugin that limits real weather visibility."
        self.VisibilityDataRef = XPLMFindDataRef("sim/weather/visibility_reported_m")
self.RealWeatherDataRef = XPLMFindDataRef("sim/weather/use_real_weather_bool")
self.cloud_type0 = XPLMFindDataRef("sim/weather/cloud_type[0]")
self.cloud_type1 = XPLMFindDataRef("sim/weather/cloud_type[1]")
self.cloud_type2 = XPLMFindDataRef("sim/weather/cloud_type[2]")
self.cloud_coverage0 = XPLMFindDataRef("sim/weather/cloud_coverage[0]")
self.cloud_coverage1 = XPLMFindDataRef("sim/weather/cloud_coverage[1]")
self.cloud_coverage2 = XPLMFindDataRef("sim/weather/cloud_coverage[2]")
self.cloud_base_msl_m0 = XPLMFindDataRef("sim/weather/cloud_base_msl_m[0]")
self.cloud_base_msl_m1 = XPLMFindDataRef("sim/weather/cloud_base_msl_m[1]")
self.cloud_base_msl_m2 = XPLMFindDataRef("sim/weather/cloud_base_msl_m[2]")
self.cloud_tops_msl_m0 = XPLMFindDataRef("sim/weather/cloud_tops_msl_m[0]")
self.cloud_tops_msl_m1 = XPLMFindDataRef("sim/weather/cloud_tops_msl_m[1]")
self.cloud_tops_msl_m2 = XPLMFindDataRef("sim/weather/cloud_tops_msl_m[2]")
self.rain_percent = XPLMFindDataRef("sim/weather/rain_percent")
self.thunderstorm_percent = XPLMFindDataRef("sim/weather/thunderstorm_percent")
self.wind_turbulence_percent = XPLMFindDataRef("sim/weather/wind_turbulence_percent")
self.barometer_sealevel_inhg = XPLMFindDataRef("sim/weather/barometer_sealevel_inhg")
self.wind_altitude_msl_m0 = XPLMFindDataRef("sim/weather/wind_altitude_msl_m[0]")
self.wind_altitude_msl_m1 = XPLMFindDataRef("sim/weather/wind_altitude_msl_m[1]")
self.wind_altitude_msl_m2 = XPLMFindDataRef("sim/weather/wind_altitude_msl_m[2]")
self.wind_direction_degt0 = XPLMFindDataRef("sim/weather/wind_direction_degt[0]")
self.wind_direction_degt1 = XPLMFindDataRef("sim/weather/wind_direction_degt[1]")
self.wind_direction_degt2 = XPLMFindDataRef("sim/weather/wind_direction_degt[2]")
self.wind_speed_kt0 = XPLMFindDataRef("sim/weather/wind_speed_kt[0]")
self.wind_speed_kt1 = XPLMFindDataRef("sim/weather/wind_speed_kt[1]")
self.wind_speed_kt2 = XPLMFindDataRef("sim/weather/wind_speed_kt[2]")
self.shear_direction_degt0 = XPLMFindDataRef("sim/weather/shear_direction_degt[0]")
self.shear_direction_degt1 = XPLMFindDataRef("sim/weather/shear_direction_degt[1]")
self.shear_direction_degt2 = XPLMFindDataRef("sim/weather/shear_direction_degt[2]")
self.shear_speed_kt0 = XPLMFindDataRef("sim/weather/shear_speed_kt[0]")
self.shear_speed_kt1 = XPLMFindDataRef("sim/weather/shear_speed_kt[1]")
self.shear_speed_kt2 = XPLMFindDataRef("sim/weather/shear_speed_kt[2]")
self.turbulence0 = XPLMFindDataRef("sim/weather/turbulence[0]")
self.turbulence1 = XPLMFindDataRef("sim/weather/turbulence[1]")
self.turbulence2 = XPLMFindDataRef("sim/weather/turbulence[2]")
self.wave_amplitude = XPLMFindDataRef("sim/weather/wave_amplitude")
self.wave_length = XPLMFindDataRef("sim/weather/wave_length")
self.wave_speed = XPLMFindDataRef("sim/weather/wave_speed")
self.wave_dir = XPLMFindDataRef("sim/weather/wave_dir")
self.temperature_sealevel_c = XPLMFindDataRef("sim/weather/temperature_sealevel_c")
self.dewpoi_sealevel_c = XPLMFindDataRef("sim/weather/dewpoi_sealevel_c")
self.runway_friction = XPLMFindDataRef("sim/weather/runway_friction")
self.FlightLoopCB = self.FlightLoopCallback
XPLMRegisterFlightLoopCallback(self, self.FlightLoopCB, 1.0, 0)
 
        return self.Name, self.Sig, self.Desc
 
 
    def XPluginStop(self):
        # Unregister the callback
        XPLMUnregisterFlightLoopCallback(self, self.FlightLoopCB, 0)
        pass
 
 
    def XPluginEnable(self):
return 1
 
 
    def XPluginDisable(self):
        pass
 
 
    def XPluginReceiveMessage(self, inFromWho, inMessage, inParam):
        pass
 
 
    def FlightLoopCallback(self, elapsedMe, elapsedSim, counter, refcon):
        Maximal_Visibility = MAX_VISIBILITY
  RealWeather = XPLMGetDatai(self.RealWeatherDataRef)
        Visibility = XPLMGetDataf(self.VisibilityDataRef)
 
if (RealWeather == 0):
   XPLMSetDatai(self.RealWeatherDataRef, 1) # set use real weather  
 
        if (Visibility > Maximal_Visibility):
   cloud_type0 = XPLMGetDatai(self.cloud_type0)
   cloud_type1 = XPLMGetDatai(self.cloud_type1)
   cloud_type2 = XPLMGetDatai(self.cloud_type2)
   cloud_coverage0 = XPLMGetDataf(self.cloud_coverage0)
   cloud_coverage1 = XPLMGetDataf(self.cloud_coverage1)
   cloud_coverage2 = XPLMGetDataf(self.cloud_coverage2)
   cloud_base_msl_m0 = XPLMGetDataf(self.cloud_base_msl_m0)
   cloud_base_msl_m1 = XPLMGetDataf(self.cloud_base_msl_m1)
   cloud_base_msl_m2 = XPLMGetDataf(self.cloud_base_msl_m2)
   cloud_tops_msl_m0 = XPLMGetDataf(self.cloud_tops_msl_m0)
   cloud_tops_msl_m1 = XPLMGetDataf(self.cloud_tops_msl_m1)
   cloud_tops_msl_m2 = XPLMGetDataf(self.cloud_tops_msl_m2)
   rain_percent = XPLMGetDataf(self.rain_percent)
   thunderstorm_percent = XPLMGetDataf(self.thunderstorm_percent)
   wind_turbulence_percent = XPLMGetDataf(self.wind_turbulence_percent)
   barometer_sealevel_inhg = XPLMGetDataf(self.barometer_sealevel_inhg)
   wind_altitude_msl_m0 = XPLMGetDataf(self.wind_altitude_msl_m0)
   wind_altitude_msl_m1 = XPLMGetDataf(self.wind_altitude_msl_m1)
   wind_altitude_msl_m2 = XPLMGetDataf(self.wind_altitude_msl_m2)
   wind_direction_degt0 = XPLMGetDataf(self.wind_direction_degt0)
   wind_direction_degt1 = XPLMGetDataf(self.wind_direction_degt1)
   wind_direction_degt2 = XPLMGetDataf(self.wind_direction_degt2)
   wind_speed_kt0 = XPLMGetDataf(self.wind_speed_kt0)
   wind_speed_kt1 = XPLMGetDataf(self.wind_speed_kt1)
   wind_speed_kt2 = XPLMGetDataf(self.wind_speed_kt2)
   shear_direction_degt0 = XPLMGetDataf(self.shear_direction_degt0)
   shear_direction_degt1 = XPLMGetDataf(self.shear_direction_degt1)
   shear_direction_degt2 = XPLMGetDataf(self.shear_direction_degt2)
   shear_speed_kt0 = XPLMGetDataf(self.shear_speed_kt0)
   shear_speed_kt1 = XPLMGetDataf(self.shear_speed_kt1)
   shear_speed_kt2 = XPLMGetDataf(self.shear_speed_kt2)
   turbulence0 = XPLMGetDataf(self.turbulence0)
   turbulence1 = XPLMGetDataf(self.turbulence1)
   turbulence2 = XPLMGetDataf(self.turbulence2)
   wave_amplitude = XPLMGetDataf(self.wave_amplitude)
   wave_length = XPLMGetDataf(self.wave_length)
   wave_speed = XPLMGetDataf(self.wave_speed)
   wave_dir = XPLMGetDatai(self.wave_dir)
   temperature_sealevel_c = XPLMGetDataf(self.temperature_sealevel_c)
   dewpoi_sealevel_c = XPLMGetDataf(self.dewpoi_sealevel_c)
   runway_friction = XPLMGetDataf(self.runway_friction)
            XPLMSetDataf(self.VisibilityDataRef, Maximal_Visibility) # set visibility
            XPLMSetDatai(self.cloud_type0, cloud_type0)
            XPLMSetDatai(self.cloud_type1, cloud_type1)
            XPLMSetDatai(self.cloud_type2, cloud_type2)
            XPLMSetDataf(self.cloud_coverage0, cloud_coverage0)
            XPLMSetDataf(self.cloud_coverage1, cloud_coverage1)
            XPLMSetDataf(self.cloud_coverage2, cloud_coverage2)
            XPLMSetDataf(self.cloud_base_msl_m0, cloud_base_msl_m0)
            XPLMSetDataf(self.cloud_base_msl_m1, cloud_base_msl_m1)
            XPLMSetDataf(self.cloud_base_msl_m2, cloud_base_msl_m2)
            XPLMSetDataf(self.cloud_tops_msl_m0, cloud_tops_msl_m0)
            XPLMSetDataf(self.cloud_tops_msl_m1, cloud_tops_msl_m1)
            XPLMSetDataf(self.cloud_tops_msl_m2, cloud_tops_msl_m2)
            XPLMSetDataf(self.rain_percent, rain_percent)
            XPLMSetDataf(self.thunderstorm_percent, thunderstorm_percent)
            XPLMSetDataf(self.wind_turbulence_percent, wind_turbulence_percent)
            XPLMSetDataf(self.barometer_sealevel_inhg, barometer_sealevel_inhg)
            XPLMSetDataf(self.wind_altitude_msl_m0, wind_altitude_msl_m0)
            XPLMSetDataf(self.wind_altitude_msl_m1, wind_altitude_msl_m1)
            XPLMSetDataf(self.wind_altitude_msl_m2, wind_altitude_msl_m2)
            XPLMSetDataf(self.wind_direction_degt0, wind_direction_degt0)
            XPLMSetDataf(self.wind_direction_degt1, wind_direction_degt1)
            XPLMSetDataf(self.wind_direction_degt2, wind_direction_degt2)
            XPLMSetDataf(self.wind_speed_kt0, wind_speed_kt0)
            XPLMSetDataf(self.wind_speed_kt1, wind_speed_kt1)
            XPLMSetDataf(self.wind_speed_kt2, wind_speed_kt2)
            XPLMSetDataf(self.shear_direction_degt0, shear_direction_degt0)
            XPLMSetDataf(self.shear_direction_degt1, shear_direction_degt1)
            XPLMSetDataf(self.shear_direction_degt2, shear_direction_degt2)
            XPLMSetDataf(self.shear_speed_kt0, shear_speed_kt0)
            XPLMSetDataf(self.shear_speed_kt1, shear_speed_kt1)
            XPLMSetDataf(self.shear_speed_kt2, shear_speed_kt2)
            XPLMSetDataf(self.turbulence0, turbulence0)
            XPLMSetDataf(self.turbulence1, turbulence1)
            XPLMSetDataf(self.turbulence2, turbulence2)
            XPLMSetDataf(self.wave_amplitude, wave_amplitude)
            XPLMSetDataf(self.wave_length, wave_length)
            XPLMSetDataf(self.wave_speed, wave_speed)
            XPLMSetDatai(self.wave_dir, wave_dir)
            XPLMSetDataf(self.temperature_sealevel_c, temperature_sealevel_c)
            XPLMSetDataf(self.dewpoi_sealevel_c, dewpoi_sealevel_c)
            XPLMSetDataf(self.runway_friction, runway_friction)
     
 
        return 1.0

-

Belligerent X-Plane 12 enthusiast on Apple M1 Max 64GB

Share this post


Link to post
Share on other sites

It seems to work fine, but after 45 minutes or so, I get constant weather reloads...


-

Belligerent X-Plane 12 enthusiast on Apple M1 Max 64GB

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...