Lucy Was Replaced
Replace The Farmer Was Replaced's Python editor with the Gleam language.
About this mod Author’s original text
Lucy was Replaced
Play The Farmer Was Replaced with the Gleam programming language
(gleam.run) instead of the game's built-in Python.
What is Gleam?
Gleam is a programming language — the friendly kind. Where the game normally has you
write Python, this mod lets you program your farm in Gleam instead. It's built for
people who'd rather spend their time farming than fighting syntax:
- Fewer surprises: Gleam checks your code before it runs, so you catch mistakes early.
- Easy to read: little syntax and one way to do things means code reads the same everywhere.
- Beginner friendly: if you can follow a recipe, you can write a Gleam program.
Gleam is free and open source, and the official site has an interactive tour that
teaches the basics in a few minutes: gleam.run.
New to Gleam? The mod has a quick primer built in — open the docs window in the game
and look under Gleam Programming.
What can you do with it?
- Automate your farm just like with Python: move, till, plant, and harvest.
- Use the whole game toolkit: sensors, items, unlocks, and the occasional flip.
- Run several drones at once to work the farm faster.
- Split your code across windows and reuse it like building blocks.
- Edit with an external editor: your code windows are mirrored to a real Gleam
project on disk, so you get full autocomplete, hover, and error checking from the
Gleam language server. See Editing from an external editor.
- Watch your program run: the editor highlights the line executing right now, and
the step-by-step button walks through your code one line at a time when you want to
really read it.
Examples
A first program might look like this:
import game
pub fn main() {
game.harvest()
game.do_a_flip()
main()
}...but a few minutes in you might end up with this:
// utils.gleam
import game
import gleam/list
pub fn visit_all(size: Int, do_work) {
use _ Nil) {
do_work()
repeat(do_work)
}
pub fn try_harvest_with(func: fn() -> Bool) {
case game.can_harvest() {
True -> {
game.harvest()
func()
}
_ -> False
}
}
pub fn try_harvest() {
try_harvest_with(fn() { True })
}
//farm_carrots.gleam
import game
import utils
pub fn main() {
utils.visit_all(3, fn() {
game.till()
game.plant(game.Carrot)
})
use /gleam-project/
├── gleam.toml # target = "javascript", pins gleam_stdlib
├── manifest.toml # dependency lock (same version the mod embeds)
└── src/
├── main.gleam # one.gleam per code window (window name = module name)
├── utils.gleam
├── game.gleam # LSP stub of the game API (read-only)
├── game/item.gleam
└── game_ffi.mjs # external glue for the stub
The mod creates this folder automatically on first Run. The game only watches
top-level.py files, so the gleam-project subfolder is left alone.
How it stays in sync:
- In-game edits are written to the project on Run and on every game save.
- External edits are picked up by a file watcher and pushed into the open
code window.
- Created/deleted/renamed files create, close, or rename the matching code
window (and closing or renaming a window updates the project).
- Compiling reads the project, so what the editor shows and what the game
runs are the same bytes.
Where are the saves?
The game stores each save in its own folder under /Saves, one
per in-game save name (e.g. Save0, Gleam). The Gleam project the mod creates
lives in the save folder: /gleam-project.
| OS | Save folder |
|---|---|
| Windows | %USERPROFILE%\AppData\LocalLow\TheFarmerWasReplaced\TheFarmerWasReplaced\Saves |
| macOS | ~/Library/Application Support/com.TheFarmerWasReplaced.TheFarmerWasReplaced/Saves |
| Linux (Proton) | ~/.local/share/Steam/steamapps/compatdata/2060160/pfx/drive_c/users/steamuser/AppData/LocalLow/TheFarmerWasReplaced/TheFarmerWasReplaced/Saves |
So on Windows your main window's project would be at:
%USERPROFILE%\AppData\LocalLow\TheFarmerWasReplaced\TheFarmerWasReplaced\Saves\Save0\gleam-project\
Install & use Install: follow the bundled instructions
- Unzip the archive from playbuff and read the bundled readme / instructions first.
- Most mods rely on the game's mod loader — the usual route is a community mod manager (such as r2modman): pick this game, install, and it handles the loader and dependencies.
- For a manual install, put the mod files into the matching Mod / plugins folder inside the game directory.
- Launch the game to confirm it loaded; mods with listed dependencies need those installed as well.
Install locations vary a lot between mods — the bundled readme is the most reliable guide.
Install these first, or the mod will not work: