api
The one interface a game uses: `local Friends = require("~friendshipKit.api")`. Setup on every peer, talk and gift for the local player, levels and points (also of other players), birthdays and the calendar, tastes, events (talk, gift, levelUp, levelDown, birthday, newDay, change…
friendshipKit.api
The one interface a game uses: local Friends = require("~friendshipKit.api"). Setup on every peer, talk and gift for the local player, levels and points (also of other players), birthdays and the calendar, tastes, events (talk, gift, levelUp, levelDown, birthday, newDay, change), the catalogue of displays, looks, boxes, emotes and rule presets, per-player saving, and the calls that open the friendship screens. The package README lists every call.
Interface
What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.
conforms to
zero/source-extract/v2nonstrict
allowedControl(code: string) → boolean
Whether friendshipKit may bind this key or pad button itself (false for KeyE, Digit keys, d-pad left/right and the pad's west button).
| arg | type | description |
|---|---|---|
| code | string |
controls( ) → any return table
The keys and pad buttons the HUD reads: { talk, gift, social, back (web key codes), padTalk, padGift, padSocial, padBack (pad button names) }.
setControls(c: any) → any
Change some of the keys and pad buttons (setup's `controls` does the same): setControls({ gift = "KeyR", padGift = "dpad_up" }).
| arg | type | description |
|---|---|---|
| c | any |
on(event: string, fn: (any) → void
Listen to "talk", "gift", "levelUp", "levelDown", "birthday", "newDay" or "change". fn(ev). Returns a function that stops listening.
| arg | type | description |
|---|---|---|
| event | string | |
| fn | (any |
emit(event: string, ev: any) → void
| arg | type | description |
|---|---|---|
| event | string | |
| ev | any |
inPlay( ) → boolean return engine
ownDate( ) → any
date( ) → any
Today: { season, day, year, dayIndex }. From setup's dateSource, else worldClockKit's clock (when handed over), else the kit's own day counter.
today( ) → number return M
seasonLabel(s: string) → string
| arg | type | description |
|---|---|---|
| s | string |
formatDate(d: any?, withYear: boolean?) → string
A date as words: "Spring 14" (with the year when `withYear`).
| arg | type | description |
|---|---|---|
| d | any? | |
| withYear | boolean? |
store( ) → any
fresh( ) → any
adopt(saved: any) → boolean
| arg | type | description |
|---|---|---|
| saved | any |
load( ) → void
data( ) → any
save(now: boolean?) → void
| arg | type | description |
|---|---|---|
| now | boolean? |
flush( ) → boolean
Write the local player's friendship now (the HUD also writes it a moment after any change).
rec(id: string) → any
| arg | type | description |
|---|---|---|
| id | string |
rules( ) → any return S
ppl( ) → number return rules
maxLevel( ) → number return rules
maxPoints( ) → number return ppl
levelOf(points: number) → number
| arg | type | description |
|---|---|---|
| points | number |
readOther(playerId: any) → any
| arg | type | description |
|---|---|---|
| playerId | any |
isLocal(playerId: any) → boolean
| arg | type | description |
|---|---|---|
| playerId | any |
need(id: string) → any
| arg | type | description |
|---|---|---|
| id | string |
defineVillager(def: any) → any
Add or replace a villager from code, with the same fields as a villager data asset. Returns the clean villager.
| arg | type | description |
|---|---|---|
| def | any |
villagers( ) → void
Every villager, as clean tables (sorted by name, code definitions last).
villager(id: string) → any
One villager by id, or nil.
| arg | type | description |
|---|---|---|
| id | string |
reloadVillagers( ) → number return Villagers
Re-read the villager data assets.
items( ) → any return Bridges
defineItem(id: string, def: any) → void
Name, tags and emoji for an item no inventory describes: defineItem("sunflower", { name = "Sunflower", tags = { "flower" }, emoji = "🌻" }).
| arg | type | description |
|---|---|---|
| id | string | |
| def | any |
itemName(id: string) → string
The item's name: the items source's, else defineItem's, else the id made readable.
| arg | type | description |
|---|---|---|
| id | string |
itemTags(id: string) → void
The item's tags (items source first, then defineItem).
| arg | type | description |
|---|---|---|
| id | string |
itemEmoji(id: string) → string
The item's emoji for the gift picker (defineItem's, else a gift box).
| arg | type | description |
|---|---|---|
| id | string |
itemCount(id: string) → number
How many of an item the local player has, from the items source.
| arg | type | description |
|---|---|---|
| id | string |
giveItem(id: string, n: number?) → boolean
Give the local player items in the kit's own bag (or the items source, when it can give). For worlds without an inventory, and for tests.
| arg | type | description |
|---|---|---|
| id | string | |
| n | number? |
giftableItems(villagerId: string?) → void
What the local player could give right now: { { id, name, count, emoji, known = taste? } } for the villager (known = a taste this player has already seen).
| arg | type | description |
|---|---|---|
| villagerId | string? |
uniSet(listName: string) → any
| arg | type | description |
|---|---|---|
| listName | string |
setUniversal(u: any) → void
Set the universal tastes every villager shares (their own lists win): { loves = { items, tags }, likes, dislikes, hates }.
| arg | type | description |
|---|---|---|
| u | any |
universal( ) → any return table
The universal tastes now in use.
tasteOf(villagerId: string, itemId: string) → string
How a villager feels about an item: "love", "like", "neutral", "dislike" or "hate". Their own item lists win, then universal items, then their tag lists, then universal tags.
| arg | type | description |
|---|---|---|
| villagerId | string | |
| itemId | string |
points(villagerId: string, playerId: any?) → number
Friendship points with a villager (the local player's, or another player's by their player id).
| arg | type | description |
|---|---|---|
| villagerId | string | |
| playerId | any? |
level(villagerId: string, playerId: any?) → number
Friendship level (hearts) with a villager, 0..maxLevel.
| arg | type | description |
|---|---|---|
| villagerId | string | |
| playerId | any? |
progress(villagerId: string, playerId: any?) → number
Progress into the next level, 0..1 (0 at the top level).
| arg | type | description |
|---|---|---|
| villagerId | string | |
| playerId | any? |
talkedToday(villagerId: string) → boolean
Whether the local player chatted with the villager today.
| arg | type | description |
|---|---|---|
| villagerId | string |
giftsToday(villagerId: string) → number
How many gifts the villager took from the local player today.
| arg | type | description |
|---|---|---|
| villagerId | string |
giftedToday(villagerId: string) → boolean return M
Whether the local player gave the villager a gift today.
| arg | type | description |
|---|---|---|
| villagerId | string |
weekOf(dayIndex: number) → number return
| arg | type | description |
|---|---|---|
| dayIndex | number |
giftsLeft(villagerId: string) → number
Gifts the villager will still take today from the local player (math.huge when there is no limit).
| arg | type | description |
|---|---|---|
| villagerId | string |
knownTastes(villagerId: string) → void
Every taste the local player has learned for a villager: { [itemId] = taste }.
| arg | type | description |
|---|---|---|
| villagerId | string |
isBirthday(villagerId: string, date: any?) → boolean
Whether today (or `date`) is the villager's birthday.
| arg | type | description |
|---|---|---|
| villagerId | string | |
| date | any? |
birthdaysOn(season: string, day: number) → void
The villagers whose birthday falls on a season and day.
| arg | type | description |
|---|---|---|
| season | string | |
| day | number |
birthdays( ) → void
Every birthday for a calendar, in calendar order: { { villagerId, displayName, season, day, emoji, color, isToday } }.
playerName( ) → string
pick(list: { string }?, fallback: string) → string
| arg | type | description |
|---|---|---|
| list | { string }? | |
| fallback | string |
fill(line: string, v: any, itemId: string?) → string
| arg | type | description |
|---|---|---|
| line | string | |
| v | any | |
| itemId | string? |
greetingFor(v: any, level: number) → string
| arg | type | description |
|---|---|---|
| v | any | |
| level | number |
greeting(villagerId: string) → string
The line the villager would greet the local player with at their level (no points change).
| arg | type | description |
|---|---|---|
| villagerId | string |
setPoints(villagerId: string, value: number, reason: string, extra: any?) → void
| arg | type | description |
|---|---|---|
| villagerId | string | |
| value | number | |
| reason | string | |
| extra | any? |
addPoints(villagerId: string, n: number) → void
Add (or take, with a negative number) friendship points for the local player, for quests, events and cutscenes. Returns the change and the new level.
| arg | type | description |
|---|---|---|
| villagerId | string | |
| n | number |
setPoints(villagerId: string, n: number) → void
Set the local player's friendship points with a villager.
| arg | type | description |
|---|---|---|
| villagerId | string | |
| n | number |
setLevel(villagerId: string, level: number) → void
Set the local player's level with a villager (points at the start of that level).
| arg | type | description |
|---|---|---|
| villagerId | string | |
| level | number |
talk(villagerId: string) → void
The local player chats with a villager. The first chat of an in-game day gives the talk points. Returns the line to show, and { points, first, birthday, level, levelUp }.
| arg | type | description |
|---|---|---|
| villagerId | string |
gift(villagerId: string, itemId: string) → any
The local player gives a villager an item from the items source. Returns { ok, reason?, taste, points, line, birthday, level, levelUp, itemId }. Refused (nothing taken) when the player has none or the villager has had enough gifts.
| arg | type | description |
|---|---|---|
| villagerId | string | |
| itemId | string |
fireBirthdays(d: any) → void
| arg | type | description |
|---|---|---|
| d | any |
checkDay( ) → void
_checkDay( ) → void
newDay( ) → any
A new day began. With the kit's own day counter this moves to the next day for everyone; with a clock or dateSource it settles the day change now (decay for villagers not talked to, daily gift limits, birthday events). Returns today's date.
setDate(season: string, day: number, year: number?) → void
Jump the kit's own day counter to a season and day (showcases, tests). Ignored when a clock or dateSource decides the date.
| arg | type | description |
|---|---|---|
| season | string | |
| day | number | |
| year | number? |
reset(villagerId: string?) → void
Forget the local player's friendship with every villager (or one).
| arg | type | description |
|---|---|---|
| villagerId | string? |
villager_mira( ) → void
villager_bram( ) → void
villager_juniper( ) → void
villager_finn( ) → void
villager_odette( ) → void
villager_pip( ) → void
villager_wren( ) → void
villager_marlow( ) → void
setModel(villagerId: string, ref: any) → void
Draw a villager with a bundle of your own (an AssetRef your code resolved): setModel("rosa", asset.resolve("art.rosa", "bundle")).
| arg | type | description |
|---|---|---|
| villagerId | string | |
| ref | any |
modelOf(villagerId: string) → any
The bundle a villager is drawn with: one set with setModel, else the kit model its `model` field names ("villager_mira"), else the kit's `villager_<id>`. nil when there is none.
| arg | type | description |
|---|---|---|
| villagerId | string |
spawnVillager(villagerId: string, o: any?) → any
Place a villager in the scene (a scene's build.luau or play): an entity with the villager's model, a collider and the Villager component. opts: { name, parent, position = {x,y,z}, yaw (degrees), scale, model (a bundle AssetRef), range, headHeight, collider (true), prompt }. Returns the entity.
| arg | type | description |
|---|---|---|
| villagerId | string | |
| o | any? |
setup(opts: any?) → any
Configure the kit on every peer. opts: { display, look, box, emote, conversation, rules = "relaxed" | "classic" | "hard" | { base, ... }, pointsPerLevel, maxLevel, daysPerSeason, dateSource = fn, items = { count, take, give?, list?, name?, tags? }, kits = { modules }, universal, overhead, overheadRange, hud, touchButtons, insets, controls, buttonPosition = "top-right" | "top-left" | "bottom-right" | "bottom-left", playerName }. Returns the settings now in use.
| arg | type | description |
|---|---|---|
| opts | any? |
config( ) → any
The settings now in use (a copy).
setter(key: string, valid: (any) → void
| arg | type | description |
|---|---|---|
| key | string | |
| valid | (any |
setRules(spec: any) → any
Switch the rules to a preset name or a table ({ base = "classic", love = 100, ... }). Points stay, levels follow the new pointsPerLevel.
| arg | type | description |
|---|---|---|
| spec | any |
display( ) → string return S
look( ) → string return S
box( ) → string return S
emote( ) → string return S
rules( ) → any return table
pointsPerLevel( ) → number return ppl
maxLevel( ) → number return maxLevel
catalogue( ) → any
Everything a game can choose from: { displays, looks, boxes, emotes, rules (presets), conversations, villagers, version } with a line about each.
described(list: ?, info: ?) → void
| arg | type | description |
|---|---|---|
| list | ? | |
| info | ? |
meter(villagerId: string, o: any?) → any
The meter as a UI node in the chosen (or given) display and look, for a game's own screens: meter(villagerId, { size, compact, display, look }).
| arg | type | description |
|---|---|---|
| villagerId | string | |
| o | any? |
ui( ) → any
openConversation(villagerId: string) → boolean
Open the conversation with a villager for the local player, as pressing Talk does (talks, then offers a gift).
| arg | type | description |
|---|---|---|
| villagerId | string |
openGifts(villagerId: string) → boolean
Open the gift picker for a villager.
| arg | type | description |
|---|---|---|
| villagerId | string |
openSocial(open: boolean?) → boolean
Open, close or toggle (nil) the Social panel.
| arg | type | description |
|---|---|---|
| open | boolean? |
closeUI( ) → void
Close any friendship screen that is open.
react(villagerId: string, kind: string) → void
Show a reaction emote over a villager on this screen: "heart", "smile", "neutral", "frown", "angry", "note", "cake".
| arg | type | description |
|---|---|---|
| villagerId | string | |
| kind | string |
_registerEntity(entityId: string, comp: any) → void
| arg | type | description |
|---|---|---|
| entityId | string | |
| comp | any |
_unregisterEntity(entityId: string, comp: any) → void
| arg | type | description |
|---|---|---|
| entityId | string | |
| comp | any |
villagerEntities( ) → void
Every Villager entity in the scene: { { entityId, villagerId } }.
toast(text: string, kind: string?) → void
Show a short message on the local player's screen in the kit's look: kind "good", "bad", "level" or "info".
| arg | type | description |
|---|---|---|
| text | string | |
| kind | string? |
_setUi(handler: any) → void
| arg | type | description |
|---|---|---|
| handler | any |
component(name: string) → any
friendshipKit's component type by short name ("Villager", "FriendshipSettings", "FriendshipHUD"), for e.component.add(Friends.component("Villager"), { villagerId = "mira" }).
| arg | type | description |
|---|---|---|
| name | string |
_ensureHud( ) → void
Make sure this peer's friendship HUD exists in play (a Villager calls it for you).
_tick(dt: number) → void
The HUD's tick: settles day changes and writes the save a moment after a change.
| arg | type | description |
|---|---|---|
| dt | number |
Sub-parts
Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.
Showing up to 3 levels deep. Open a part to see what it holds further down.
Problems
Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.
agent_score is exposed.+ quality × 0.35
+ performance × 0.25
± compat factor
Usability ratings
Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".
Scoped to this part · feeds back into the world's score.