Automated the extraction and delivery loop for a ship
This commit is contained in:
parent
b1157af9cd
commit
19107b153e
4 changed files with 94 additions and 112 deletions
|
@ -5,7 +5,7 @@ export async function extract(ctx) {
|
|||
if (response.error !== undefined) {
|
||||
switch(response.error.code) {
|
||||
case 4000: // ship is on cooldown
|
||||
await api.sleep(response.error.data.remainingSeconds * 1000);
|
||||
await api.sleep(response.error.data.cooldown.remainingSeconds * 1000);
|
||||
return extract(ctx);
|
||||
case 4228: // ship is full
|
||||
return null;
|
||||
|
@ -31,7 +31,9 @@ export async function dock(ctx) {
|
|||
}
|
||||
|
||||
export async function navigate(ctx) {
|
||||
return await api.send({endpoint: `/my/ships/${ctx.ship}/navigate`, method: 'POST', payload: { waypointSymbol: ctx.waypoint }});
|
||||
const response = await api.send({endpoint: `/my/ships/${ctx.ship}/navigate`, method: 'POST', payload: { waypointSymbol: ctx.waypoint }});
|
||||
const delay = new Date(response.data.nav.route.arrival) - new Date();
|
||||
await api.sleep(delay);
|
||||
}
|
||||
|
||||
export async function orbit(ctx) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue