The Farmer Was Replaced Guide & Walkthrough — Paste This First

If you searched for a guide, you need a script that runs — not a Python course. Paste the block below, then read loops and if.

News: DLC The Miner Was Replaced launches November 2, 2026 (announced Sep 9). This guide stays on the base game until mining APIs are public. Details: Steam

Copy-paste: harvest forever

python
while True:
    if can_harvest():
        harvest()
    move(East)
    if get_pos_x() == 0:
        move(North)

This is not full Python. `harvest()` and `move()` are game commands. After it runs, the sections below explain why `while True` never stops.

1.0 API gotchas (read before copy-pasting old scripts)

  • `trade()` removed. No `Carrot_Seed` / `Water_Tank` — planting spends inventory; water with `use_item(Items.Water)`.
  • `Grounds.Turf` → `Grounds.Grassland`. `set_farm_size` → `set_world_size`.
  • Megafarm drones do not share globals. Prefer `quick_print()` over `print()` in loops (print costs 1s).
01

Variables & Assignment

Variables are like labels in a warehouse. You can label a container (variable name) and then store something inside (assignment). In Python, we use `=` for assignment.

python
# Store "Carrot" in a variable named crop
crop = "Carrot"

# Store the number 10 in a variable named count
count = 10

# You can change a variable's value anytime
count = count + 5  # Now count is 15

💡 Naming Rules

  • Can only contain letters, numbers, and underscores (_)
  • Cannot start with a number
  • Case-sensitive (crop and Crop are different)

? After executing `x = 5; x = x + 2`, what is the value of x?

02

Data Types

There are different types of items on the farm (hay, wood, gold), and Python has different data types too:

Integer (int)

Integers, e.g., 10, -5, 0. Used for counting.

String (str)

Strings, must be wrapped in quotes, e.g., 'Hello'.

Boolean (bool)

Booleans, only True or False. Used for logic.

Float

Floats (decimal numbers), e.g., 3.14, 0.5.

? In Python, what is the data type of '10' (with quotes)?

03

Conditional Statements

Conditionals let your code 'think'. If a condition is true, execute a block of code; otherwise, execute another.

python
water_level = 20

if water_level < 50:
    print("需要浇水")  # Need watering
elif water_level > 80:
    print("水太多了")  # Too much water
else:
    print("水分刚好")  # Water is just right

⚠️ Note: Python uses indentation (spaces at the start of a line) to define code blocks. This is crucial!

? If `x = 10`, what will `if x > 5: print('A') else: print('B')` output?

04

Loops - The Soul of Automation

On the farm, you don't want to manually harvest 100 pumpkins. That's what loops are for: making the computer repeat boring tasks.

🔄 While Loop (Most Common)

As long as the condition is true, keep doing something.

python
# Loop until fuel tank is empty
while get_fuel() > 0:
    move_forward()
    harvest()

🔢 For Loop

Iterate over each item in a sequence (like a list).

python
for i in range(10):
    print("This is repetition number", i)  # This is repetition number i

? Which loop is best for creating an 'ever-running' farm script?

05

Lists

Lists are like numbered shelves that can store multiple pieces of data.

python
crops = ["Carrot", "Pumpkin", "Sunflower"]

# Access the first element (counting starts from 0!)
print(crops[0])  # Output: Carrot

# Add a new element
crops.append("Cactus")

? If `my_list = [10, 20, 30]`, what is the value of `my_list[1]`?

🚀 Essential Knowledge Before Playing

Coding Core

  • ✓ Variables: Store and modify data
  • ✓ Logic: Understand how if/else changes flow
  • ✓ Loops: Especially persistent operations like while True

Game Tips

  • ✓ Functions: Learn to use built-in functions like harvest() and move()
  • ✓ Indentation: Program will error if leading spaces are wrong
  • ✓ Debugging: Understand error messages in the console

Ready to start your farm automation journey?

Questions or tips? Join the discussion below!