[{"data":1,"prerenderedAt":530},["ShallowReactive",2],{"help-\u002Fhelp\u002Fgold-coins":3,"help-index":399},{"id":4,"title":5,"body":6,"category":375,"description":376,"extension":377,"keywords":378,"meta":392,"navigation":393,"order":394,"path":395,"seo":396,"stem":397,"__hash__":398},"help\u002Fhelp\u002Fgold-coins.md","Give or take gold coins",{"type":7,"value":8,"toc":365},"minimark",[9,13,21,32,58,65,70,119,125,132,136,165,171,193,197,220,226,233,245,249,275,281,293,297,315,325,329],[10,11,5],"h1",{"id":12},"give-or-take-gold-coins",[14,15,16,20],"p",{},[17,18,19],"strong",{},"The case:"," the main character carries gold. A merchant sells bread for three coins and buys their old sword for five. The player can only buy bread while they have at least three coins.",[22,23,29],"pre",{"className":24,"code":26,"language":27,"meta":28},[25],"language-text","Gold: 10\nMerchant: Fresh bread, three coins a loaf. Anything else?\n  1. Buy bread (3 coins)\n  2. Sell my old sword\n  3. Goodbye.\nPlayer picks 1.\nMerchant: Here you go, still warm.\nGold: 7\n","text","",[30,31,26],"code",{"__ignoreMap":28},[14,33,34,37,38,41,42,45,46,49,50,53,54,57],{},[17,35,36],{},"The short answer:"," create a number variable ",[30,39,40],{},"gold",". On the node where the player pays, add ",[17,43,44],{},"Set variable"," with ",[30,47,48],{},"gold −= 3",". On the node where they earn coins, ",[30,51,52],{},"gold += 5",". Give the buy option the condition ",[30,55,56],{},"gold ≥ 3",".",[14,59,60],{},[61,62],"img",{"alt":63,"src":64},"The merchant dialogue: the merchant's node with Buy bread, Sell my old sword and Goodbye, and a node for each answer","\u002Fimages\u002Fhelp\u002Fgold-coins\u002Fcanvas.jpg",[66,67,69],"h2",{"id":68},"_1-create-the-gold-variable","1. Create the gold variable",[71,72,73,81,91,98,108],"ol",{},[74,75,76,77,80],"li",{},"Click the pencil next to ",[17,78,79],{},"Variables"," in the explorer on the left.",[74,82,83,84,87,88,90],{},"Click ",[17,85,86],{},"New variable"," and name it ",[30,89,40],{},". Names use small Latin letters and underscores.",[74,92,93,94,97],{},"Set its type to ",[17,95,96],{},"Unsigned number",", a whole number that never goes below 0.",[74,99,100,101,104,105,57],{},"Under ",[17,102,103],{},"Starts as",", enter how many coins the player has at the start, for example ",[30,106,107],{},"10",[74,109,110,111,115,116,57],{},"Add a comment like ",[112,113,114],"em",{},"Coins the player carries",", so everyone on the team knows what it means. Click ",[17,117,118],{},"Save",[14,120,121],{},[61,122],{"alt":123,"src":124},"The Variables window with gold, an unsigned number that starts as 10, and its comment","\u002Fimages\u002Fhelp\u002Fgold-coins\u002Fvariable.jpg",[14,126,127,128,131],{},"Pick ",[17,129,130],{},"Number"," instead if gold can go negative, for example to allow debt.",[66,133,135],{"id":134},"_2-take-coins-when-the-player-pays","2. Take coins when the player pays",[71,137,138,144,155],{},[74,139,140,141],{},"Select the node that plays after the player pays, here ",[112,142,143],{},"\"Here you go, still warm.\"",[74,145,100,146,149,150,152,153,57],{},[17,147,148],{},"On start, set",", click ",[17,151,44],{}," and pick ",[30,154,40],{},[74,156,157,158,161,162,57],{},"Choose ",[17,159,160],{},"−="," and enter ",[30,163,164],{},"3",[14,166,167],{},[61,168],{"alt":169,"src":170},"The bread node selected: under On start, set, gold −= 3","\u002Fimages\u002Fhelp\u002Fgold-coins\u002Fset-variable.jpg",[14,172,173,174,177,178,181,182,184,185,188,189,192],{},"The coins change when the node plays. To give coins, do the same on the node where the player earns them, with ",[17,175,176],{},"+=",": here ",[112,179,180],{},"\"Five coins for it\""," gets ",[30,183,52],{},". Choose ",[17,186,187],{},"="," to set an exact amount, for example ",[30,190,191],{},"gold = 0"," when the player is robbed.",[66,194,196],{"id":195},"_3-offer-the-option-only-when-the-player-can-pay","3. Offer the option only when the player can pay",[71,198,199,202,213],{},[74,200,201],{},"Select the merchant's node.",[74,203,204,205,149,208,152,211,57],{},"On ",[112,206,207],{},"Buy bread (3 coins)",[17,209,210],{},"+ condition",[30,212,40],{},[74,214,157,215,161,218,57],{},[17,216,217],{},"≥",[30,219,164],{},[14,221,222],{},[61,223],{"alt":224,"src":225},"The merchant's node selected: Buy bread is visible when gold ≥ 3","\u002Fimages\u002Fhelp\u002Fgold-coins\u002Fcondition.jpg",[14,227,228,229,232],{},"Now the player only sees ",[112,230,231],{},"Buy bread"," while they have three coins or more. The option shows a filter badge with its number of conditions on the canvas.",[14,234,235,236,239,240,57],{},"To let the player come back to the merchant's options after buying, link the answer back to the merchant's node with ",[17,237,238],{},"Return to options",". See ",[241,242,244],"a",{"href":243},"\u002Fhelp\u002Fquestion-hub","Bring the player back to a list of questions",[66,246,248],{"id":247},"_4-test-it","4. Test it",[71,250,251,257,266],{},[74,252,83,253,256],{},[17,254,255],{},"Show player"," and play the dialogue.",[74,258,259,260,262,263,265],{},"Watch ",[30,261,40],{}," in the ",[17,264,79],{}," column while you buy bread: 10, 7, 4, 1.",[74,267,268,269,271,272,274],{},"With 1 coin left, ",[112,270,231],{}," is faded with ",[17,273,56],{}," next to it. In your game the player won't see it.",[14,276,277],{},[61,278],{"alt":279,"src":280},"The player after three loaves: gold is 1 and Buy bread is faded with gold ≥ 3","\u002Fimages\u002Fhelp\u002Fgold-coins\u002Fplayer.jpg",[14,282,283,284,262,286,288,289,292],{},"You can change ",[30,285,40],{},[17,287,79],{}," column to test other amounts without playing up to them. Click ",[17,290,291],{},"Restart"," to start again with 10 coins.",[66,294,296],{"id":295},"variations","Variations",[14,298,299,302,303,306,307,310,311,57],{},[17,300,301],{},"Sell only once."," Turn on ",[17,304,305],{},"Ask once"," on ",[112,308,309],{},"Sell my old sword",", since the player has only one sword. See ",[241,312,314],{"href":313},"\u002Fhelp\u002Foption-only-once","Make an option the player can pick only once",[14,316,317,320,321,324],{},[17,318,319],{},"Branch on the amount."," Give the links from a node conditions, like ",[30,322,323],{},"gold ≥ 100"," to one line and no condition to another. The game follows the first link whose conditions are met.",[66,326,328],{"id":327},"in-your-game","In your game",[14,330,331,333,334,45,337,340,341,344,345,348,349,352,353,239,356,360,361,57],{},[30,332,40],{}," is exported with the dialogue's variables and its starting value. A node exports its change in ",[30,335,336],{},"setVariableOnStart",[30,338,339],{},"operation"," set to ",[30,342,343],{},"add"," or ",[30,346,347],{},"subtract",", and the option's condition with ",[30,350,351],{},"operator"," ",[30,354,355],{},">=",[241,357,359],{"href":358},"\u002Fdocumentation\u002Fdialogue-schema-api\u002Fvariable-v1","Variable v1"," and ",[241,362,364],{"href":363},"\u002Fdocumentation\u002Fdialogue-schema-api\u002Fdialogue-node-v2#setvariableonstart","SetVariableOnStart",{"title":28,"searchDepth":366,"depth":366,"links":367},3,[368,370,371,372,373,374],{"id":68,"depth":369,"text":69},2,{"id":134,"depth":369,"text":135},{"id":195,"depth":369,"text":196},{"id":247,"depth":369,"text":248},{"id":295,"depth":369,"text":296},{"id":327,"depth":369,"text":328},"variables","Track the main character's gold with a number variable: add coins when they earn them, take coins when they pay, and offer an option only when they can afford it.","md",[40,379,380,381,382,383,343,384,347,385,386,387,388,389,390,391],"coins","money","currency","inventory","counter","remove","increase","decrease","number variable","buy","sell","pay","price",{},true,1,"\u002Fhelp\u002Fgold-coins",{"title":5,"description":376},"help\u002Fgold-coins","JOZvIrrSZ1_vfQ30gGJna5g6BrbhAx8R6bmb8iJB6vs",{"articles":400,"sections":427},[401,403,415],{"path":395,"title":5,"description":376,"category":375,"order":394,"keywords":402},[40,379,380,381,382,383,343,384,347,385,386,387,388,389,390,391],{"path":313,"title":314,"description":404,"category":405,"order":394,"keywords":406},"Hide a dialogue option after the player picks it, with Ask once in the LoreHub Dialogue Builder. Step by step, with a list of questions as the example.","dialogue-builder",[407,408,409,410,411,412,413,414],"play once","one time","only once","ask once","hide option","already asked","repeat question","disappear",{"path":243,"title":244,"description":416,"category":405,"order":369,"keywords":417},"Let the player ask questions in any order and return to the same list after each answer, with Return to options in the LoreHub Dialogue Builder.",[418,419,420,421,422,423,424,425,426],"hub","question hub","back to questions","return","loop","go back","ask again","menu","list of questions",[428,430,434,438,442,446,450,454,458,460,464,469,474,479,484,488,493,497,501,503,507,512,517,522,526],{"id":395,"title":5,"titles":429,"content":376,"level":394},[],{"id":431,"title":5,"titles":432,"content":433,"level":394},"\u002Fhelp\u002Fgold-coins#give-or-take-gold-coins",[],"The case: the main character carries gold. A merchant sells bread for three coins and buys their old sword for five. The player can only buy bread while they have at least three coins. Gold: 10\nMerchant: Fresh bread, three coins a loaf. Anything else?\n  1. Buy bread (3 coins)\n  2. Sell my old sword\n  3. Goodbye.\nPlayer picks 1.\nMerchant: Here you go, still warm.\nGold: 7 The short answer: create a number variable gold. On the node where the player pays, add Set variable with gold −= 3. On the node where they earn coins, gold += 5. Give the buy option the condition gold ≥ 3.",{"id":435,"title":69,"titles":436,"content":437,"level":369},"\u002Fhelp\u002Fgold-coins#_1-create-the-gold-variable",[5],"Click the pencil next to Variables in the explorer on the left. Click New variable and name it gold. Names use small Latin letters and underscores. Set its type to Unsigned number, a whole number that never goes below 0. Under Starts as, enter how many coins the player has at the start, for example 10. Add a comment like Coins the player carries, so everyone on the team knows what it means. Click Save. Pick Number instead if gold can go negative, for example to allow debt.",{"id":439,"title":135,"titles":440,"content":441,"level":369},"\u002Fhelp\u002Fgold-coins#_2-take-coins-when-the-player-pays",[5],"Select the node that plays after the player pays, here \"Here you go, still warm.\" Under On start, set, click Set variable and pick gold. Choose −= and enter 3. The coins change when the node plays. To give coins, do the same on the node where the player earns them, with +=: here \"Five coins for it\" gets gold += 5. Choose = to set an exact amount, for example gold = 0 when the player is robbed.",{"id":443,"title":196,"titles":444,"content":445,"level":369},"\u002Fhelp\u002Fgold-coins#_3-offer-the-option-only-when-the-player-can-pay",[5],"Select the merchant's node. On Buy bread (3 coins), click + condition and pick gold. Choose ≥ and enter 3. Now the player only sees Buy bread while they have three coins or more. The option shows a filter badge with its number of conditions on the canvas. To let the player come back to the merchant's options after buying, link the answer back to the merchant's node with Return to options. See Bring the player back to a list of questions.",{"id":447,"title":248,"titles":448,"content":449,"level":369},"\u002Fhelp\u002Fgold-coins#_4-test-it",[5],"Click Show player and play the dialogue. Watch gold in the Variables column while you buy bread: 10, 7, 4, 1. With 1 coin left, Buy bread is faded with gold ≥ 3 next to it. In your game the player won't see it. You can change gold in the Variables column to test other amounts without playing up to them. Click Restart to start again with 10 coins.",{"id":451,"title":296,"titles":452,"content":453,"level":369},"\u002Fhelp\u002Fgold-coins#variations",[5],"Sell only once. Turn on Ask once on Sell my old sword, since the player has only one sword. See Make an option the player can pick only once. Branch on the amount. Give the links from a node conditions, like gold ≥ 100 to one line and no condition to another. The game follows the first link whose conditions are met.",{"id":455,"title":328,"titles":456,"content":457,"level":369},"\u002Fhelp\u002Fgold-coins#in-your-game",[5],"gold is exported with the dialogue's variables and its starting value. A node exports its change in setVariableOnStart with operation set to add or subtract, and the option's condition with operator >=. See Variable v1 and SetVariableOnStart.",{"id":313,"title":314,"titles":459,"content":404,"level":394},[],{"id":461,"title":314,"titles":462,"content":463,"level":394},"\u002Fhelp\u002Foption-only-once#make-an-option-the-player-can-pick-only-once",[],"The case: the player talks to an innkeeper and can ask several questions: Who are you?, What's this town called?, Any work for me?. After each answer the player is back at the list of questions, but a question they have already asked shouldn't be offered again. Goodbye is always there, so the player can leave. The short answer: select the node with the options and turn on Ask once on each question. Then link each answer back to the node's options with Return to options.",{"id":465,"title":466,"titles":467,"content":468,"level":369},"\u002Fhelp\u002Foption-only-once#before-you-start","Before you start",[314],"You need a dialogue with a node that has options, and a node for each answer. If you are starting from scratch: Open your dialogue in the Dialogue Builder. Write the innkeeper's greeting in a node, for example \"Welcome, traveller. What can I do for you?\" Add the questions as options: click + Option on the node, or select the node and click Add option in the inspector. Add a node for each answer, and drag from each option's dot to its answer node.",{"id":470,"title":471,"titles":472,"content":473,"level":369},"\u002Fhelp\u002Foption-only-once#_1-turn-on-ask-once","1. Turn on Ask once",[314],"Click the node with the options to open it in the inspector. Under Options, find the question and turn on Ask once below it. Do the same for every question that should be asked only once. Leave Ask once off on Goodbye. The option's Visible when now shows a once chip, and the option gets a once pill on the canvas, so you can see at a glance which options disappear.",{"id":475,"title":476,"titles":477,"content":478,"level":369},"\u002Fhelp\u002Foption-only-once#_2-bring-the-player-back-to-the-questions","2. Bring the player back to the questions",[314],"An option that is asked once only makes sense if the player comes back to the list. After each answer, link back to the node with the questions: Drag from the answer node's dot to the innkeeper's node. Select the answer node. Under Links, turn on Return to options for the new link. With Return to options, the player skips the innkeeper's greeting and sees the questions again, minus the ones already asked. Without it, the greeting would play again first. Return to options shows only when the link goes to a node that has options. You'll also find it in the inspector when you select the link itself, and on an option's link under Goes to, if an option leads straight back.",{"id":480,"title":481,"titles":482,"content":483,"level":369},"\u002Fhelp\u002Foption-only-once#_3-leave-a-way-out","3. Leave a way out",[314],"Keep at least one option without Ask once that leads on, like Goodbye. If every option is asked once and every one leads back, the player ends up with nothing to pick. The inspector warns you about this on the node: Every option is asked once and leads back here, so the player runs out of options. Add an option that leads on, or turn off Ask once on one of them.",{"id":485,"title":248,"titles":486,"content":487,"level":369},"\u002Fhelp\u002Foption-only-once#_4-test-it",[314],"Click Show player and play the dialogue. Pick Who are you?. After the answer you are back at the questions. Who are you? is now faded, with its condition next to it. Hover it to see Hidden in the game: its condition is not met. In your game the player won't see it at all. The test player still lets you click a faded option, so you can check the rest of the dialogue without starting over. Click Restart to play from the beginning with every question available again.",{"id":489,"title":490,"titles":491,"content":492,"level":369},"\u002Fhelp\u002Foption-only-once#turn-it-off","Turn it off",[314],"Turn off Ask once on the option, or click the cross on its once chip.",{"id":494,"title":296,"titles":495,"content":496,"level":369},"\u002Fhelp\u002Foption-only-once#variations",[314],"Unlock a question after another one. Say Any work for me? should appear only after the player asked Who are you?. On Any work for me?, click + condition, pick stateData.isOptionSelected under Predefined variables, then pick Who are you?. The condition starts as true: the option shows once Who are you? was picked. Click the value to switch it to false for the opposite. React to a line the player has already heard. stateData.isNodePlayed works the same way for nodes: it checks whether the player has already seen a node. Use it on an option, or on a link, to play a different line the second time round. Remember it in other dialogues. Ask once remembers what was picked in this dialogue. If another dialogue needs to know that the player asked the question, use a variable instead: set it on the answer node with Set variable, and check it with + condition wherever you need it.",{"id":498,"title":328,"titles":499,"content":500,"level":369},"\u002Fhelp\u002Foption-only-once#in-your-game",[314],"If you load LoreHub dialogues into your own engine, Ask once is exported as a condition on the option: the option's own stateData.selected must be false. Your game marks an option selected when the player picks it, and checks the conditions again each time it shows the options. The LoreHub Dialogue Player for Godot does this for you. For the JSON, see state data conditions and StateData.",{"id":243,"title":244,"titles":502,"content":416,"level":394},[],{"id":504,"title":244,"titles":505,"content":506,"level":394},"\u002Fhelp\u002Fquestion-hub#bring-the-player-back-to-a-list-of-questions",[],"The case: Sam asks the player if they have questions, and the player can ask them in any order. After each answer, Sam shows the same questions again, until the player says That's all. Sam: Do you have questions?\n  1. Who are you?\n  2. Where are we?\n  3. What time is it now?\n  4. That's all.\nPlayer picks 2.\nSam: Eastbrook, by the old mill.\n  1. Who are you?\n  2. Where are we?\n  3. What time is it now?\n  4. That's all. The short answer: link each answer back to Sam's node and turn on Return to options on that link.",{"id":508,"title":509,"titles":510,"content":511,"level":369},"\u002Fhelp\u002Fquestion-hub#_1-write-the-questions-and-the-answers","1. Write the questions and the answers",[244],"Open your dialogue in the Dialogue Builder. Write Sam's line in a node: \"Do you have questions?\" Add the questions as options: click + Option on the node, or select it and click Add option in the inspector. Add That's all. as the last option. Add a node for each answer, and drag from each question's dot to its answer. Drag from That's all. to the node where the conversation goes on, or to a goodbye line.",{"id":513,"title":514,"titles":515,"content":516,"level":369},"\u002Fhelp\u002Fquestion-hub#_2-link-each-answer-back-to-the-questions","2. Link each answer back to the questions",[244],"Drag from the answer node's dot back to Sam's node. Select the answer node. Under Links, turn on Return to options. Do the same for every answer. With Return to options, the player skips \"Do you have questions?\" and goes straight back to the list. Without it, Sam would say the line again before every list. Return to options shows only when the link goes to a node that has options.",{"id":518,"title":519,"titles":520,"content":521,"level":369},"\u002Fhelp\u002Fquestion-hub#_3-test-it","3. Test it",[244],"Click Show player and play the dialogue. Pick Where are we? and click Continue after the answer. The player shows Back to the options of node_01 and the same four questions again.",{"id":523,"title":296,"titles":524,"content":525,"level":369},"\u002Fhelp\u002Fquestion-hub#variations",[244],"Hide a question once it's asked. Turn on Ask once on the question. See Make an option the player can pick only once. Unlock a question after another one. On the new question, click + condition, pick stateData.isOptionSelected and then the question it depends on.",{"id":527,"title":328,"titles":528,"content":529,"level":369},"\u002Fhelp\u002Fquestion-hub#in-your-game",[244],"A link with Return to options is exported with \"entry\": \"options\". When your game follows it, show the node's options again without its lines, and check each option's conditions again. The LoreHub Dialogue Player for Godot does this for you. See Link v1.1 for the JSON.",1794607929042]