Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Search for fuel tanks and SRBs on SHIP and add to lists.
- for i in SHIP:PARTS
- {
- //Walk through resources for that part
- for res in i:resources
- {
- if res:name = "LIQUIDFUEL"
- {
- SET child to i.
- //Check to see if it has an engine or fuel line attached
- //We do this so stacked tanks are staged properly,
- //rather than staging as soon as one of them is empty
- for j in child:CHILDREN
- {
- if j:name = "fuelLine" OR j:name = "liquidEngine"
- {
- tanklist:ADD (i).
- break.
- }
- }
- }
- if res:name = "SOLIDFUEL"
- {
- srblist:ADD (i).
- break.
- }
- }
- }
- SET tanklist2 to tanklist:COPY.
- SET srblist2 to srblist:COPY.
- //Check tanks to see if empty and stage if needed
- WHEN flight_state <= 3 THEN
- {
- SET tanknum to 0.
- for t in tanklist
- {
- if t:resources[0]:AMOUNT < 0.01
- {
- PRINT "Staging due to empty fuel tank".
- tanklist2:REMOVE(tanknum).
- STAGE.
- break.
- }
- set tanknum to tanknum + 1.
- }
- SET tanklist to tanklist2:COPY.
- //Stage SRBs when empty
- set srbnum to 0.
- if srblist:LENGTH > 0
- {
- for i in srblist
- {
- if i:resources[0]:AMOUNT < 0.01 AND i:STAGE = STAGE:NUMBER
- {
- PRINT "Staging due to empty SRB".
- srblist2:REMOVE(srbnum).
- STAGE.
- break.
- }
- set srbnum to srbnum + 1.
- }
- set srblist to srblist2:COPY.
- }
- PRESERVE.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement