Fork events use local variables that were set by vars events.
After resolving this event, the player is returned immediately to the map screen (or, if an event is on the event chain, the chained event will begin).
Plays a text event. Which one is played depends on what variables have been set.
"fork": {
"example": {
"list": [
{"faveFood=rice": "text:rice" }, if "faveFood" was set to "rice" earlier, play the rice text event.
{"faveFood=noodles": "text:noodles"} if "faveFood" was set to "noodles" earlier, play the noodles text event.
]
}
},
You can download this example campaign here:
{
"area": {
"START": {
"mdata": [
["choice:characterSelect"],
["text:showWhatWasSelected"]
]
}
},
"choice": {
"characterSelect": {
"micon": "pack.webp",
"mdesc": "Choose your Character",
"title": "Pick which gadget you are.\nThis will save a variable, which is later referenced by the fork event.",
"list": [
{"desc": "Green", "name": "Green Gadget", "img": "grn.webp", "vars": "character=>Green" },
{"desc": "Red", "name": "Red Gadget", "img": "red.webp", "vars": "character=>Red" },
{"desc": "Yellow", "name": "Yellow Gadget", "img": "yel.webp", "vars": "character=>Yellow"}
]
}
},
"text": {
"showWhatWasSelected": {
"micon": "pack.webp",
"chain": "fork:showCharacter",
"parts": [
{"text": "The character variable was saved in the previous choice event."},
{"text": "A fork event is chained to this event."},
{"text": "Depending on the variable that was set before, a different text event will be triggered."}
],
},
"Green": {"parts": [{"char": "Green", "name": "Green Gadget", "text": "You are the Green Gadget!", "src": "grn.webp"}]},
"Red": {"parts": [{"char": "Red", "name": "Red Gadget", "text": "You are the Red Gadget!", "src": "red.webp"}]},
"Yellow": {"parts": [{"char": "Yellow", "name": "Yellow Gadget", "text": "You are the Yellow Gadget!", "src": "yel.webp"}]}
},
"fork": {
"showCharacter": {
"list": [
{"character=Green": "text:Green" },
{"character=Red": "text:Red" },
{"character=Yellow": "text:Yellow"}
]
}
},
"vars": {}
}
You can have the entire event contain the contents of the "list" array:
"fork": {
"longExample": {
"list": [
{"number=One": "text:one"},
{"number=Two": "text:two"}
]
},
"shortExample" : [this event is effectively identical to the above one.
{"number=One": "text:one"},
{"number=Two": "text:two"}
]
},
You can add a "DEFAULT" branch, which will be triggered in the case that no other branches are triggered.
"fork": {
"defaultExample": {
"list": [
{"number=One": "text:one"},
{"number=Two": "text:two"},
{"DEFAULT" : "text:default"} triggered if number is any value other than one or two.
]
}
},