No description
Find a file
2021-03-21 12:05:43 +11:00
src Added basic caching of market data 2021-03-21 11:59:19 +11:00
changelog.md Grammer error 2021-03-21 12:05:43 +11:00
example Added basic caching of market data 2021-03-21 11:59:19 +11:00
example.nim Switched to sync api 2021-03-21 11:58:40 +11:00
LICENSE Initial commit 2021-03-20 12:39:31 +11:00
readme.md Missed a waitFor 2021-03-21 12:03:16 +11:00
spacenimtraders.nimble 0.2.0 2021-03-21 12:01:23 +11:00
todo.md Show what I am working on 2021-03-20 12:43:43 +11:00

I was going to call it space nimvaders but that doesn't make much sense seeing has it is a trading game

Tutorial

What's The Game?

SpaceTraders is a typical fleet management / trading / strategy game. Right now we've built the basic game features such as purchasing ships, navigating them around the universe, and trading goods at a profit. Later we plan to expand into construction, combat, exploration, factions, officers, ship modules and more.

How To Play Guide

To follow this guide you first need to install the library

nimble install spacenimtraders

You can then follow along by running it all in a nim file or by using inim

This tutorial uses the sync api but you can use it in an async context with newAsyncClient instead of newClient

Generate An Access Token

The API is only accessible if you have an access token. You can claim a username and generate a token by using this method. Make sure you save this token and don't share it with anyone. You can only generate a single token once per username.

import spacenimtraders
let token = claimUsername("foobar") # Username is foobar # Save this token to a file or something so that you can read it back in later
echo token

let client = newClient("foobar", token)

View Your User Account

Congratulations on taking your first steps toward the complete and total domination of galactic trade! Let's take a quick look at your account.

echo client

Looks like you don't have much in the way of credits or assets. Let's see how we can fix that.

View Available Loans

Let's kick off our trade empire by taking out a small low-risk loan. We can use these funds to purchase our first ship and fill our cargo with something valuable.

for loan in client.getLoans:
    echo client.getLoans()

Take Out A Loan

Let's take out a small loan to kick off our new venture.

discard client.applyLoan(Startup)

View Ships To Purchase

Now our credits are looking much healthier! But remember, you will have to pay it back by the due date. Let's buy a small ship to start shipping goods around and hopefully make enough to pay back our loan.

for ship in client.getShips(MK1):
    echo ship

Choose one of the available ships and send a request to purchase it. The Jackshaw looks like a good cheap option.

Purchase A Ship

discard client.buyShip("OE-PM-TR", "JW-MK-I")
echo client

Save your ship to a variable so we can resuse it in a moment.

let ship = client.ships[`your_ship_id`]

Now let's load it up with fuel and metals and see if we can make a profitable trade.

Purchase Ship Fuel

discard client.buyGoods(ship, Fuel, 20)

View Marketplace

Each location has a marketplace of goods. Let's see what's available to us.

echo client.getMarket(ship.location)

Metals look like a solid trade good. Let's fill our cargo full.

discard client.buyGoods(ship, Metal, 80)

Find Nearby Planet

Now we need to find a nearby planet to unload our cargo.

for planet in client.getLocations(ship.getSystem(), Planet):
    echo planet

Looks like Prime is right next to us. Let's create a flight plan to send our ship to the planet.

Create Flight Plan

let flightPlan = client.createFlightPlan(ship, "OE-PM")

You can monitor your ship's flight plan until it arrives. We will save the flight plan so that we can check on it in a moment.

View Flight Plan

echo client.getFlightPlan(flightPlan)

Sell Trade Goods

Let's place a sell order for our metals.

discard client.sellGoods(ship, Metal, 80)
echo client

Next Steps

Congratulations! You made your first profitable trade. You will likely want to trade in higher margin goods, but metals are a sure-fire way to make some credits. Try buying another ship, exploring each market, and maybe automate your way to wealth and glory! When you're ready to pay back your loan, you can call the final method in this guide:s

discard client.payLoan()