Modding
Discord Wishlist on Steam

Graphs

A first graph

This builds a small graph from nothing: whoever a longsword strikes is set alight for four seconds. It is the same graph as the Fire sword template, so the template is there to compare with.

A blow landed: was it struck with a longsword?Then the one struck burnsBlow landedallweaponattackervictimpartAddress ofofaddress=BranchconditiontruefalseSet on fire forallwhoseconds4
The finished graph

1. A new graph

  1. Open your mod on the bench. Under Graphs in the list on the left, press +.
  2. Name it Fire sword, leave Empty graph picked, and press Make it. The graph page opens in place of the canvas.

2. When a blow lands

  1. Right-click the ground (or press Space). The node list opens where the pointer is, with the node book first.
  2. Type blow. Blow landed is under Events › Fighting. Click it, or press Enter.

The event has no run coming in: a run starts here every time a weapon's blow lands on somebody. Its outputs are the weapon that struck, the attacker, the victim and the body part hit.

3. Was it a longsword?

  1. Drag from the event's weapon pin and let go on the ground. The node list opens showing only nodes that take a weapon.
  2. Type address and pick Address of. It is placed with its of pin on the wire's end, already wired. It gives the weapon's address as text, such as thing/Longsword.
  3. Drag from its address pin onto the ground and pick Compare. It is a small node with = on it.
  4. In its second input, press the search button beside the box and pick the Longsword. The box now reads Longsword; the file keeps thing/Longsword.

= gives yes when both sides are the same.

4. Only then

  1. Drag from the event's run pin (the white arrow on the right of its head) onto the ground, and pick Branch.
  2. Drag from the ='s output into the Branch's condition.

The run now reaches Branch at every blow, and goes on through true only when the weapon was a longsword.

5. Burn

  1. Drag from Branch's true onto the ground and type fire for. Set on fire for is a function of the game's library, under Library › Fighting.
  2. Type 4 into its seconds.
  3. Drag from the event's victim into its who.

6. Notes, saving and trying it

  1. Pick the nodes (drag a box round them on the ground) and press C for a comment box round them. Write what they do in its head.
  2. Save (Ctrl+S) writes the file to graphs/fire_sword.graph.json and lists it in mod.json.
  3. Try in the Test Map, take a longsword, and strike somebody.

When something is wrong

  • A node with a problem has a red dot in its head; hovering it says what. The side panel lists every problem first, and a click shows its node.
  • A wire that won't join says why ("a number can't go into text").
  • In play, F7 opens the graph debugger: the graph drawn over the game, its nodes lighting as they run.

Make it yours

  • Pick your own weapon in the = instead of the Longsword: a mod's weapon is picked the same way, thing/<mod id>.<Name>.
  • Open Set on fire for with a double-click to see how it is made. It opens read-only; Copy into my mod makes a copy to change.
  • Add a Play sound after it, or a Bark from the one struck.