Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. @name Water pump controller
  2. @inputs ToggleRefuel PumpsSubmerged WaterAvailable WaterCapacity ClampsEngaged DriverEntity:entity
  3. @outputs Latch Clamps Pumps ShipBrake Mode:string
  4. @persist WaterPercent
  5. @trigger none
  6.  
  7. #Initialisation
  8. #In here the E2 just sets itself up if it hasn't been
  9. #activated previously. It also does some basic per-loop math.
  10.  
  11. interval(100)
  12. WaterPercent=((WaterAvailable/WaterCapacity)*100)
  13. if(Mode==""){Mode="Flight"}
  14.  
  15. #The next section handles mode switching
  16. #The entire system operates on a system of modes.
  17. #By having the outputs isolated totally from the inputs
  18. #we can add more modes or inputs very easily at a later date.
  19. #For instance, it wasn't until I was already coding this E2 that
  20. #I realised I would need the "Dropping" and "Retracting" modes.
  21. #But by having everything isolated, I could add them and their
  22. #behaviours in very easily.
  23.  
  24. if(Mode=="Flight" && ToggleRefuel){
  25. if(WaterPercent>=90){
  26. DriverEntity:hintDriver("Tanks are over 90% capacity",3)
  27. DriverEntity:hintDriver("Pumps have remained docked",3)}
  28. else{
  29. Mode="Dropping"
  30. DriverEntity:hintDriver("Dropping pumps",3)}}
  31. elseif(ToggleRefuel){
  32. Mode="Retracting"
  33. DriverEntity:hintDriver("Emergency pump shutoff complete",3)
  34. DriverEntity:hintDriver("Pumps retracting",3)}
  35. elseif(Mode=="Dropping" && PumpsSubmerged){
  36. Mode="Pumping"
  37. DriverEntity:hintDriver("Pumps engaging",3)}
  38. elseif(Mode=="Pumping" && WaterPercent>=90){
  39. Mode="Retracting"
  40. DriverEntity:hintDriver("Tanks are full. Retracting pumps",3)}
  41. elseif(Mode=="Retracting" && ClampsEngaged==4){
  42. Mode="Flight"
  43. DriverEntity:hintDriver("Pumps are docked and secure",3)
  44. DriverEntity:hintDriver("Up is go, on your command.",3)}
  45.  
  46. #The section below covers mode behaviours
  47. #In this section we control how the ship reacts to being put
  48. #into any of its different modes. As mentioned earlier, modes
  49. #can be added very easily, simply by adding the behaviour below
  50. #and by setting up when that behaviour should happen above.
  51.  
  52. if(Mode=="Flight"){
  53. Latch=0
  54. Clamps=1
  55. Pumps=0}
  56. if(Mode=="Dropping"){
  57. Latch=0
  58. Clamps=0
  59. Pumps=0
  60. ShipBrake=1}
  61. if(Mode=="Pumping"){
  62. Latch=1
  63. Clamps=1
  64. Pumps=1
  65. ShipBrake=1}
  66. if(Mode=="Retracting"){
  67. Latch=0
  68. Clamps=1
  69. Pumps=0
  70. ShipBrake=1}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement