BasketMC

GPS and Turtle2: Hypermine Modded Episode 6

  • Published on

Episode 6 of Hypermine Modded is mostly about code. Basket wants the turtles to find their own way home, even after the server restarts, and that means GPS. By the end the GPS works, the bus runner turtles can find their homes, and the new quarry script is still broken.

Four GPS computers

The trouble Basket describes at the start: a turtle that powers off mid-job, or after a server restart, has no idea where it is. The bus runners might also end up in a different order. Basket has not set up GPS before. Four computers go into a small marble room, each labeled with a GPS name, sunk lower so they are out of the way, and each needs a wireless modem. Basket crafts four of them. One computer's screen reports "No wireless modems found. 1 required." until one is attached.

ComputerCraft computers in a row in a marble brick room, labeled GPS1, under a sign listing BasketMC to-dos

Ambiguous position

Each GPS computer needs its exact position typed in. The test turtle has no modem at first, so Basket adds one and asks it to locate itself. The answer is "ambiguous position." After reading up, Basket finds one computer had one number wrong. A fix and a reboot later, the turtle knows where it is. "I was worried that I had to rearrange these things."

A test turtle goes home

Days of coding follow. The test turtle, turtle6, now tries to go home as soon as it starts. It moves one block to learn which way it is facing, then heads for the spot Basket set. It handles height first, then the other two directions, so from some spots it fails. In one run it tries to go down and can't, then goes over and down and turns to face the right way. "It seems fairly straightforward, but it's actually took a bunch of code."

A ComputerCraft turtle with the nameplate turtle6 sitting at the bottom of a small cobblestone pit on a marble floor

Turtle2 and three homes

Basket breaks the bus runners' start code along the way and comes back a couple of hours later with Turtle2, an API the turtles call in place of the regular moves. It keeps track of the turtle's position and the direction it faces, so it does not have to ask GPS every time. Each bus runner gets three homes in priority order: a menu on the turtle sets the current spot as home 1, 2 or 3. Then Basket pretends the server just reset and boots them up. Each one finds its facing, travels back and settles into its spot. "Maybe not very exciting, but it's a lot of programming."

A row of color-coded ender chests above red blocks, with a turtle nameplate reading BusRunner in front of them

Where it ends

The quarry turtles are next. The plan is for them to save where they left off, so after a restart they can go home, empty out and carry on. Basket is not sure the GPS reaches that far, and these turtles have no wireless modems yet. A couple of hours later the new quarry code is not working: a test turtle went across, came back, turned around and kept going. Later, Basket wants the turtle to carry an ender chest and empty into it when full. For now the episode ends there, in the stone pit.

A dug-out stone pit lit by torches, with dirt in the far wall and an ender chest set into the stone