Advertisement
Guest User

r00tyX52.act

a guest
Nov 21st, 2019
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.34 KB | None | 0 0
  1. ACTIONFILE V4
  2.  
  3. ENABLED True
  4.  
  5. INSTALL Version=1.0.0.1
  6. INSTALL MinEDVersion=10.6.0.0
  7. INSTALL ShortDescription="LED and MFD actions for the Saitek X52 Pro HOTAS"
  8.  
  9. EVENT UIFsdMassLocked, UIFsdMassLocked, "", Condition AlwaysTrue
  10. EVENT onRefreshEnd, StartupShutdown, "", Condition AlwaysTrue
  11. EVENT onShutdown, StartupShutdown, "", Condition AlwaysTrue
  12. EVENT UIFsdCharging, UIFsdCharging, "", Condition AlwaysTrue
  13. EVENT UIFsdCooldown, UIFsdCooldown, "", Condition AlwaysTrue
  14. EVENT UISupercruise, UISupercruise, "", Condition AlwaysTrue
  15. EVENT UILandingGear, UILandingGear, "", Condition AlwaysTrue
  16. EVENT FSDJump, FSDJump, "", Condition AlwaysTrue
  17. EVENT Docked, JournalDocked, "", Condition AlwaysTrue
  18. EVENT UIDocked, UIDocked, "", Condition AlwaysTrue
  19. EVENT onStartup, onStartup, "", Condition AlwaysTrue
  20. EVENT StartJump, StartJump, "", Condition AlwaysTrue
  21. EVENT Location, AtLocation, "", Condition AlwaysTrue
  22.  
  23. // ****************************************************************************************************************
  24. // This script provides feedback of FSD status, Landing gear state, and MFD info about current system/docking state
  25. // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  26. // FSD state is on light for button T3/T4 (because I have FSD on T3)
  27. // When FSD is on cooldown, slow flashing red.
  28. // When Mass locked, steady red
  29. // When FSD available and not in supercruise, steady green
  30. // When FSD is charging, flash flashing amber
  31. // When FSD is in hyperdrive, steady amber
  32. // When FSD is in supercruise, slow flashing green
  33. // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  34. // Landing gear state is on light for button T1/T2 (Gear is on T1 for me)
  35. // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  36. // When gear is up, steady green
  37. // When gear is down, steady red
  38. // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  39. // MFD will store star class when a jump is made, before that point star class is not known
  40. // Otherwise when not docked, it will show "System:" on line 1, the system name on line 2.
  41. // If star class is known "Type: x" with the class of star will be shown.
  42. // When performing a hyperspace jump it will show "Jumping to:" line 1, system name on line 2, and "Type: x" with
  43. // star class on line 3.
  44. // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  45. // Todo:
  46. // Use lights on throttle to indicate some status, under attack, heat warning, interdiction etc
  47. // Perhaps some other status for other activities as they come along, fuel scoop etc
  48. // Another idea is to have some lights change based on posture, e.g. most pips to engine, normal running (green)
  49. // most pips to systems, defensive (amber, flashing if under attack), most pips to weapons (red, flashing if under attack)
  50. // It's a real shame there's no feedback of the engine bars (not pips). Would have been good to give feedback of
  51. // boost availability.
  52. // Another idea is to turn off certain lights when they're not applicable. When docked for example
  53. // ****************************************************************************************************************
  54.  
  55. //*************************************************************
  56. // onStartup
  57. // Events: onStartup
  58. //*************************************************************
  59. PROGRAM onStartup
  60.  
  61. // Declare set set flags
  62. Global isMassLocked = 0
  63. Global isFsdCooldown = 0
  64. Global isFsdCharging = 0
  65. Global isStartHyperJump = 0
  66. Global isStartSupercruise = 0
  67. Global isDocked = 0
  68. Global isGearDown = 0
  69. Global superCruiseState = 0
  70.  
  71. // Declare and set strings
  72. Global currentSystem = ""
  73. Global starClass = ""
  74. Global currentDock = ""
  75.  
  76. END PROGRAM
  77.  
  78. //*************************************************************
  79. // StartupShutdown
  80. // Events: onRefreshEnd, onShutdown
  81. //*************************************************************
  82. PROGRAM StartupShutdown
  83.  
  84. // When starting/shutting down EDDProfile, set some default lighting settings (all green)
  85. DLLCall EDDX52, setLED, FIRE, GREEN
  86. DLLCall EDDX52, setLED, FIRE_A, GREEN
  87. DLLCall EDDX52, setLED, FIRE_B, GREEN
  88. DLLCall EDDX52, setLED, FIRE_D, GREEN
  89. DLLCall EDDX52, setLED, FIRE_E, GREEN
  90. DLLCall EDDX52, setLED, TOGGLE_1_2, GREEN
  91. DLLCall EDDX52, setLED, TOGGLE_3_4, GREEN
  92. DLLCall EDDX52, setLED, TOGGLE_5_6, GREEN
  93. DLLCall EDDX52, setLED, POV_2, GREEN
  94. DLLCall EDDX52, setLED, CLUTCH, GREEN
  95. DLLCall EDDX52, setLED, THROTTLE, ON
  96.  
  97. END PROGRAM
  98.  
  99. //*************************************************************
  100. // updateMFD
  101. //*************************************************************
  102. PROGRAM updateMFD
  103.  
  104. // Always reset MFD
  105. DLLCall EDDX52, resetMFD
  106.  
  107. // Set first line based on state
  108. If isStartHyperJump IsTrue
  109. DLLCall EDDX52, setString, 0, "Jumping to:", MFD_STARTJUMP1
  110. ElseIf isDocked IsTrue
  111. DLLCall EDDX52, setString, 0, "Docked:", MFD_JDOCKED1
  112. Else
  113. DLLCall EDDX52, setString, 0, "System:", MFD_FSDJUMP1
  114.  
  115. // Set second line based on state
  116. If currentSystem $!= ""
  117. DLLCall EDDX52, setString, 1, %(currentSystem), MFD_STARTJUMP2
  118. Else
  119. DLLCall EDDX52, setString, 1, "UNKNOWN", MFD_STARTJUMP2
  120.  
  121. // Set third line based on state
  122. If isDocked IsTrue
  123. DLLCall EDDX52, setString, 2, %(currentDock), MFD_JDOCKED3
  124. ElseIf starClass $!= ""
  125. DLLCall EDDX52, setString, 2, "Type: %(starClass)", MFD_STARTJUMP3
  126.  
  127. END PROGRAM
  128.  
  129. //*************************************************************
  130. // updateFsdLights
  131. //*************************************************************
  132. PROGRAM updateFsdLights
  133.  
  134. // This handles the lighting on T3/T4 which shows the FSD state using the following priority.
  135. // isFsdCooldown > isStartHyperJump > isStartSupercruise > isFsdCharging > isMassLocked > superCruiseState
  136. If isFsdCooldown IsTrue
  137. // Cooldown state T3/T4 = Red flashing 1s on 1s off
  138. DLLCall EDDX52, setLED, TOGGLE_3_4, RED
  139. DLLCall EDDX52, advSetLED, 11, 1, 1, 1, 1, 0
  140. DLLCall EDDX52, syncFlashPatterns
  141. ElseIf isStartHyperJump IsTrue
  142. // Hyperspace jump in progress = T3/T4 = fast flash green/amber
  143. DLLCall EDDX52, setLED, TOGGLE_3_4, GREEN
  144. DLLCall EDDX52, advSetLED, 11, 1, 1, 0.25, 0.25, 0
  145. //DLLCall EDDX52, advSetLED, 12, 1, 1, 0.25, 0.25, 0.5
  146. DLLCall EDDX52, syncFlashPatterns
  147. //DLLCall EDDX52, permaSyncTo, 11, 12
  148. ElseIf isStartSupercruise IsTrue
  149. // Supercruise charging = T3/T4 = Green flashing .25s on .25s off
  150. DLLCall EDDX52, setLED, TOGGLE_3_4, OFF
  151. DLLCall EDDX52, advSetLED, 12, 1, 1, 0.25, 0.25, 0
  152. DLLCall EDDX52, syncFlashPatterns
  153. ElseIf isFsdCharging IsTrue
  154. // Charging state T3/T4 = Amber flashing .25s on .25s off
  155. DLLCall EDDX52, setLED, TOGGLE_3_4, OFF
  156. DLLCall EDDX52, advSetLED, 11, 1, 1, 0.25, 0.25, 0
  157. DLLCall EDDX52, advSetLED, 12, 1, 1, 0.25, 0.25, 0
  158. DLLCall EDDX52, syncFlashPatterns
  159. ElseIf isMassLocked IsTrue
  160. // Mass locked = T3/T4 = Red
  161. DLLCall EDDX52, setLED, TOGGLE_3_4, RED
  162. ElseIf superCruiseState IsTrue
  163. // In supercruise = T3/T4 = Green flashing 1s on 1s off
  164. DLLCall EDDX52, setLED, TOGGLE_3_4, OFF
  165. DLLCall EDDX52, advSetLED, 12, 1, 1, 1, 1, 0
  166. DLLCall EDDX52, syncFlashPatterns
  167. Else
  168. // Otherwise in regular space = T3/T4 = Green
  169. DLLCall EDDX52, setLED, TOGGLE_3_4, GREEN
  170.  
  171. END PROGRAM
  172.  
  173. //*************************************************************
  174. // updateGearLight
  175. //*************************************************************
  176. PROGRAM updateGearLight
  177.  
  178. // This handles the lighting on T1/T2 which shows the landing gear state
  179. If isGearDown IsTrue
  180. DLLCall EDDX52, setLED, TOGGLE_1_2, RED
  181. Else
  182. DLLCall EDDX52, setLED, TOGGLE_1_2, GREEN
  183.  
  184. END PROGRAM
  185.  
  186. //*************************************************************
  187. // UIFsdMassLocked
  188. // Events: UIFsdMassLocked
  189. //*************************************************************
  190. PROGRAM UIFsdMassLocked
  191.  
  192. // Update mass locked status then update FSD light state
  193. If EventClass_MassLocked IsTrue
  194. Global isMassLocked = 1
  195. Else
  196. Global isMassLocked = 0
  197. Call updateFsdLights
  198.  
  199. END PROGRAM
  200.  
  201. //*************************************************************
  202. // UIFsdCooldown
  203. // Events: UIFsdCooldown
  204. //*************************************************************
  205. PROGRAM UIFsdCooldown
  206.  
  207. // Update FSD cooldown status then update FSD light state
  208. If EventClass_CoolDown IsTrue
  209. Global isFsdCooldown = 1
  210. Else
  211. Global isFsdCooldown = 0
  212.  
  213. Call updateFsdLights
  214.  
  215. END PROGRAM
  216.  
  217. //*************************************************************
  218. // UISupercruise
  219. // Events: UISupercruise
  220. //*************************************************************
  221. PROGRAM UISupercruise
  222.  
  223. // Update supercruise status then update FSD light state
  224. If EventClass_Supercruise IsTrue
  225. Global superCruiseState = 1
  226. Global isStartSupercruise = 0
  227. Else
  228. Global superCruiseState = 0
  229.  
  230. Call updateFsdLights
  231.  
  232. END PROGRAM
  233.  
  234. //*************************************************************
  235. // UIFsdCharging
  236. // Events: UIFsdCharging
  237. //*************************************************************
  238. PROGRAM UIFsdCharging
  239.  
  240. // Update charging status then update FSD light state
  241. If EventClass_Charging IsTrue
  242. Global isFsdCharging = 1
  243. Else
  244. Global isFsdCharging = 0
  245.  
  246. Call updateFsdLights
  247.  
  248. END PROGRAM
  249.  
  250. //*************************************************************
  251. // AtLocation
  252. // Events: Location
  253. //*************************************************************
  254. PROGRAM AtLocation
  255. // Seems to be called at game start so let's populate info we can get
  256. // Set current system and dock if set, and docked state then update MFD
  257. If EventClass_Docked IsTrue
  258. Global isDocked = 1
  259. Else
  260. Global isDocked = 0
  261.  
  262. If EventClass_StarSystem $!= ""
  263. Global currentSystem = %(EventClass_StarSystem)
  264.  
  265. If EventClass_StationName $!= ""
  266. Global currentDock = %(EventClass_StationName)
  267.  
  268. Call updateMFD
  269.  
  270. END PROGRAM
  271.  
  272. //*************************************************************
  273. // StartJump
  274. // Events: StartJump
  275. //*************************************************************
  276. PROGRAM StartJump
  277.  
  278. // If we're hyperspace jumping, make sure to update current system to target system
  279. // (can the jump not happen at this point? Might be a problem if it can)
  280. // Update FSD status and MFD
  281. If EventClass_JumpType $== Hyperspace
  282. Global isStartSupercruise = 0
  283. Global isStartHyperJump = 1
  284. Global currentSystem = %(EventClass_StarSystem)
  285. Global starClass = %(EventClass_StarClass)
  286. Else
  287. Global isStartHyperJump = 0
  288. Global isStartSupercruise = 1
  289. if EventClass_StarSystem $!= ""
  290. Global currentSystem = %(EventClass_StarSystem)
  291.  
  292. Call updateFsdLights
  293. Call updateMFD
  294.  
  295. END PROGRAM
  296.  
  297. //*************************************************************
  298. // FSDJump
  299. // Events: FSDJump
  300. //*************************************************************
  301. PROGRAM FSDJump
  302.  
  303. // Update status to normal (we just finished a jump), then update FSD status and MFD
  304. Global isStartHyperJump = 0
  305. Global currentSystem = %(EventClass_StarSystem)
  306.  
  307. Call updateFsdLights
  308. Call updateMFD
  309.  
  310. END PROGRAM
  311.  
  312. //*************************************************************
  313. // UILandingGear
  314. // Events: UILandingGear
  315. //*************************************************************
  316. PROGRAM UILandingGear
  317.  
  318. // Update gear state and then update gear light
  319. If EventClass_Gear IsTrue
  320. Global isGearDown = 1
  321. Else
  322. Global isGearDown = 0
  323.  
  324. Call updateGearLight
  325.  
  326. END PROGRAM
  327.  
  328. //*************************************************************
  329. // JournalDocked
  330. // Events: Docked
  331. //*************************************************************
  332. PROGRAM JournalDocked
  333.  
  334. // Set docked state, and station name then update MFD
  335. Global isDocked = 1
  336. Global currentDock = %(EventClass_StationName)
  337. If currentSystem $== ""
  338. Global currentSystem = %(EventClass_StarSystem)
  339.  
  340. Call updateMFD
  341.  
  342. END PROGRAM
  343.  
  344. //*************************************************************
  345. // UIDocked
  346. // Events: UIDocked
  347. //*************************************************************
  348. PROGRAM UIDocked
  349.  
  350. // If we undocked, change state and update MFD
  351. If EventClass_Docked IsFalse
  352. Global isDocked = 0
  353. Global currentDock = ""
  354.  
  355. If currentSystem $!= ""
  356. Call updateMFD
  357.  
  358. END PROGRAM
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement