Lucy Was Replaced
Replace The Farmer Was Replaced's Python editor with the Gleam language.
模組介紹 作者原文
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\
安裝與使用 安裝:按包內說明操作
- 解壓本站下載的壓縮包,先讀包內的 readme / 說明檔案。
- 多數模組依賴遊戲的模組載入器:常見做法是用社群模組管理器(如 r2modman)選中本遊戲安裝,由管理器自動處理載入器與依賴。
- 手動安裝時,把模組檔案放進遊戲目錄下對應的 Mod / plugins 資料夾。
- 啟動遊戲確認載入成功;帶「前置依賴」的模組需要把依賴一併安裝。
不同模組的安裝位置差異較大,包內說明是最可靠的依據。
下面這些內容需要先安裝,否則該模組不會生效: