← Submit an app or mod
Download the starter appDownload API.mdDownload all how-tos
Where your files goGetting the API from your modPhone appsMoneyLifemailAI and Lifestyle LinkSettingsBodyTattoosDaily needsPetsPet messMenuPhone contactsEventsFun

Lifestyle – the CPAPI reference (version 1)

Everything in Lifestyle runs through one Lua table, CPAPI: the phone (your own apps and contacts), settings, daily needs, money, Lifemail, AI, body sliders, tattoos, pets and the menu. The mod's own screens use these same functions, so a change made from your mod shows up everywhere.

Where your files go

Your mod is a normal FS25 mod folder (or the same thing zipped) in your mods folder:

Documents\My Games\FarmingSimulator2025\mods\
    HS25_Lifestyle_Mod.zip        <- Lifestyle (or its unzipped folder)
    FS25_MyPhoneApp\              <- your mod, while you work on it
        modDesc.xml               <- the game reads this first: name, version, which scripts to load
        icon_myApp.dds            <- the mod's icon (256 x 256), also used as the phone app icon
        scripts\
            MyPhoneApp.lua        <- your code (listed in modDesc.xml under <extraSourceFiles>)
        textures\                 <- optional: your own pictures (.dds)

Getting the API from your mod

local api = CPAPI or (HS25_Lifestyle_Mod ~= nil and HS25_Lifestyle_Mod.CPAPI) or nil
if api ~= nil and api.VERSION >= 1 then
    -- use it
end

Call it after the map has loaded, for example from your mod's loadMap or later (each mod has its own Lua environment; Lifestyle puts CPAPI where yours can see it). In every function that takes a character key, key = nil means the character being edited in the wardrobe, or your own player when the wardrobe is closed.

Phone apps

FunctionWhat it does
api.phone.addApp(def)Put your app on the phone's Home Screen (see below). Returns true when it was added.
api.phone.open(view) / api.phone.close() / api.phone.isOpen()Open the phone (optionally on an app's view), close it, or check it.
api.phone.notify(title, body)A banner on the phone (a toast when it's closed) with the message sound.
api.phone.message(text, kind)A line in the phone's system messages. kind: "info", "ok", "critical".
api.phone.design()Returns CPDesign, CPUI: the phone's own drawing kit (below), so your app looks like the rest of the phone.
api.phone.addApp({
    id    = "myPhoneApp",                       -- unique, letters / numbers / _ only
    title = "My App",                           -- the name under the icon (or a l10n key)
    icon  = modDir .. "icon_myApp.dds",         -- a .dds path, or the name of a phone icon like "uiL_star"
    color = { 0.20, 0.55, 0.90 },               -- the icon's tile colour
    draw  = function(phone, x, y, w, h) end,    -- runs every frame while your app is open (inside the phone screen)
    -- launch = function() end,                 -- instead of draw: your app opens its own screen
    badge = function() return nil end,          -- a number or "!" = a red dot on the icon
})

Drawing inside the phone. x, y, w, h is the app's area in screen units (0..1, y goes up). phone:hit(x, y, w, h, fn) makes a box clickable (it returns true while the mouse is over it). With the design kit:

local D, UI = api.phone.design()
local c = D.c()                                                  -- the current colours: c.text, c.sub, c.surface, c.raised ...
D.text(x, y + h - UI.py(30), UI.py(18), "Hello", c.text, 1, RenderText.ALIGN_LEFT, true)       -- (x, y, size, text, colour, alpha, align, bold, maxWidth)
D.row(phone, x, y + h - UI.py(90), w, UI.py(46), { title = "A row", sub = "with a line under it", chevron = true, part = "single", fn = function() end })
D.button(phone, x, y, w, UI.py(44), "Do it", "primary", function() end)                       -- kinds: primary, plain, tinted, danger
UI.box(x, y, w, h, 1, 1, 1, 0.1, UI.px(12))                                                    -- a rounded box (x, y, w, h, r, g, b, a, radius)

UI.px(n) / UI.py(n) turn pixels of a 1920 x 1080 screen into screen units, so your app looks the same on every monitor.

Money

FunctionWhat it does
api.money.get()The player's farm money.
api.money.canAfford(amount)Whether the farm has that much.
api.money.charge(amount)Take money off the farm account (in multiplayer the host checks and takes it). Returns true when it went.
api.money.pay(amount)Pay money to the farm. Host / single player only (a client can't make money); returns false otherwise.

Lifemail

FunctionWhat it does
api.mail.send({ from, fromAddr, subject, body, quiet })Put a mail in the player's in-game inbox (works offline). quiet = true = no banner.

AI and Lifestyle Link

FunctionWhat it does
api.ai.ready()Whether an AI answer is possible right now (Lifestyle Link signed in, AI on).
api.ai.isOff(key)Whether the player switched an AI feature off in Settings > AI ("neighbours", "family", "pet", "farmer", "advisor", "dispatch"...). Check this before your own AI feature, and add nothing if they turned AI off.
api.ai.ask(question, persona, function(answer, err) end)Ask the AI as your character (persona = who they are and how they talk). Counts against the player's daily AI answers. Keep it 13+.
api.link.online()Whether Lifestyle Link is signed in (online features work).

Settings

FunctionWhat it does
api.settings.get(id) / api.settings.set(id, value)Read or change a setting. The change saves straight away.
api.settings.list()Every setting: { id, section, sectionTitle, type, value, default, values, texts, label, tooltip }.
api.settings.add(sectionId, def, sectionTitle)Add your own setting to the menu. def = { id, type = "bool" | "choice", default, values = {...}, texts = {...}, label, tooltip, onChange = function(v) end }. A saved value is restored automatically.

Body

FunctionWhat it does
api.body.sections()The slider groups, each with its sliders: { id, label, min, max, step, values, texts }.
api.body.get(key, sliderId) / api.body.set(key, sliderId, value)Read or change one slider. The value is a multiplier (1 = normal) and is clamped to the slider's range.
api.body.getAll(key) / api.body.setAll(key, { height = 1.03, ... })Read or change every slider at once.
api.body.reset(key)Set every slider back to normal.
api.body.currentKey()The key of the character being edited or worn.

Slider ids: height, weight, muscle, headSize, neckLength, neckThick, shoulders, chest, chestWidth, belly, waist, hips, butt, upperArms, forearms, armLength, hands, thighs, calves, feet.

Tattoos

FunctionWhat it does
api.tattoos.slots(key)The spots this character has: { id, zone, zoneTitle, title, list }.
api.tattoos.designs(slotId)The designs that fit a spot: { id, name, icon }.
api.tattoos.get(key, slotId)The id of the design on that spot, or nil.
api.tattoos.set(key, slotId, design)Put a design on a spot. design is an id, a list number, or nil / "none" to remove it. Covering one area clears whatever else was there, e.g. a full sleeve replaces the upper arm and forearm pieces.
api.tattoos.getAll(key) / api.tattoos.clear(key)Read every spot, or remove every tattoo.
api.tattoos.registerDesign(list, def)Add your own artwork while the game runs (see below).

Spots:

ZoneSpots
Headforehead, leftCheek, rightCheek, leftTeardrop, rightTeardrop, leftNeck, rightNeck
Torsochest, back
ArmsleftSleeve, leftUpperArm, leftForearm, rightSleeve, rightUpperArm, rightForearm
HandsleftHand, rightHand, leftKnuckles, rightKnuckles
LegsleftThigh, rightThigh, leftCalf, rightCalf

Face spots are on the mod's own characters only. Leg spots are on the base game characters only.

Lists: normal (the regular designs), small (face and neck: tiny designs plus the regular ones), tiny, sleeve and knuckles (4 letters, one per finger).

Your own design:

api.tattoos.registerDesign("normal", {
    id = "myDragon",                                  -- must be unique
    texture = g_currentModDirectory .. "dragon.dds",  -- RGBA, transparent background, square (sleeve: 512x1024 and wraps sideways)
    icon = g_currentModDirectory .. "dragon_icon.dds",-- optional, 256x256
    name = "Dragon",
})

A saved choice of a custom design comes back as soon as the design is registered again.

Daily needs

Food (hunger), water (thirst) and energy (energy), each from 0 to 100. They go down with in-game time, faster while running and thirst faster above 25 °C. Sleeping in the game's bed brings energy back. Meals, water and coffee are free near a farmhouse your farm owns; anywhere else they are bought with farm money. The HUD and the menu read everything through these functions, so a need you register gets its own HUD row and menu line.

FunctionWhat it does
api.needs.isEnabled()Whether daily needs are switched on.
api.needs.list()Every need: { id, label, icon, value, low, critical }.
api.needs.get(id) / api.needs.set(id, value) / api.needs.add(id, delta)Read, set or change a need. Values are clamped to 0–100.
api.needs.reset()Fill every need.
api.needs.eat() / api.needs.drink() / api.needs.coffee()The same as the keys and menu buttons: free at home, bought away from home. Return ok, message.
api.needs.offer(kind)What "eat", "drink" or "coffee" would give right now: { id, label, price, effects, home }.
api.needs.consume(def, quiet)Your own food or drink: { label = "Sandwich", effects = { hunger = 30 }, price = 8 }. The price comes off the farm account.
api.needs.isHome() / api.needs.isSleeping()Whether you are near your farmhouse, or asleep.
api.needs.register(def)Add your own need: { id, label, icon = "<white-on-transparent .dds>", perHour = 4, sleepPerHour = -1, run = 1.2, heat = 1, lowText, criticalText }.

Keys: Left Alt + B eats, Left Alt + V drinks. They show in the key help only when that need is below 40. The Settings page has a Cheat menu switch; while it is on, a section appears for setting each need, freezing needs, free food, and pet helpers.

Pets

FunctionWhat it does
api.pets.list() / api.pets.get(idOrName)Your pets: { id, name, species, breed, gender, mode, hunger, mood, bond, ageDays, out, personality, followDist, size, nightHome, autoFeed, mapIcon, alerts, x, y, z, distance }.
api.pets.breeds()Every pet type you can adopt: { key, name, species }.
api.pets.canAdopt() / api.pets.max()Whether there is room for another pet, and the limit.
api.pets.adopt({ name, breed, species, gender = "m"|"f", personality, size, followDist })Adopt a pet. Returns the new pet's id, or nil. Host only.
api.pets.release(id) / api.pets.rename(id, name) / api.pets.setBreed(id, breedKey)Release, rename or change the coat of a pet.
api.pets.setOption(id, option, value)Change one setting. Options: personality, followDist (1–4), size (1–4), nightHome, autoFeed, mapIcon, alerts.
api.pets.command(id, cmd)Give an order. Commands: follow, stay, come, home, setHome, feed, pet, fetch.
api.pets.whistle()Call your pets.

Pet mess

FunctionWhat it does
api.poop.count()How many piles are lying around.
api.poop.drop(kind, x, y, z, scale)Drop a pile. kind is "dog", "cat" or "kangaroo".
api.poop.cleanAround(x, z, radius)Clean up near a spot. Returns how many piles were removed.
api.poop.clearAll()Clean up every pile.

Menu

FunctionWhat it does
api.menu.open(page) / api.menu.close() / api.menu.isOpen()Open, close or check the menu. Pages: "settings", "needs", "body", "tattoos", "pets", "help", or your own.
api.menu.addPage(def)Add your own tab (it goes before Help). See the example below.
api.menu.addPage({
    id = "myPage", title = "My stuff",
    info = function(menu, state) return "Shown under the page title" end,
    action = { text = "Do it", fn = function(menu) end },        -- the bottom-bar button (controller: X / Y)
    build = function(menu, rows, state)
        rows:header("Section")
        rows:choice("Label", "Tooltip", { "Off", "On" }, function() return 1 end, function(i) end)
        rows:slider("Amount", "", { "0", "1", "2" }, function() return 2 end, function(i) end)
        rows:buttons({ { text = "Button", fn = function() end } })
        -- menu:rebuild() rebuilds the page on the next frame
    end,
    refresh = function(menu, rows, state) end,               -- runs when something changes
    live = false,                                            -- true = refresh every second while the page is open
})

Phone contacts

Your mod can add its own people to the phone's Contacts, with a Messages conversation. You decide what they say. The player texts back and your function answers.

FunctionWhat it does
api.contacts.add(def)Add a contact (see below). Returns false if the id is missing or another contact already uses that name.
api.contacts.text(id, body)A text from them, any time (the phone's normal text alert).
api.contacts.reply(id, body, delayMs)An answer with the typing dots first (default 1.5 s).
api.contacts.remove(id) / api.contacts.list()Remove one, or get { {id, name, role}, ... }.
api.contacts.add({
    id = "dale", name = "Dale", role = "Feed store",
    onMessage = function(text, photo)        -- the player texted them (photo = true if they sent a picture)
        if text:lower():find("feed") then return "20 bags on the way!" end   -- a string = the reply
        return nil                                                           -- nil = no reply now
    end,
    onCall = function() end,                 -- optional: what tapping Call does
})

Names must be unique on the phone. The phone's own AI never answers for your contacts. An error inside onMessage is written to the log and doesn't break the phone.

Events

local handle = api.on(eventName, function(...) end) adds a listener and api.off(handle) removes it.

EventArguments
settingChangedid, value
bodyChangedkey, sliderId, value
bodyResetkey
tattooChangedkey, slotId, designId (designId is nil when removed)
tattoosClearedkey
designRegisteredlist, id
petAdoptedpet
petReleasedpet
petChangedpet, what
petCommandpet, command
poopDroppedkind, x, y, z
steppedInPoopnone
menuOpenedpageId
menuClosednone
needChangedid, value, old, reason ("time", "sleep", "consume", "api", "reset")
needLowid, "low" | "critical"
consumeditemId, effects, price
needsReset / needsLoadednone
needRegisteredid
sleepStartednone
sleepEndedenergy

Listeners run in protected calls, so an error in one listener never breaks the mod.

Fun

FunctionWhat it does
api.hashy.play(which)A Hashy screen effect: "disco", "dvd", "hype", "chill", "rain" (nil = random).