Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @name Hydraulic Flipper Code v1.0
- @inputs Fire Charge
- @outputs Constant Damping Length
- @outputs CurrentCharge #This can be wired to an indicator
- @outputs HiFlipping PercentageCharge #Debug Values
- @persist CurrentCharge HiFlipping
- @persist Ten Twenty Thirty Fourty Fifty Sixty Seventy Eighty Ninety Hundred Ready #Info things
- runOnTick(1)
- FullPowerLength=150 #Length for a Full power flip.
- FullPowerConstant=10000000 #Constant for a Full power flip.
- FullPowerDamping=500 #Damping for a Full power flip.
- StationaryLength=0 #Length when the flipper is not flipping.
- StationaryConstant=15000 #Constant when the flipper is not flipping.
- StationaryDamping=1500 #Damping when the flipper is not flipping.
- #Flipper Controller stolen straight from Business
- if(Fire == 1) #check is Fire is pressed
- {
- HiFlipping=1
- }
- if(HiFlipping == 1 & StationaryLength < (FullPowerLength*(CurrentCharge/500))) #Check is flipper is pressed and that the new length is longer then the Stationary Length.
- {
- Length = (FullPowerLength*(CurrentCharge/500)) #Calculation for new flipper length.
- Constant = FullPowerConstant
- Damping = FullPowerDamping
- timer("HiExtend",1200) #Timer for how long the flipper stays open
- CurrentCharge = 0 #Charge is reset when flip is successful
- }
- else
- {
- HiFlipping = 0 #if the flip isn't successful, the charge remains the same.
- }
- if(clk("HiExtend")){ #Run when the timer finished
- Length = StationaryLength,
- Constant = StationaryConstant
- Damping = StationaryDamping
- timer("HiPersist",250) #Timer for how long it takes for the flipper to reset. Don't change.
- }
- if(clk("HiPersist"))
- {
- HiFlipping = 0
- } #End of flip.
- #Charging the Flipper
- if(Charge == 1 & CurrentCharge <= 500 & HiFlipping == 0) #if charge button is pressed and the value of the charge isn't higher then 500.
- {
- if(CurrentCharge < 250) #Starts fast then slows down.
- {
- CurrentCharge = CurrentCharge + 3
- }
- elseif(CurrentCharge <= 300 & CurrentCharge > 250)
- {
- CurrentCharge = CurrentCharge + 2
- }
- else
- {
- CurrentCharge = CurrentCharge + 1
- }
- }
- #Info for drivers
- 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.
- {
- print("Ready to Fire")
- Ready = 1
- }
- PercentageCharge = round((CurrentCharge/500), 1)
- if(PercentageCharge == 0.1 & Ten == 0)
- {
- print("10% Charge")
- Ten = 1
- }
- if(PercentageCharge == 0.2 & Twenty == 0)
- {
- print("20% Charge")
- Twenty = 1
- }
- if(PercentageCharge == 0.3 & Thirty == 0)
- {
- print("30% Charge")
- Thirty = 1
- }
- if(PercentageCharge == 0.4 & Fourty == 0)
- {
- print("40% Charge")
- Fourty = 1
- }
- if(PercentageCharge == 0.5 & Fifty == 0)
- {
- print("50% Charge")
- Fifty = 1
- }
- if(PercentageCharge == 0.6 & Sixty == 0)
- {
- print("60% Charge")
- Sixty = 1
- }
- if(PercentageCharge == 0.7 & Seventy == 0)
- {
- print("70% Charge")
- Seventy = 1
- }
- if(PercentageCharge == 0.8 & Eighty == 0)
- {
- print("80% Charge")
- Eighty = 1
- }
- if(PercentageCharge == 0.9 & Ninety == 0)
- {
- print("90% Charge")
- Ninety = 1
- }
- if(PercentageCharge == 1 & Hundred == 0)
- {
- print("100% Charge")
- Hundred = 1
- }
- if(PercentageCharge == 0) #These values are used to make sure the driver isn't notified twice.
- {
- Ten = 0
- Twenty = 0
- Thirty = 0
- Fourty = 0
- Fifty = 0
- Sixty = 0
- Seventy = 0
- Eighty = 0
- Ninety = 0
- Hundred = 0
- Ready = 0
- }
Add Comment
Please, Sign In to add comment