Rowan the carpenter and Ivy the mason live on the Green, and villages grow up far from it as you explore, built to suit the land: a street, a well and a house for each villager. Thirteen jobs trade with you: sell them what you've gathered for beads and spend beads on what they make, and the better they know you the more they show you. A peddler and his pack yak come by now and then.
| 1 | --!strict |
| 2 | -- What every job trades, and what the peddler carries. A trade is what a |
| 3 | -- villager wants for what they give: `n` of `give` for everything in |
| 4 | -- `want`. Beads are what villages pay in: sell them what you've gathered |
| 5 | -- for beads, and spend beads on what they make. |
| 6 | -- |
| 7 | -- `tier` is how well they must know you: 1 at once, 2 once you're a |
| 8 | -- regular and 3 once you're a friend (TRUST in main.luau). `stock` is how |
| 9 | -- many times a day they'll do it (8 if left out). Anything that names a |
| 10 | -- block or item from another creation (rails, brews, beehives) only shows |
| 11 | -- when that creation is in the world. |
| 12 | -- |
| 13 | -- Nothing here may be bought back for less than it sells for, or beads |
| 14 | -- would grow on trees: main.luau checks, and says so in its log. |
| 15 | |
| 16 | export type Trade = { |
| 17 | tier: number, |
| 18 | want: { [string]: number }, |
| 19 | give: string, |
| 20 | n: number, |
| 21 | stock: number?, |
| 22 | -- a service rather than a thing: "way" tells you where the next village is |
| 23 | does: string?, |
| 24 | -- what a service is called on its button |
| 25 | label: string?, |
| 26 | } |
| 27 | |
| 28 | export type Job = { |
| 29 | -- a villager's work, said in a sentence: "the baker" |
| 30 | title: string, |
| 31 | -- what stands by their door (the first that's in the world), and what |
| 32 | -- goes on top of it |
| 33 | station: { string }, |
| 34 | on_top: string?, |
| 35 | -- what goes inside their house: two by the back wall, one by the bed |
| 36 | -- (a table gets a candle on it) and one by the door |
| 37 | inside: { string }, |
| 38 | trades: { Trade }, |
| 39 | -- what they say now and then |
| 40 | lines: { string }, |
| 41 | -- what they say while they work |
| 42 | work: { string }, |
| 43 | } |
| 44 | |
| 45 | local BEADS = "Beads" |
| 46 | |
| 47 | local function sell(tier: number, what: string, k: number, beads: number?, stock: number?): Trade |
| 48 | return { tier = tier, want = { [what] = k }, give = BEADS, n = beads or 1, stock = stock } |
| 49 | end |
| 50 | |
| 51 | local function buy(tier: number, beads: number, what: string, n: number, stock: number?): Trade |
| 52 | return { tier = tier, want = { [BEADS] = beads }, give = what, n = n, stock = stock } |
| 53 | end |
| 54 | |
| 55 | local function swap(tier: number, want: { [string]: number }, what: string, n: number, stock: number?): Trade |
| 56 | return { tier = tier, want = want, give = what, n = n, stock = stock or 16 } |
| 57 | end |
| 58 | |
| 59 | local JOBS: { [string]: Job } = { |
| 60 | Carpenter = { |
| 61 | title = "the carpenter", |
| 62 | station = { "Table" }, |
| 63 | inside = { "Crate", "Stool", "Table", "Barrel" }, |
| 64 | trades = { |
| 65 | swap(1, { ["Oak log"] = 1 }, "Planks", 4), |
| 66 | sell(1, "Oak log", 8), |
| 67 | swap(1, { Planks = 3 }, "Fence", 2), |
| 68 | swap(1, { Planks = 4 }, "Crate", 1), |
| 69 | sell(2, "Birch log", 8), |
| 70 | swap(2, { Planks = 6 }, "Table", 1), |
| 71 | buy(2, 2, "Bookshelf", 1), |
| 72 | buy(3, 2, "Barrel", 1), |
| 73 | }, |
| 74 | lines = { "Mind the sawdust.", "Fresh planks today!", "Bring me a log or two." }, |
| 75 | work = { "Measure twice, cut once.", "Nearly square. Nearly.", "This one's for a cradle." }, |
| 76 | }, |
| 77 | Mason = { |
| 78 | title = "the mason", |
| 79 | station = { "Column" }, |
| 80 | inside = { "Barrel", "Lantern", "Table", "Stone bricks" }, |
| 81 | trades = { |
| 82 | swap(1, { Sand = 3 }, "Glass", 2), |
| 83 | swap(1, { Sandstone = 4 }, "Sandstone bricks", 4), |
| 84 | sell(1, "Cobblestone", 16), |
| 85 | swap(2, { Glass = 1, Stone = 2 }, "Lantern", 1), |
| 86 | swap(2, { Cobblestone = 4 }, "Brazier", 1), |
| 87 | buy(2, 1, "Mossy brick", 4), |
| 88 | buy(3, 1, "Column", 2), |
| 89 | buy(3, 1, "Slate", 8), |
| 90 | }, |
| 91 | lines = { "Sand into glass, stone into light.", "Lovely day for a lantern.", "Got any sand?" }, |
| 92 | work = { "Tap, tap, there.", "Good stone sings.", "Square and true." }, |
| 93 | }, |
| 94 | Baker = { |
| 95 | title = "the baker", |
| 96 | station = { "Furnace", "Brazier" }, |
| 97 | inside = { "Barrel", "Hay", "Table", "Crate" }, |
| 98 | trades = { |
| 99 | sell(1, "Wheat", 12), |
| 100 | buy(1, 1, "Bread", 3), |
| 101 | sell(1, "Berries", 10), |
| 102 | buy(2, 1, "Pumpkin pie", 1), |
| 103 | buy(2, 1, "Berry pie", 1), |
| 104 | sell(2, "Egg", 6), |
| 105 | buy(3, 2, "Honey cake", 1), |
| 106 | buy(3, 1, "Porridge", 2), |
| 107 | }, |
| 108 | lines = { "Smell that? Fresh out.", "Crusts are the best part.", "I'm always short of wheat." }, |
| 109 | work = { "Knead, fold, knead.", "Just a pinch more.", "Mind, that's hot!" }, |
| 110 | }, |
| 111 | Angler = { |
| 112 | title = "the angler", |
| 113 | station = { "Barrel" }, |
| 114 | inside = { "Crate", "Barrel", "Table", "Stool" }, |
| 115 | trades = { |
| 116 | sell(1, "Raw fish", 6), |
| 117 | buy(1, 1, "Cooked fish", 2), |
| 118 | buy(1, 2, "Fishing rod", 1), |
| 119 | buy(2, 3, "Bucket", 1), |
| 120 | buy(2, 1, "Fish stew", 1), |
| 121 | sell(2, "Reeds", 12), |
| 122 | buy(3, 4, "Water bucket", 1), |
| 123 | buy(3, 2, "Ice", 8), |
| 124 | }, |
| 125 | lines = { "They're biting today.", "Smells like rain. Good.", "One got away. A big one." }, |
| 126 | work = { "Untangling. Always untangling.", "A new hook for the old rod.", "Patience. Patience." }, |
| 127 | }, |
| 128 | Weaver = { |
| 129 | title = "the weaver", |
| 130 | station = { "Cream wool" }, |
| 131 | on_top = "Red rug", |
| 132 | inside = { "Light blue wool", "Crate", "Pink wool", "Lime wool" }, |
| 133 | trades = { |
| 134 | sell(1, "Cream wool", 6), |
| 135 | swap(1, { ["Cream wool"] = 2, ["Red flower"] = 1 }, "Red wool", 2), |
| 136 | swap(1, { ["Cream wool"] = 2, ["Blue flower"] = 1 }, "Blue wool", 2), |
| 137 | swap(1, { ["Cream wool"] = 2, Honey = 1 }, "Yellow wool", 2), |
| 138 | sell(2, "Silk", 4), |
| 139 | buy(2, 2, "Purple dye", 3), |
| 140 | buy(2, 4, "Wool coat", 1), |
| 141 | buy(3, 3, "Shears", 1), |
| 142 | }, |
| 143 | lines = { "Over, under, over.", "Red flowers make the best red.", "Bring me wool and flowers.", "Blue and white make the sky." }, |
| 144 | work = { "Over, under, over, under.", "This pattern's my gran's.", "Nearly a whole bolt." }, |
| 145 | }, |
| 146 | Smith = { |
| 147 | title = "the smith", |
| 148 | station = { "Anvil", "Cobblestone" }, |
| 149 | on_top = nil, |
| 150 | inside = { "Barrel", "Crate", "Table", "Stool" }, |
| 151 | trades = { |
| 152 | sell(1, "Coal", 10), |
| 153 | sell(1, "Raw copper", 4), |
| 154 | buy(1, 4, "Copper pickaxe", 1, 2), |
| 155 | sell(2, "Raw iron", 3), |
| 156 | buy(2, 8, "Iron pickaxe", 1, 2), |
| 157 | buy(2, 8, "Iron sword", 1, 2), |
| 158 | buy(3, 5, "Shield", 1, 2), |
| 159 | buy(3, 10, "Iron helmet", 1, 2), |
| 160 | }, |
| 161 | lines = { "Hot iron waits for nobody.", "Coal! I need coal!", "That's a fine edge." }, |
| 162 | work = { "Clang. Clang. There.", "Hotter. Hotter...", "Into the trough, hiss!" }, |
| 163 | }, |
| 164 | Grower = { |
| 165 | title = "the grower", |
| 166 | station = { "Hay" }, |
| 167 | inside = { "Hay", "Barrel", "Table", "Crate" }, |
| 168 | trades = { |
| 169 | buy(1, 1, "Seeds", 6), |
| 170 | sell(1, "Potatoes", 10), |
| 171 | sell(1, "Carrots", 10), |
| 172 | sell(2, "Pumpkin", 2), |
| 173 | buy(2, 1, "Apple", 4), |
| 174 | buy(2, 4, "Watering can", 1, 2), |
| 175 | buy(3, 4, "Sickle", 1, 2), |
| 176 | buy(3, 3, "Berry bush", 1, 3), |
| 177 | }, |
| 178 | lines = { "Rain tonight, I'd say.", "The carrots are coming on.", "Mind the rows!" }, |
| 179 | work = { "Weeds, weeds, weeds.", "Grow, little ones.", "That's a fine crop." }, |
| 180 | }, |
| 181 | Chandler = { |
| 182 | title = "the chandler", |
| 183 | station = { "Crate" }, |
| 184 | on_top = "Candle", |
| 185 | inside = { "Barrel", "Candle", "Table", "Stool" }, |
| 186 | trades = { |
| 187 | buy(1, 1, "Candle", 4), |
| 188 | buy(1, 1, "Torch", 8), |
| 189 | sell(1, "Honey", 6), |
| 190 | sell(2, "Bristles", 4), |
| 191 | buy(2, 2, "Lantern", 1), |
| 192 | buy(3, 3, "Paper lantern", 2), |
| 193 | buy(3, 2, "Brazier", 1), |
| 194 | }, |
| 195 | lines = { "Light keeps the gloom off.", "Never go out without a torch.", "Wax, wick and a little patience." }, |
| 196 | work = { "Dip, cool, dip again.", "A good straight wick.", "That one's for the well." }, |
| 197 | }, |
| 198 | Tanner = { |
| 199 | title = "the tanner", |
| 200 | station = { "Barrel" }, |
| 201 | on_top = nil, |
| 202 | inside = { "Crate", "Hay", "Table", "Barrel" }, |
| 203 | trades = { |
| 204 | sell(1, "Leather", 4), |
| 205 | sell(1, "Raw meat", 6), |
| 206 | buy(1, 1, "Cooked meat", 2), |
| 207 | buy(2, 3, "Leather", 2), |
| 208 | buy(2, 2, "Leather cap", 1), |
| 209 | buy(2, 2, "Leather boots", 1), |
| 210 | buy(3, 3, "Leather leggings", 1), |
| 211 | buy(3, 4, "Leather coat", 1), |
| 212 | }, |
| 213 | lines = { "Good hide, that.", "Boars make the toughest leather.", "Stand downwind, friend." }, |
| 214 | work = { "Scrape, stretch, scrape.", "Supple as you like.", "Nearly a pair of boots." }, |
| 215 | }, |
| 216 | Herbalist = { |
| 217 | title = "the herbalist", |
| 218 | station = { "Brazier" }, |
| 219 | on_top = "Clay pot", |
| 220 | inside = { "Clay pot", "Crate", "Table", "Bush" }, |
| 221 | trades = { |
| 222 | sell(1, "Glowcap", 6), |
| 223 | sell(1, "Red flower", 8), |
| 224 | buy(1, 1, "Fern", 4), |
| 225 | buy(2, 3, "Glimmer seeds", 2, 3), |
| 226 | buy(2, 2, "Mending tea", 1, 3), |
| 227 | sell(2, "Gloom dust", 2), |
| 228 | buy(3, 4, "Digger's tonic", 1, 2), |
| 229 | buy(3, 3, "Glowcap", 4), |
| 230 | }, |
| 231 | lines = { "Everything grows for something.", "Glowcaps, from the deep. Lovely.", "Feeling peaky? I've just the thing." }, |
| 232 | work = { "Stir it sunwise.", "Not too much of that one.", "Smell that? Mint." }, |
| 233 | }, |
| 234 | Wayfinder = { |
| 235 | title = "the wayfinder", |
| 236 | station = { "Bookshelf" }, |
| 237 | inside = { "Bookshelf", "Bookshelf", "Table", "Stool" }, |
| 238 | trades = { |
| 239 | { tier = 1, want = { [BEADS] = 1 }, give = "", n = 0, does = "way", label = "The way to a village" }, |
| 240 | sell(1, "Feather", 6), |
| 241 | buy(2, 4, "Torn map", 1, 2), |
| 242 | buy(2, 3, "Rail", 8), |
| 243 | buy(3, 6, "Cart", 1, 2), |
| 244 | buy(3, 12, "Balloon basket", 1, 1), |
| 245 | }, |
| 246 | lines = { "Every road goes somewhere.", "I've seen the snow and the sand.", "Need a way? Ask me." }, |
| 247 | work = { "North's that way. Mostly.", "Another line on the map.", "Here be... meadows." }, |
| 248 | }, |
| 249 | Beekeeper = { |
| 250 | title = "the beekeeper", |
| 251 | station = { "Beehive", "Hay" }, |
| 252 | inside = { "Barrel", "Crate", "Table", "Hay" }, |
| 253 | trades = { |
| 254 | buy(1, 1, "Honey", 2), |
| 255 | sell(1, "White flower", 10), |
| 256 | sell(1, "Violet flower", 10), |
| 257 | buy(2, 1, "Candle", 4), |
| 258 | buy(2, 1, "Honey cake", 1), |
| 259 | buy(3, 6, "Beehive", 1, 2), |
| 260 | }, |
| 261 | lines = { "Hear them hum? Happy bees.", "Walk slow near the hives.", "Flowers make the honey." }, |
| 262 | work = { "Easy, my lovelies.", "A fine full comb.", "Hush now, hush." }, |
| 263 | }, |
| 264 | Bowyer = { |
| 265 | title = "the bowyer", |
| 266 | station = { "Stake" }, |
| 267 | inside = { "Crate", "Barrel", "Table", "Stool" }, |
| 268 | trades = { |
| 269 | buy(1, 1, "Arrow", 8), |
| 270 | sell(1, "Feather", 6), |
| 271 | sell(1, "Flint", 8), |
| 272 | buy(2, 3, "Bow", 1, 2), |
| 273 | buy(2, 2, "Sling", 1, 2), |
| 274 | buy(3, 3, "Spear", 1, 2), |
| 275 | buy(3, 2, "Arrow", 20), |
| 276 | }, |
| 277 | lines = { "Straight shafts fly true.", "Got feathers? I need feathers.", "Steady hands, steady aim." }, |
| 278 | work = { "A little more off the end.", "Bend, but don't break.", "Feather, feather, feather." }, |
| 279 | }, |
| 280 | } |
| 281 | |
| 282 | -- What the peddler might carry: each visit brings a handful of these, and |
| 283 | -- he'll buy one or two things too. |
| 284 | local PEDDLER: { Trade } = { |
| 285 | buy(1, 1, "Cactus", 4, 3), |
| 286 | buy(1, 1, "Ice", 6, 3), |
| 287 | buy(1, 1, "Snow", 8, 3), |
| 288 | buy(1, 1, "Reeds", 6, 3), |
| 289 | buy(1, 1, "Sand", 16, 3), |
| 290 | buy(1, 1, "Slate", 16, 3), |
| 291 | buy(1, 1, "Birch log", 6, 3), |
| 292 | buy(1, 2, "Glowcap", 4, 3), |
| 293 | buy(1, 3, "Glimmer seeds", 2, 2), |
| 294 | buy(1, 4, "Gloom dust", 2, 2), |
| 295 | buy(1, 6, "Crystal", 1, 2), |
| 296 | buy(1, 8, "Gold ingot", 1, 2), |
| 297 | buy(1, 16, "Moonsilver ingot", 1, 1), |
| 298 | buy(1, 5, "Torn map", 1, 1), |
| 299 | buy(1, 12, "Balloon basket", 1, 1), |
| 300 | buy(1, 10, "Wooden music box", 1, 1), |
| 301 | buy(1, 3, "Berry bush", 1, 2), |
| 302 | buy(1, 1, "Red flower", 4, 3), |
| 303 | buy(1, 1, "Blue flower", 4, 3), |
| 304 | buy(1, 1, "Violet flower", 4, 3), |
| 305 | buy(1, 1, "Apple", 4, 3), |
| 306 | buy(1, 2, "Honey", 3, 3), |
| 307 | buy(1, 3, "Mending tea", 1, 2), |
| 308 | buy(1, 5, "Stoneheart tonic", 1, 1), |
| 309 | } |
| 310 | local PEDDLER_BUYS: { Trade } = { |
| 311 | sell(1, "Crystal", 1, 2, 4), |
| 312 | sell(1, "Gold ingot", 1, 3, 4), |
| 313 | sell(1, "Silk", 3, 1, 4), |
| 314 | sell(1, "Ember", 2, 1, 4), |
| 315 | sell(1, "Feather", 5, 1, 4), |
| 316 | } |
| 317 | |
| 318 | return { |
| 319 | BEADS = BEADS, |
| 320 | JOBS = JOBS, |
| 321 | PEDDLER = PEDDLER, |
| 322 | PEDDLER_BUYS = PEDDLER_BUYS, |
| 323 | } |