Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @name Water pump controller
- @inputs ToggleRefuel PumpsSubmerged WaterAvailable WaterCapacity ClampsEngaged DriverEntity:entity
- @outputs Latch Clamps Pumps ShipBrake Mode:string
- @persist WaterPercent
- @trigger none
- #Initialisation
- #In here the E2 just sets itself up if it hasn't been
- #activated previously. It also does some basic per-loop math.
- interval(100)
- WaterPercent=((WaterAvailable/WaterCapacity)*100)
- if(Mode==""){Mode="Flight"}
- #The next section handles mode switching
- #The entire system operates on a system of modes.
- #By having the outputs isolated totally from the inputs
- #we can add more modes or inputs very easily at a later date.
- #For instance, it wasn't until I was already coding this E2 that
- #I realised I would need the "Dropping" and "Retracting" modes.
- #But by having everything isolated, I could add them and their
- #behaviours in very easily.
- if(Mode=="Flight" && ToggleRefuel){
- if(WaterPercent>=90){
- DriverEntity:hintDriver("Tanks are over 90% capacity",3)
- DriverEntity:hintDriver("Pumps have remained docked",3)}
- else{
- Mode="Dropping"
- DriverEntity:hintDriver("Dropping pumps",3)}}
- elseif(ToggleRefuel){
- Mode="Retracting"
- DriverEntity:hintDriver("Emergency pump shutoff complete",3)
- DriverEntity:hintDriver("Pumps retracting",3)}
- elseif(Mode=="Dropping" && PumpsSubmerged){
- Mode="Pumping"
- DriverEntity:hintDriver("Pumps engaging",3)}
- elseif(Mode=="Pumping" && WaterPercent>=90){
- Mode="Retracting"
- DriverEntity:hintDriver("Tanks are full. Retracting pumps",3)}
- elseif(Mode=="Retracting" && ClampsEngaged==4){
- Mode="Flight"
- DriverEntity:hintDriver("Pumps are docked and secure",3)
- DriverEntity:hintDriver("Up is go, on your command.",3)}
- #The section below covers mode behaviours
- #In this section we control how the ship reacts to being put
- #into any of its different modes. As mentioned earlier, modes
- #can be added very easily, simply by adding the behaviour below
- #and by setting up when that behaviour should happen above.
- if(Mode=="Flight"){
- Latch=0
- Clamps=1
- Pumps=0}
- if(Mode=="Dropping"){
- Latch=0
- Clamps=0
- Pumps=0
- ShipBrake=1}
- if(Mode=="Pumping"){
- Latch=1
- Clamps=1
- Pumps=1
- ShipBrake=1}
- if(Mode=="Retracting"){
- Latch=0
- Clamps=1
- Pumps=0
- ShipBrake=1}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement