Skip to content

Data panel, tech tree and item tree ​

The Data panel (right rail) edits your game's definitions: units, abilities, buffs, items, upgrades and races, and its tags, callings and default sets. Changes apply at once in the editor and in a game played here, and Keep writes them to your game's data.json.

Change a unit's stats ​

  1. Open Data, or double-click a unit type in Content, or click the data icon beside a selected unit's name in the Inspector.
  2. Find the unit by name and pick it.
  3. Change a field: health, damage, cost, build time. A dot marks a change; click the dot to undo it.
  4. Press Keep to write the changes into data.json.

A game played here takes the change at once, units of that type included. The field's code name (stats.health) is on its tooltip.

Make a new unit from an existing one ​

  1. Pick the unit (say, Footman).
  2. Press Copy as new and give it an id and a name (Champion).
  3. Change what you want: give it an aura, add it to what the Barracks trains.
  4. Press Keep.

The copy looks and sounds like its original until you give it a look of its own. data.json stores it as the original plus what changed:

json
"champion": { "copyOf": "footman", "name": "Champion", "abilities": ["devotionAura"] }

Make a definition from nothing ​

  1. Pick the kind (units, abilities…).
  2. Press New (beside Tech tree), and pick: of nothing, of the smallest definition of that kind, or of the one shown.
  3. Fill in the required fields, then Keep.

data.json stores it as "recruit": { "new": true, "name": "Recruit" }. Tick With code to also write a code stub; see Start a definition with code.

Delete a definition ​

  1. Pick it and press × beside Copy as new.
  2. It is also taken out of every list that names it (what a barracks trains, a unit's abilities).
  3. Keep writes it under removed; Undo all brings it back.

Edit lists: abilities, effects, what a building trains ​

  • Lists of ids (abilities, what a barracks trains) are chips: × removes one, Add… picks one by name.
  • Lists of things (an ability's effects, a buff's ticks, an upgrade's levels) are rows: pick the effect's type first, then its fields. Up, down and × reorder and remove. Add… adds one.
  • A row's When (hit, arrived, landed, end) makes it wait on the row above, as a chain.
  • A number by level (amount: [40, 70, 100]) shows a field for each level.

Keep changes for this map only ​

  1. Set Keep in (beside Keep) to This map.
  2. Change fields as usual.
  3. Save the map: the changes are in its file (GameMap.definitions), so a 200-health footman is this map's alone.

See the tech tree ​

  1. Press Tech tree under the Data panel's search.
  2. Read it left to right by tier: solid lines are trains, builds, hires, researches and upgrades to; dashed lines are requirements.
  3. Hover a thing to light its lines; click it to show its definition.
  4. Zoom with the wheel, drag to move, Whole to fit. Save as a picture writes an SVG.

techTree(registry) gives the same tree to draw in your own help screen. itemTree(items, { currency, problems }) gives the item tree (from @v12-engine/editor).

See the item tree ​

  1. Press Item tree under the Data panel's search.
  2. Items are in columns by tier (consumable, starter, basic, intermediate, legendary, relic, then the game's own tiers). A line runs from each part to what it builds; ×2 means it takes two.
  3. Each item shows its price and what its parts cost together. A price in red costs less than its parts; a dot means Problems has something on it (hover for the message).
  4. Find items by name or #tag, or pick a calling or a tag: what fits is lit, the rest dimmed.
  5. Change the tree:
    • drag an item onto another to make it one of its parts (refused where the tree would loop);
    • hover a line and press its × to take the part out;
    • click an item to edit it in Data;
    • Shift+click several, then Tag them or Untag them.
  6. The changes are Data changes: Keep writes them into data.json. Save as a picture writes an SVG.

Tag items ​

  • An item's Tags field shows its tags as chips, by their names and colours, and offers the tags already in use as you type.
  • To tag several at once, Shift+click or Ctrl+click them in the list (or on the item tree), type a tag in the bar above the list and press Tag (or Untag).
  • Search with #attack or tag:attack: only definitions with every tag typed are listed, and the other words search as usual.

Name tags and give them a look ​

  1. Pick Tags in the kind picker. It lists every tag your definitions use, with how many use each (click the count to list them).
  2. Open a tag to give it a Name, a Line, an Icon and a Colour, and to make it A shop's filter (TagDef).
  3. Add names a tag nothing uses yet; Its word only takes its name and look away.
  4. Keep writes them under tags in data.json.

Edit the callings ​

  1. Pick Callings in the kind picker (in a game with heroes).
  2. Open a calling to change its name, line, icon and colour; Add makes one of your own; × takes one out.
  3. Keep writes them under callings. A calling of the default set is taken out by leaving it out of the set (defaults.callings).

Choose the default sets ​

A game that takes the engine's default sets in code (useDefaults: the items, the hero spells, the callings) can choose again here:

  1. Pick Default sets in the kind picker.
  2. For each set pick All of it (start from the defaults), All but some, Only some or None: start empty, and pick the ids for the list.
  3. Add your own with New, and change the set's like any other definition.
  4. Keep writes the choice under defaults in data.json.

The editor takes the set's definitions out and puts them back at once. Your own definitions and changes made in code (with, change) stay.

Fix data problems ​

Problems, under the fields, lists what does not fit together: an id that names nothing, an effect type nothing handles, requirements in a loop, and (as warnings) things nothing makes. Click one to jump to the field; press F8 for the next, Shift+F8 for the one before.

Set how a race's AI plays ​

  1. Pick a race in Data.
  2. Under its fields, set the brain, difficulty, personality, flags, build order and waves.
  3. Set its army (each soldier's share) and where it builds (near home, on a deposit, at the edge…).
  4. Keep writes it into data.json's ai.races.

A computer seated in a game started here after that plays by it.

Change global rules ​

Supply, heroes (maxHeroes, maxHeroLevel, xpRange), resources and upkeep can be data too. Change them in the panel and Keep: they go into data.json's rules.

Start a definition with code ​

  1. Open the Code panel (left rail) and press New with code.
  2. Pick the kind (unit type, ability, order, system, mission, editor panel), an id and a name.
  3. The editor writes a stub <id>.ts (.tsx for a panel) and opens it in your code editor. Its comment says where to list it in your rules.

A unit type or ability is in the data at once, so it is in a game played here before you list the code. Nothing is written until the project says where:

ts
editorFiles({
	gameFolder: () => 'src',
	// or by game: scaffold: (game) => [`src/games/${game}/code`]
	scaffold: ['src/game']
})

A file is never written over. An id is letters and digits with -, _ and . between.

Choose which fields can be edited ​

Nothing is editable until your game says so, with editable:

ts
export const towerDefense = layData(
	{
		// …
		editable: {
			units: (def) => (def.kind === 'building' ? ['name', { path: 'stats.health', min: 1 }, { path: 'cost.gold', kind: 'integer', min: 0 }] : null),
			abilities: [{ path: 'cooldown', min: 0 }, 'description'],
			buffs: 'all'
		}
	},
	dataFile // import dataFile from './data.json'
)

layData lays data.json over your code's definitions, and makes the copies and new ones.

In code ​

ts
editor.data.set('units', 'footman', 'stats.health', 450) // gives back why not, if it cannot
editor.data.copy('units', 'footman', 'champion', 'Champion')
editor.data.make('units', 'recruit', 'Recruit')
editor.data.remove('units', 'rifleman')
editor.data.setRule('supply.max', 150)
editor.data.setChoice('items', { except: ['sightWard'] })
editor.data.tag('items', ['ironSword', 'quickDagger'], 'early')
editor.data.setTag('early', { name: 'Early', color: '#7fb4e6', filter: true })
editor.data.setCalling('vanguard', { name: 'Bulwark' })
editor.data.scope = 'map' // keep in this map
editor.data.problems()
editor.data.keep()

editor.code.newWithCode('unit', 'archer', 'Archer')

Reference ​

Field kinds ​

A field is its path in the definition (stats.health, attacks.0.damagePoint), with a name, a kind, bounds and a heading.

KindWhat it holds
numberA number
integerA whole number
textWords
booleanYes or no
choiceOne of its options
eitherYes, no, one of its options, or a number where orNumber says
listIds of the kind of says
idOne id of the kind of says, picked by name
rowsA list of things: an ability's effects, a buff's onApply, an upgrade's effects, a race's start.units

'all' offers every number, word and yes-or-no, plus the lists of ids (abilities, requirements, trains, builds, sells, hires, upgradesTo, learns, made of), but not the id, the kind, or anything that is a function. With 'all', the fields of the ability primitives and of packs the game has on (Rules.packs) are offered too. packages/engine/tests/abilityData.test.ts holds that list; the abilities cookbook builds abilities from them.

What data.json holds ​

EntryWhat it is
A field by path"effects": { "0": { "amount": 50 } } changes one thing in a list
A list written wholeReplaces the list (after an add, a remove, a reorder)
"copyOf": "<id>"A copy of another definition, with what changed
"new": trueA definition made from nothing
"removed"{ "units": ["rifleman"] }: taken out after the copies are made
"rules"Global rules (DataRules)
"ai": { "races" }A race's computer profile
"defaults"What the game takes of each default set: "all", "none", { "only": [...] } or { "except": [...] }
"tags"Tags by id, each a TagDef without its id, over the code's: { "burn": { "name": "Burn", "filter": true } }
"callings"Callings by id, over the game's or new: { "vanguard": { "name": "Bulwark" } }

A race shows its start as data (RaceDef.start), and a copied race has toggles for whether it keeps the original's hooks and onStart (Races).

editor.data ​

MethodWhat it does
kinds(), defs(kind), fields(kind, id), value(kind, id, path)Read
set(kind, id, path, value)Change a field; gives back why not
rows(kind, id, path), addRow(kind, id, path, type?), removeRow(kind, id, path, place), moveRow(kind, id, path, place, to), retypeRow(kind, id, path, place, type)Lists of things
copy(kind, from, id, name?), make(kind, id, name?, template?), smallest(kind)Copy as new, New
remove(kind, id), isRemoved(kind, id), copyOf(kind, id)Delete, and what was copied
rule(path), setRule(path, value)Global rules
problems()checkRules on the data as it is now
asData(), list({ unkept }), isChangedWhat changed
reset(kind?, id?, path?), keep(), show(kind, id)Undo, Keep, show one in the panel
tags(), setTag(id, def), tag(kind, ids, tag, on?)Tags in use, naming one, tagging several
callings(), setCalling(id, values), removeCalling(id)Callings
sets(), setChoice(set, choice)Default sets
section(part, id), setSection(part, id, value)An entry of tags, callings or defaults whole

fieldWords names a field in words; REQUIRED_FIELDS lists what a new definition must have; effectFields(game, type) lists what an effect's type reads. The Code panel's stub API is editor.code (newWithCode, scaffoldFolders, loadScaffolds). The panel's id is data: a game can put its own in its place (editor.dock.add).