Created
June 14, 2025 11:20
-
-
Save agrif/7582acd7fe1fe5da11ebc559515cef89 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import spess.client | |
import spess.models | |
def extract_cycle(c, ship): | |
ext = ship.extract_resources().extraction.yield_ | |
print(f'got {ext.units} units of {ext.symbol}') | |
ship.wait() | |
if ext.symbol != 'IRON_ORE': | |
ship.jettison_cargo(ext.symbol, ext.units) | |
print(ship.cargo) | |
def extract_loop(c, ship): | |
while ship.cargo.units < ship.cargo.capacity: | |
print('-- mining', datetime.datetime.now().isoformat()) | |
extract_cycle(c, ship) | |
def contract(c): | |
m = c.ship('AGRIF-3') | |
cont, = c.contracts() | |
contwp = c.waypoint(m.nav, cont.terms.deliver[0].destinationSymbol) | |
roid, = c.system_waypoints(m.nav, type='ENGINEERED_ASTEROID') | |
while True: | |
# fly to asteroid | |
if m.nav.waypointSymbol != roid.symbol: | |
print('flying to asteroid') | |
m.navigate(roid) | |
m.wait() | |
# do the mining loop | |
extract_loop(c, m) | |
# fly to dropoff | |
if m.nav.waypointSymbol != contwp.symbol: | |
print('flying to dropoff') | |
m.navigate(contwp) | |
m.wait() | |
# dock to refuel and dropoff | |
amt = cont.terms.deliver[0].unitsRequired - cont.terms.deliver[0].unitsFulfilled | |
print(f'{amt} remains in contract') | |
amt = min(amt, 15) | |
print(f'dropping off {omt}') | |
m.dock() | |
m.refuel() | |
cont.deliver(m, 'IRON_ORE', amt) | |
m.orbit() | |
# break if we didn't drop off a full load | |
if amt < 15: | |
break | |
print('done!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment