croga_

Hydraulic Flipper Code v1.0

Apr 24th, 2021 (edited)
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.68 KB | None | 0 0
  1. @name Hydraulic Flipper Code v1.0
  2. @inputs Fire Charge
  3. @outputs Constant Damping Length
  4. @outputs CurrentCharge #This can be wired to an indicator
  5. @outputs HiFlipping PercentageCharge #Debug Values
  6. @persist CurrentCharge HiFlipping
  7. @persist Ten Twenty Thirty Fourty Fifty Sixty Seventy Eighty Ninety Hundred Ready #Info things
  8.  
  9. runOnTick(1)
  10.  
  11. FullPowerLength=150 #Length for a Full power flip.
  12. FullPowerConstant=10000000 #Constant for a Full power flip.
  13. FullPowerDamping=500 #Damping for a Full power flip.
  14.  
  15. StationaryLength=0 #Length when the flipper is not flipping.
  16. StationaryConstant=15000 #Constant when the flipper is not flipping.
  17. StationaryDamping=1500 #Damping when the flipper is not flipping.
  18.  
  19.  
  20. #Flipper Controller stolen straight from Business
  21. if(Fire == 1) #check is Fire is pressed
  22. {
  23. HiFlipping=1
  24. }
  25.  
  26. if(HiFlipping == 1 & StationaryLength < (FullPowerLength*(CurrentCharge/500))) #Check is flipper is pressed and that the new length is longer then the Stationary Length.
  27. {
  28.  
  29. Length = (FullPowerLength*(CurrentCharge/500)) #Calculation for new flipper length.
  30. Constant = FullPowerConstant
  31. Damping = FullPowerDamping
  32. timer("HiExtend",1200) #Timer for how long the flipper stays open
  33. CurrentCharge = 0 #Charge is reset when flip is successful
  34. }
  35. else
  36. {
  37. HiFlipping = 0 #if the flip isn't successful, the charge remains the same.
  38. }
  39. if(clk("HiExtend")){ #Run when the timer finished
  40. Length = StationaryLength,
  41. Constant = StationaryConstant
  42. Damping = StationaryDamping
  43. timer("HiPersist",250) #Timer for how long it takes for the flipper to reset. Don't change.
  44. }
  45. if(clk("HiPersist"))
  46. {
  47. HiFlipping = 0
  48. } #End of flip.
  49.  
  50. #Charging the Flipper
  51. if(Charge == 1 & CurrentCharge <= 500 & HiFlipping == 0) #if charge button is pressed and the value of the charge isn't higher then 500.
  52. {
  53. if(CurrentCharge < 250) #Starts fast then slows down.
  54. {
  55. CurrentCharge = CurrentCharge + 3
  56. }
  57. elseif(CurrentCharge <= 300 & CurrentCharge > 250)
  58. {
  59. CurrentCharge = CurrentCharge + 2
  60. }
  61. else
  62. {
  63. CurrentCharge = CurrentCharge + 1
  64. }
  65. }
  66.  
  67. #Info for drivers
  68. if(StationaryLength < (FullPowerLength*(CurrentCharge/500)) & Ready == 0) #When the new length is longer then the stationery length, tell the driver the flipper is ready to fire.
  69. {
  70. print("Ready to Fire")
  71. Ready = 1
  72. }
  73. PercentageCharge = round((CurrentCharge/500), 1)
  74. if(PercentageCharge == 0.1 & Ten == 0)
  75. {
  76. print("10% Charge")
  77. Ten = 1
  78. }
  79. if(PercentageCharge == 0.2 & Twenty == 0)
  80. {
  81. print("20% Charge")
  82. Twenty = 1
  83. }
  84. if(PercentageCharge == 0.3 & Thirty == 0)
  85. {
  86. print("30% Charge")
  87. Thirty = 1
  88. }
  89. if(PercentageCharge == 0.4 & Fourty == 0)
  90. {
  91. print("40% Charge")
  92. Fourty = 1
  93. }
  94. if(PercentageCharge == 0.5 & Fifty == 0)
  95. {
  96. print("50% Charge")
  97. Fifty = 1
  98. }
  99. if(PercentageCharge == 0.6 & Sixty == 0)
  100. {
  101. print("60% Charge")
  102. Sixty = 1
  103. }
  104. if(PercentageCharge == 0.7 & Seventy == 0)
  105. {
  106. print("70% Charge")
  107. Seventy = 1
  108. }
  109. if(PercentageCharge == 0.8 & Eighty == 0)
  110. {
  111. print("80% Charge")
  112. Eighty = 1
  113. }
  114. if(PercentageCharge == 0.9 & Ninety == 0)
  115. {
  116. print("90% Charge")
  117. Ninety = 1
  118. }
  119. if(PercentageCharge == 1 & Hundred == 0)
  120. {
  121. print("100% Charge")
  122. Hundred = 1
  123. }
  124. if(PercentageCharge == 0) #These values are used to make sure the driver isn't notified twice.
  125. {
  126. Ten = 0
  127. Twenty = 0
  128. Thirty = 0
  129. Fourty = 0
  130. Fifty = 0
  131. Sixty = 0
  132. Seventy = 0
  133. Eighty = 0
  134. Ninety = 0
  135. Hundred = 0
  136. Ready = 0
  137. }
  138.  
Add Comment
Please, Sign In to add comment