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.
1. A new graph
- Open your mod on the bench. Under Graphs in the list on the left, press +.
- 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
- Right-click the ground (or press Space). The node list opens where the pointer is, with the node book first.
- 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?
- Drag from the event's
weaponpin and let go on the ground. The node list opens showing only nodes that take a weapon. - Type
addressand pick Address of. It is placed with itsofpin on the wire's end, already wired. It gives the weapon's address as text, such asthing/Longsword. - Drag from its
addresspin onto the ground and pick Compare. It is a small node with=on it. - 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
- Drag from the event's run pin (the white arrow on the right of its head) onto the ground, and pick Branch.
- Drag from the
='s output into the Branch'scondition.
The run now reaches Branch at every blow, and goes on through true only when the weapon was a longsword.
5. Burn
- Drag from Branch's
trueonto the ground and typefire for. Set on fire for is a function of the game's library, under Library › Fighting. - Type 4 into its
seconds. - Drag from the event's
victiminto itswho.
6. Notes, saving and trying it
- 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.
- Save (Ctrl+S) writes the file to
graphs/fire_sword.graph.jsonand lists it inmod.json. - 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.
Modding