X-Plane 12 Random Storm Lua Emergency Situation Challenge.
The X-Plane 12 Random Storm Lua Emergency Situation Challenge is all about challenging your decision making and flying skills in X Plane 12. This script is all about putting you in a bad weather situation and you and your valued passengers home safe! Are you up to the challenge?
The situation requires you have the X PLANE 12 WEATHER on MANUAL! If you have automatic weather it will not activate! The Random_Storm.lua allows you time to get into your aircraft and takeoff unhindered. You may fly any aircraft your X Plane 12 sim has to offer. The script is not designed specifically for any aircraft like the previous series of BAron 58 Scripts that take you from Cold & Dark or Engines Running at the beginning through your takeoff checks, Climb, Cruise then back to the ground safely.

This script can be used alongside these scripts as well if you wish. I have the script running in the background as i write this initial section of the blog post. I have to say I’m loving the ability to create specific LUA NG scripts for all you X Plane 12 pilots and sharing them for you to experience.
How to Install the Lua Script

Create Your Own File.
Copy everything BETWEEN the LINES and Paste into a NOTEPAD page!
Name the file: Random_Storm.lua
ENSURE you change the file type from TXT to ALL FILES.
If you look at your file and it says Random_Storm.lua.txt you didn’t do correctly ok! Resave it and change the FILE TYPE in the lower save box to ALL FILES and you will see it named correctly as Random_Storm.lua – OK
Please the file in your X Plane 12/resources/plugins/flywithlua/scripts folder.
Copy the text BETWEEN the ——– but don’t copy the lines please.
Name your new script:Random_Storm.lua – Further Updated 26/6/2025.

The Script – Random_Storm.lua
Whats Said?
- Sir, Thunder and lightning are possible ahead according to the latest weather reports.
The storm appears to be intensifying sir, Maybe we need to consider landing soon
.Heavy wind gusts are reported Sir, Reports of 40 to 50 knot winds at the surface are now being reported
- Storm system is approaching Sir. Weather will begin deteriorating shortly.
The 2,3,4 are dependent on the storm situation if they are spoken at all. There is some difference the weather conditions. It may or may not have lightening and thunder? You will experience different effects hopefully.
———————————-
–[[
RANDOM_STORM.lua
Extreme Storm Challenge for X-Plane 12
Randomized delay before thunderstorm builds up (15–30 mins)
Includes thunderstorm cloud types, wind gusts, and copilot voice prompts
Created by Brendon McAliece + ChatGPT | letsflyvfr.com
–]]
— Weather Datarefs
dataref(“cloud1”, “sim/weather/cloud_coverage[0]”, “writable”)
dataref(“cloud2”, “sim/weather/cloud_coverage[1]”, “writable”)
dataref(“cloud3”, “sim/weather/cloud_coverage[2]”, “writable”)
dataref(“cloud_base1”, “sim/weather/cloud_base_msl_m[0]”, “writable”)
dataref(“cloud_tops1”, “sim/weather/cloud_tops_msl_m[0]”, “writable”)
dataref(“vis”, “sim/weather/visibility_reported_m”, “writable”)
dataref(“wind_speed”, “sim/weather/wind_speed_kt[0]”, “writable”)
dataref(“wind_direction”, “sim/weather/wind_direction_degt[0]”, “writable”)
— Cloud type for lightning effect
dataref(“cloud_type1”, “sim/weather/cloud_type[0]”, “writable”)
dataref(“cloud_type2”, “sim/weather/cloud_type[1]”, “writable”)
dataref(“cloud_type3”, “sim/weather/cloud_type[2]”, “writable”)
— Frame time substitute
dataref(“frame_time”, “sim/operation/misc/frame_rate_period”, “readonly”)
— Control variables
local transition_time = 600 — storm builds over 10 minutes
local timer = 0
local interval = 3.0
local time_accumulator = 0
— Delay before storm starts
local storm_delay = math.random(900, 1800) — between 15 and 30 minutes
local delay_timer = 0
local storm_started = false
— Storm variables
local storm_intensity = 0
local thunder_triggered = false
local lightning_triggered = false
local wind_gust_active = false
local gust_strength = 0
— Voice function
function speakNoText(sText)
if XPLMSpeakString then
XPLMSpeakString(sText)
end
end
function play_lightning()
logMsg(“Lightning Strike!”)
speakNoText(“Sir, Thunder and lightning are possible ahead according to the latest weather reports!“)
end
function random_wind_gust()
gust_strength = math.random(40, 50)
wind_gust_active = true
end
function gradual_weather_change()
time_accumulator = time_accumulator + frame_time
if time_accumulator < interval then return end
time_accumulator = 0
if timer < transition_time then
timer = timer + interval
local fraction = timer / transition_time
storm_intensity = fractionif not lightning_triggered and storm_intensity > 0.4 then play_lightning() lightning_triggered = true end if storm_intensity > 0.7 and not thunder_triggered then speakNoText("The storm appears to be intensifying sir, Maybe we need to consider landing soon!") thunder_triggered = true end if storm_intensity > 0.5 and not wind_gust_active then random_wind_gust() speakNoText("Heavy wind gusts are reported Sir, Reports of 40 to 50 knot winds at the surface are now being reported!") end -- Force thunderstorm cloud types if storm_intensity > 0.5 then cloud_type1 = 2 cloud_type2 = 2 cloud_type3 = 2 end cloud1 = storm_intensity * 1.0 cloud2 = storm_intensity * 0.9 cloud3 = storm_intensity * 0.8 cloud_base1 = 400 - (math.pow(storm_intensity, 1.5) * 400) cloud_tops1 = cloud_base1 + 1000 vis = 10000 - (storm_intensity * 9500) wind_speed = storm_intensity * gust_strength wind_direction = math.random(0, 360)
else
— Final state: storm in full swing
cloud1 = 1.0
cloud2 = 0.9
cloud3 = 0.7
cloud_base1 = 100
cloud_tops1 = 200
vis = 1000
wind_speed = 50
wind_direction = math.random(0, 360)
cloud_type1 = 2
cloud_type2 = 2
cloud_type3 = 2logMsg("RANDOM_STORM.lua: Full storm conditions applied.") do_every_frame("")
end
end
— Handles the randomized delay before storm begins
function delayed_storm_start()
delay_timer = delay_timer + frame_time
if not storm_started and delay_timer >= storm_delay then
speakNoText(“Storm system is approaching Sir. Weather will begin deteriorating shortly.“)
do_every_frame(“gradual_weather_change()”)
do_every_frame(“”) — stop delay function
storm_started = true
end
end
— Log storm delay and begin timer
logMsg(“RANDOM_STORM.lua: Storm will start in ” .. math.floor(storm_delay / 60) .. ” minutes.”)
do_every_frame(“delayed_storm_start()”)
——————————
Adjusting the Script!
Your welcome to make this script your own but please note the legal notice below. The highlighted areas above are areas you can alter if you wish. The actual speech is easy to edit between the ( ) signs and the section below you can randomise the time frame in SECONDS the script will activate.
— Delay before storm starts
local storm_delay = math.random(900, 1800) — between 15 and 30 minutes
local delay_timer = 0
local storm_started = false
This script is currently set to activate randomly between 900 Seconds & 1800 Seconds ie Between 15 minutes and 30 minutes. Feel free to change the timing if your on a long flight and want to force a touch arrival for yourself or even throw in a possible diversion for yourself or a friend! It’s all up to you!

Random_Storm.lua – Common Issues & Troubleshooting
While the Random_Storm.lua Script has been extensively tested by Brendon McAliece (AKA Gunnie) of LETSFLYVFR.com, there may still be occasional issues, especially as the script is still in beta. The script included worked perfectly and is running as I write this post and works perfectly!

Common Lua Script Issues:
- No Speech or Callouts: Ensure FlyWithLua NG is properly installed. If the Lua script isn’t executing, it might be due to missing files or incorrect setup. Check the installation steps carefully.
- Script Not Running: Double-check that the script file is saved with the correct .lua extension and placed in the FlyWithLua/Scripts/ folder.
- Missing Datarefs or Errors in Log: If you see errors about missing datarefs, it may indicate that a specific part of the aircraft model or X-Plane setup is not fully compatible with the script. Report any issues in the comments or contact us.
- Performance Issues: If the script causes performance issues, try disabling other scripts temporarily to identify potential conflicts.
Current Baron 58 Lua Scripts Available.
- COLD START – Baron 58 Co Pilot Lua (Completed & Published)
- Engines Running – Baron 58 Co Pilot Lua (Completed & Published)
- X Plane 12 Co Pilot Take OFF Climb LUA Script (Completed & Published)
- Baron 58 Co Pilot – Cruise Decent LUA Script (Completed & Published)
- Baron 58 Co Pilot – Decent – Landing (In Progress)
- Random Storm Lua – Generic and for ALL AIRCRAFT you Own! (Completed & Published)

Author

Brendon McAliece (Aka Gunnie) is a military veteran with 23 years working on Jet Fighters, their weapons systems and ejection seat/module systems as well as munitions and R&D. Involved with flight simulation since the 1980s, he has flown all the major flight simulators over the years.
He is an Australian expat who has lived in Malaysia, UK, Saudi Arabia and more recently Thailand. He is a multi-lingual blogger who loves to share his life experiences here on LetsFlyVFR.com and DreamingGuitar.com, with his lifestyle and Travel experiences Blog plus his Dreaming Coffee website.
Learn More @
DreamingGuitar.com – DreamingCoffee.com – LetsFlyVFR.com
( HOME – BLOG – SHOP – ABOUT )
This page has been viewed 0 times.
As an Amazon affiliate I may benefit from qualifying sales.