#Conditional Hooks
$Application: FS2_Open

$On HUD Comm Menu Opened: [
  mn.runSEXP('( set-time-compression 0.1 50)')
  local sfx = ad.loadSoundfile("slowtime.ogg")
  sfx:play()
  
  local async_util = require("async_util")
  
  async.run(function()
    async.await(async_util.wait_for(0.2))
	if hu.isCommMenuOpen() then
	  ad.pauseMusic(-1, true)
	end
  end, async.OnFrameExecutor)
]

$On HUD Comm Menu Closed: [
  mn.runSEXP('( set-time-compression 100 1000)')
  local sfx = ad.loadSoundfile("restoretime.ogg")
  sfx:play()
  
  local async_util = require("async_util")
  
  async.run(function()
    async.await(async_util.wait_for(0.8))
	if not hu.isCommMenuOpen() then
	  ad.pauseMusic(-1, false)
	end
  end, async.OnFrameExecutor)
]

$On Gameplay Start: [
  mn.runSEXP('( reset-time-compression )')
]

#End