Wikily

Spiel wechseln

46 Wikis · wähle dein Spiel
WikilyWIKILY
Alle Spiele46 Wikis · wähle dein Spiel
Menu

Documentation

Material picker

Updated 2026-11-27

Some recipes take one of several materials for the same slot, and the material changes the item: a rifle stock of Cypress fires faster, one of Redwood lasts twice as long.

The material picker lets readers try that on the item’s page. They pick a material, the page shows what it changes, and the link they share opens with the same pick.

The examples follow a rifle whose recipe takes Heartwood, Cypress or Redwood for its stock.

What it does

The slot opens a pickerThe recipe’s “Heartwood / Cypress / Redwood” slot becomes a button. On a phone the choices slide up from the bottom; on a computer they open in a panel. From nine choices on, they show as a grid of icons with a search field.
The list marks the pickEach material under the recipe (“Material options”) can be tapped. The picked one is outlined and marked Selected; tapping it again takes the pick away.
The stats followThe Option stats block shows each stat with the pick applied: the old value crossed out, the new one, and the change (Fire Rate 1.5/s → 1.73/s, +15%).
The Harrison Repeater recipe with Cypress in its material slot and marked Selected in the material list, and below it the stats with Fire Rate going from 1.5/s to 1.73/s
On a computer: the slot shows the pick, the list marks it, the stats show the change.
On a phone, the choices of the material slot slide up from the bottom of the screen
On a phone the slot opens the choices from the bottom of the screen.
On a phone, the stats with Cypress picked, the changed ones tinted, with Change, Clear and Copy link buttons
The stats with the pick, and the buttons to change it, clear it or copy a link.

What it reads

Everything comes from your own data, nothing is typed into the block by hand. It needs two things for each item:

The materialsA list where each entry has a title, an icon and, if you like, a link. The title’s first line is the material’s name; the next line is what it does.
The statsThe item’s stats as rows of a name and a value (Fire Rate 1.5/s, Range 60m, Durability 150).

In the example both come from an Items table. Each item has recipe_cards, one card per recipe, and a card with a material slot carries the list in its choice_icons field, one entry per material:

{
  "title": "Cypress\n+15% Rate Of Fire · +15% Reload Speed · -15% Aim Time",
  "icon": "CypressLumber_icon.png",
  "href": "/items/cypress"
}

The bonuses are read from that second line, the way a player reads it: a sign, an amount, an optional %, and the stat. Separate them with “·” or “;”.

+15% Rate Of FireMultiplies the stat: 1.5/s becomes 1.73/s.
-15% Aim TimeLowers it by 15%.
+5 ArmorWithout %, the amount is added: 12 becomes 17.
No stat bonusAnything that is not a bonus is shown as a note and changes nothing.

A bonus finds its stat by its words, in any order, so “Rate Of Fire” changes the stat called “Fire Rate”. Units stay as they are (1.5/s, 60m). A bonus the item has no stat for, such as +15% Reload Speed on a rifle that lists none, still shows as its own line with just the change.

Set it up in the layout editor

This is done once, in the shared layout of the item pages, and then works on every item that has a material slot. See One layout for every entry and Variables and scripts if those are new to you.

  1. In Variables & Scripts, add a reader input named material: text, empty by default. Set its Share link name to material so links read ?material=cypress.
  2. Add a script that returns the materials of the item, for example from the recipe card shown (below), and one that returns the stats a material can change.
  3. Select the recipe cards block, open the field that shows the material list, and set Pick into input to material. The list becomes choices, and the slot that names those materials (“Heartwood / Cypress / Redwood”) opens the picker.
  4. Add an Option stats block (in the Data blocks) under the recipe. Choose the stats script, the materials script, and material under Pick stored in. Give it a title, such as “Stats with this material”.
  5. Optional: a second Option stats block in the item’s summary panel, with Controls switched off. It only follows the pick, so the item’s main stats change too.

Two scripts that do this for an items table like the one above:

-- The materials of this item's recipe slot, from the recipe card shown.
local e = vars.entry or {}
for _, card in ipairs(vars.recipeCards or e.recipe_cards or {}) do
  if type(card.choice_icons) == "string" and card.choice_icons ~= "" then
    return card.choice_icons
  end
end
return ""
-- The stats a material can change, before it.
local rows = {}
for _, r in ipairs(vars.tipStats or {}) do
  rows[#rows + 1] = { name = r.name, value = r.value }
end
-- plus the durability of the quality the reader picked
local e = vars.entry or {}
for _, r in ipairs(e["quality_" .. (vars.qSel or "common")] or {}) do
  if r.name == "Durability" then
    rows[#rows + 1] = { name = "Durability", value = tostring(r.quantity):match("^[%d%.]+") }
  end
end
return rows

Show the Option stats block only once near the recipe. On a phone the summary panel is at the top of the page and the recipe far below it, so the block under the recipe is the one the reader sees right after picking.

One slot, several items

A recipe slot that takes any one of several items (any meat, any seasoning) can show those items themselves: their real icons, each linking to its own page, instead of a placeholder. Give the slot’s entry an options list, one entry per item, in the same shape as any other icon:

{
  "title": "Meat",
  "qty": 1,
  "options": [
    { "title": "Bear Meat", "icon": "meat_02_icon.png", "href": "/items/bear-meat" },
    { "title": "Bird Meat", "icon": "BirdMeat_icon.png", "href": "/items/bird-meat" },
    { "title": "Bison Meat", "icon": "BisonMeat_icon.png", "href": "/items/bison-meat" }
  ]
}
One at a time (default)The slot keeps its size and shows the items in turn, marked “or”. Pointing at it or tabbing to it stops the turn; the button under it lists every item.
All side by sideEvery item next to each other with “or” between them, for slots with room. Choose it per icon field.
With a material pickerIf the card’s material list offers the same items, the button under the slot opens the picker, and the slot shows the picked item.
  1. Add options to the slot’s entry in your data or script, as above. The other slots stay as they are. alternatives works as a name too.
  2. Select the recipe cards block, open the icon field of the ingredients (Icon list: All icons with names and links), and choose Slots with several items: One at a time in the slot or All side by side.

A slot without a name of its own is named after its first items (“Bear Meat / Bird Meat / Bison Meat / ...”). The count (qty) belongs to the slot, not to each item.

On a page whose script already renames the slot to “Bear Meat / Bird Meat / ...”, add the list to that slot in the same script: the slot then shows the items, and the picker still opens from it.

Several pickers on one card

Some recipes take several picks: a meat, an optional seasoning and a fuel. Each becomes its own picker on the same card, and one stats block adds them all up.

Every slot opens its own pickerThe meat slot opens the meats, the seasoning slot the seasonings, the fuel slot the fuels, right where the reader taps. No scrolling to a list under the card.
One stats blockThe stats show every pick at once (Comfort 10 → 46 with Bird Meat and Yarrow), with one button per picker. A picker the item does not have is left out.
Each picker keeps its nameA picker is headed by its list's own label, so the fuel picker says Optional Fuel, not Optional Material.
  1. In the recipe cards block, add one icon list per picker (for example choice_icons, choices, choicesF). Give each its own Pick into input (material, optional, optional2) and a label (Required Material, Optional Material, Optional Fuel).
  2. Untick Show this list under the card on those lists if the slots alone should offer the items.
  3. Give each slot of the ingredients the picker it opens, with pick (below). Without it a slot still opens the picker whose items it lists or names.
  4. Use one Option stats block. Under Pickers, click Add a second picker and add one row per picker: its options, the input and a button text.
[
  { "title": "Meat", "qty": 1, "pick": "material",
    "options": [ { "title": "Bear Meat", "icon": "meat_02_icon.png", "href": "/items/bear-meat" } ] },
  { "title": "Flour", "icon": "Flour_icon.png", "href": "/items/flour", "qty": 1 },
  { "title": "Optional material", "icon": "Slot_White.png", "qty": 1, "pick": "optional" },
  { "title": "Fuel", "icon": "Slot_White.png", "qty": 1, "pick": "optional2" }
]

The same setup written as block settings, for an AI assistant or a layout file. The three option lists of the recipe cards block, hidden under the card:

[
  { "display": "icons", "fieldRef": "input_icons", "iconsMode": "flow" },
  { "display": "icons", "fieldRef": "choice_icons", "iconsMode": "flow",
    "label": "Required Material", "pickInput": "material", "pickList": "hidden" },
  { "display": "icons", "fieldRef": "choices", "iconsMode": "flow",
    "label": "Optional Material", "pickInput": "optional", "pickList": "hidden" },
  { "display": "icons", "fieldRef": "choicesF", "iconsMode": "flow",
    "label": "Optional Fuel", "pickInput": "optional2", "pickList": "hidden" }
]

And the one Option stats block that follows all three picks:

{
  "type": "option-stats",
  "attrs": {
    "statsVariable": "materialStats",
    "groups": [
      { "inputVariable": "material", "optionsVariable": "materialOptions", "label": "Choose required material" },
      { "inputVariable": "optional", "optionsVariable": "optionalOptions", "label": "Choose optional material" },
      { "inputVariable": "optional2", "optionsVariable": "optional2Options", "label": "Choose fuel" }
    ]
  }
}

The same layout serves every recipe: meat only, meat with seasoning and fuel, two meats, seasoning only. A picker whose list is empty for an item simply does not appear.

pickInputOn an icon list: the reader input its items are picked into. Each list with its own input is one picker of the card.
pickList: "hidden"Keeps that list off the card; the slot that opens the picker still offers every item. Editor: untick Show this list under the card.
pickOn a slot in the ingredients: the input of the picker it opens. Without it, a slot opens the picker whose items it lists in options or names (A / B / C).
labelThe list's label heads its picker: Optional Fuel, not Optional Material.

Share a pick with a link

The pick is part of the page address: picking Cypress turns the address into …/items/harrison-repeater?material=cypress. Anyone who opens that link sees the page with Cypress already picked. The name in the link is the material’s name in lower case, with dashes for spaces (bird-meat).

Copy linkCopies the address with the pick. If the browser refuses, the link is shown to copy by hand.
ClearBack to the base stats; the material leaves the address.
An old linkA material the item does not have (any more) is ignored: the page opens with nothing picked.
Several pickersEvery picker adds its own pick: …/items/stew?material=bird-meat&optional=yarrow&fuel=joshua-wood. Give each reader input its own Share link name (material, optional, fuel); without one the link reads ?v.optional2=….

Quality and material together

A quality picker (Common, Uncommon, Rare, Epic) and the material picker work side by side. The quality decides which recipe card is shown and the stats the material starts from; the material is applied on top of them.

Both in one linkA link can carry both: …?v.qPick=rare&material=redwood opens the Rare recipe with Redwood picked.
The material staysChanging the quality keeps the picked material, as long as the new recipe offers it.
Stats from the qualityDurability follows the quality first: Rare is 210, and Redwood (+100%) makes it 420.
On a phone, the material list under the recipe with Cypress outlined and marked Selected
The material list on a phone, with the pick marked.

Limits, and items without materials

Several slotsA recipe with several slots (a meat, a seasoning, a fuel) gets one picker per slot: see Several pickers on one card.
Slots named “any …”A slot called “any Specific Meat” does not name its materials, so the slot itself is not a button. The list and the Choose material button still work. Give the slot its items (One slot, several items) and it opens the picker.
No materialsOn an item without a material slot, the Option stats block shows nothing and the recipe looks as it always did.
No live calculationPicking a material needs no script, so it works everywhere. If a browser cannot run the page’s scripts, values that come from them (such as a quality pick) stay as the page opened and a short note offers a reload.

For developers

The block is option-stats; the recipe cards’ icons field takes pickInput; a reader input’s share link name is urlKey. Options are icon entries (title with the name on its first line, icon, href), read and matched in lib/option-picker.ts.

A slot’s options are parsed in lib/repeater-rows.ts and drawn by components/widgets/icon-alt-slot.tsx; the field setting is optionsMode (absent: one at a time, "row": side by side).

Several pickers: every icons field with pickInput is one picker of its card; pickList: "hidden" keeps a list off the card. A slot names its picker with pick. The block takes groups (inputVariable, optionsVariable, label) and applies every pick in that order.

The live scripts of a page re-run only when an input they name changes, so a material pick runs no Lua.