| summaryrefslogtreecommitdiff | 
diff options
Diffstat (limited to 'content/learn')
| -rw-r--r-- | content/learn/03.variables/default.md | 100 | ||||
| -rw-r--r-- | content/learn/04.sequences/default.md | 143 | ||||
| -rw-r--r-- | content/learn/05.files/default.md | 154 | ||||
| -rw-r--r-- | content/learn/06.pointers/default.md | 238 | ||||
| -rw-r--r-- | content/learn/07.structures/default.md | 296 | ||||
| -rw-r--r-- | content/learn/08.collections/default.md | 696 | ||||
| -rw-r--r-- | content/learn/09.lambdas/default.md | 620 | ||||
| -rw-r--r-- | content/learn/10.conditions/default.md | 686 | ||||
| -rw-r--r-- | content/learn/_index.md | 1 | 
9 files changed, 1463 insertions, 1471 deletions
| diff --git a/content/learn/03.variables/default.md b/content/learn/03.variables/default.md index 6c2cdf4..3d0e962 100644 --- a/content/learn/03.variables/default.md +++ b/content/learn/03.variables/default.md @@ -18,61 +18,61 @@ We are trying to add a variable that corresponds to money. An `int` is thus  appropriate.  **main.fate:** +{{< fatecode >}}(fate_version 1) -         (fate_version 1) +(local int hero_money) +(local int price_of_booze) -         (local int hero_money) -         (local int price_of_booze) +(set hero_money 42) +(set price_of_booze 12) -         (set hero_money 42) -         (set price_of_booze 12) +Once upon a time, starting a story with these words wasn't considered +a cliche. Starting in a tavern might also not be seen as very +original.  Having the main character be an street orphan, raised by +some mysterious sage all to end up as a mercenary with an uncommonly +strong sense of honor probably isn't going to lead to any praises for +novelty either. Maybe you should drink to that. +(newline) +Or maybe you shouldn't. This isn't your first mug. Not your second +either.  Drinking to forget that you are a stereotypical hero isn't +going to solve anything. Worse, the alcoholic trait is part of the +image. +(newline) +As you contemplate your own pointless description, your gaze leaves +what turns out to be an already empty glass in your hand and finds the +barman. -         Once upon a time, starting a story with these words wasn't considered -         a cliche. Starting in a tavern might also not be seen as very -         original.  Having the main character be an street orphan, raised by -         some mysterious sage all to end up as a mercenary with an uncommonly -         strong sense of honor probably isn't going to lead to any praises for -         novelty either. Maybe you should drink to that. -         (newline) -         Or maybe you shouldn't. This isn't your first mug. Not your second -         either.  Drinking to forget that you are a stereotypical hero isn't -         going to solve anything. Worse, the alcoholic trait is part of the -         image. -         (newline) -         As you contemplate your own pointless description, your gaze leaves -         what turns out to be an already empty glass in your hand and finds the -         barman. +(player_choice +   ( +      ( Ask the barman for a refill ) +      Staring straight at the barman, you raise your glass and +      proclaim: +      (newline) +      "This soon-to-be world savior needs more booze!" +      (newline) +      The barman's lack of reaction is disappointing, but seeing the +      beer being poured does help improve the mood. +      (newline) +      Satisfied, you hand the barman (var price_of_booze) copper coins. +      (set hero_money +         (- (var hero_money) (var price_of_booze)) +      ) +   ) +   ( +      ( Fall asleep ) +      Deciding to break away from the expected storyline, you promptly +      fall asleep. +      (newline) +      ... +      (newline) +      Upon waking up, your hard-trained reflexes inform you that +      someone stole all your money. +      (set hero_money 0) +   ) +) -         (player_choice -            ( -               ( Ask the barman for a refill ) -               Staring straight at the barman, you raise your glass and -               proclaim: -               (newline) -               "This soon-to-be world savior needs more booze!" -               (newline) -               The barman's lack of reaction is disappointing, but seeing the -               beer being poured does help improve the mood. -               (newline) -               Satisfied, you hand the barman (var price_of_booze) copper coins. -               (set hero_money -                  (- (var hero_money) (var price_of_booze)) -               ) -            ) -            ( -               ( Fall asleep ) -               Deciding to break away from the expected storyline, you promptly -               fall asleep. -               (newline) -               ... -               (newline) -               Upon waking up, your hard-trained reflexes inform you that -               someone stole all your money. -               (set hero_money 0) -            ) -         ) - -         (end) +(end) +{{< /fatecode >}}  * `(local int hero_money)` declares an `int` variable with the name    `hero_money`. diff --git a/content/learn/04.sequences/default.md b/content/learn/04.sequences/default.md index cecbff8..8b56ee7 100644 --- a/content/learn/04.sequences/default.md +++ b/content/learn/04.sequences/default.md @@ -29,77 +29,78 @@ Sequences can take parameters.  **main.fate:** -         (fate_version 1) - -         (global int hero_money) - -         (set hero_money 42) - -         Once upon a time, starting a story with these words wasn't considered -         a cliche. Starting in a tavern might also not be seen as very -         original.  Having the main character be an street orphan, raised by -         some mysterious sage all to end up as a mercenary with an uncommonly -         strong sense of honor probably isn't going to lead to any praises for -         novelty either. Maybe you should drink to that. -         (newline) -         Or maybe you shouldn't. This isn't your first mug. Not your second -         either.  Drinking to forget that you are a stereotypical hero isn't -         going to solve anything. Worse, the alcoholic trait is part of the -         image. -         (newline) -         As you contemplate your own pointless description, your gaze leaves -         what turns out to be an already empty glass in your hand and finds the -         barman. - -         (player_choice -            ( -               ( Ask the barman for a refill ) -               (visit get_a_refill) -            ) -            ( -               ( Fall asleep ) -               (jump_to fall_asleep) -            ) -         ) - -         (define_sequence pay ( (int cost) ) -            (set hero_money -               (- (var hero_money) (var cost)) -            ) -         ) - -         (define_sequence get_a_refill () -            (local int price_of_booze) - -            (set price_of_booze 12) - -            Staring straight at the barman, you raise your glass and proclaim: -            (newline) -            "This soon-to-be world savior needs more booze!" -            (newline) -            The barman's lack of reaction is disappointing, but seeing the beer -            being poured does help improve the mood. -            (newline) -            Satisfied, you hand the barman (var price_of_booze) copper coins. -            (visit pay (var price_of_booze)) -         ) - -         (define_sequence fall_asleep () -            Deciding to break away from the expected storyline, you promptly -            fall asleep. -            (newline) -            ... -            (newline) -            Upon waking up, your hard-trained reflexes inform you that someone -            stole all your money. -            (set hero_money 0) -            (newline) -            This set-back was more than you could take. You give up on this -            barely coherent story. -            (end) -         ) - -         (end) +{{< fatecode >}}(fate_version 1) + +(global int hero_money) + +(set hero_money 42) + +Once upon a time, starting a story with these words wasn't considered +a cliche. Starting in a tavern might also not be seen as very +original.  Having the main character be an street orphan, raised by +some mysterious sage all to end up as a mercenary with an uncommonly +strong sense of honor probably isn't going to lead to any praises for +novelty either. Maybe you should drink to that. +(newline) +Or maybe you shouldn't. This isn't your first mug. Not your second +either.  Drinking to forget that you are a stereotypical hero isn't +going to solve anything. Worse, the alcoholic trait is part of the +image. +(newline) +As you contemplate your own pointless description, your gaze leaves +what turns out to be an already empty glass in your hand and finds the +barman. + +(player_choice +   ( +      ( Ask the barman for a refill ) +      (visit get_a_refill) +   ) +   ( +      ( Fall asleep ) +      (jump_to fall_asleep) +   ) +) + +(define_sequence pay ( (int cost) ) +   (set hero_money +      (- (var hero_money) (var cost)) +   ) +) + +(define_sequence get_a_refill () +   (local int price_of_booze) + +   (set price_of_booze 12) + +   Staring straight at the barman, you raise your glass and proclaim: +   (newline) +   "This soon-to-be world savior needs more booze!" +   (newline) +   The barman's lack of reaction is disappointing, but seeing the beer +   being poured does help improve the mood. +   (newline) +   Satisfied, you hand the barman (var price_of_booze) copper coins. +   (visit pay (var price_of_booze)) +) + +(define_sequence fall_asleep () +   Deciding to break away from the expected storyline, you promptly +   fall asleep. +   (newline) +   ... +   (newline) +   Upon waking up, your hard-trained reflexes inform you that someone +   stole all your money. +   (set hero_money 0) +   (newline) +   This set-back was more than you could take. You give up on this +   barely coherent story. +   (end) +) + +(end) +{{< /fatecode >}}  * `(visit get_a_refill)` makes a visit to the sequence `get_a_refill`. Since     that sequence does not take parameters, none need to be provided. diff --git a/content/learn/05.files/default.md b/content/learn/05.files/default.md index da78206..06b6436 100644 --- a/content/learn/05.files/default.md +++ b/content/learn/05.files/default.md @@ -13,101 +13,103 @@ but only if that file has not already been explored.  * Create a new file, `data.fate`, with the following content: -         (fate_version 1) +{{< fatecode >}}(fate_version 1) -         (global int hero_money) +(global int hero_money) -         (set hero_money 42) +(set hero_money 42) +{{< /fatecode >}}  * Create a new file, `actions.fate`, with the following content: -         (fate_version 1) +{{< fatecode >}}(fate_version 1) -         (require data.fate) +(require data.fate) -         (define_sequence pay ( (int cost) ) -            (set hero_money -               (- (var hero_money) (var cost)) -            ) -         ) +(define_sequence pay ( (int cost) ) +   (set hero_money +      (- (var hero_money) (var cost)) +   ) +) +{{< /fatecode >}}  * Create a new file, `get_a_refill.fate`, with the following content: -         (fate_version 1) +{{< fatecode >}}(fate_version 1) -         (require actions.fate) +(require actions.fate) -         (define_sequence get_a_refill () -            (local int price_of_booze) +(define_sequence get_a_refill () +   (local int price_of_booze) -            (set price_of_booze 12) +   (set price_of_booze 12) -            Staring straight at the barman, you raise your glass and proclaim: -            (newline) -            "This soon-to-be world savior needs more booze!" -            (newline) -            The barman's lack of reaction is disappointing, but seeing the beer -            being poured does help improve the mood. -            (newline) -            Satisfied, you hand the barman (var price_of_booze) copper coins. -            (visit pay (var price_of_booze)) -         ) +   Staring straight at the barman, you raise your glass and proclaim: +   (newline) +   "This soon-to-be world savior needs more booze!" +   (newline) +   The barman's lack of reaction is disappointing, but seeing the beer being +   poured does help improve the mood. +   (newline) +   Satisfied, you hand the barman (var price_of_booze) copper coins. +   (visit pay (var price_of_booze)) +) +{{< /fatecode >}}  * Create a new file, `falling_asleep.fate`, with the following content: -         (fate_version 1) - -         (require data.fate) - -         (define_sequence fall_asleep () -            Deciding to break away from the expected storyline, you promptly -            fall asleep. -            (newline) -            ... -            (newline) -            Upon waking up, your hard-trained reflexes inform you that someone -            stole all your money. -            (set hero_money 0) -            (newline) -            This set-back was more than you could take. You give up on this -            barely coherent story. -            (end) -         ) +{{< fatecode >}}(fate_version 1) + +(require data.fate) + +(define_sequence fall_asleep () +   Deciding to break away from the expected storyline, you promptly fall +   asleep. +   (newline) +   ... +   (newline) +   Upon waking up, your hard-trained reflexes inform you that someone stole all +   your money. +   (set hero_money 0) +   (newline) +   This set-back was more than you could take. You give up on this barely +   coherent story. +   (end) +) +{{< /fatecode >}}  **main.fate:** -         (fate_version 1) - -         Once upon a time, starting a story with these words wasn't considered -         a cliche. Starting in a tavern might also not be seen as very -         original.  Having the main character be an street orphan, raised by -         some mysterious sage all to end up as a mercenary with an uncommonly -         strong sense of honor probably isn't going to lead to any praises for -         novelty either. Maybe you should drink to that. -         (newline) -         Or maybe you shouldn't. This isn't your first mug. Not your second -         either.  Drinking to forget that you are a stereotypical hero isn't -         going to solve anything. Worse, the alcoholic trait is part of the -         image. -         (newline) -         As you contemplate your own pointless description, your gaze leaves -         what turns out to be an already empty glass in your hand and finds the -         barman. - -         (player_choice -            ( -               ( Ask the barman for a refill ) -               (visit get_a_refill) -            ) -            ( -               ( Fall asleep ) -               (jump_to fall_asleep) -            ) -         ) - -         (require get_a_refill.fate) -         (require falling_asleep.fate) - -         (end) +{{< fatecode >}}(fate_version 1) + +Once upon a time, starting a story with these words wasn't considered a cliche. +Starting in a tavern might also not be seen as very original.  Having the main +character be an street orphan, raised by some mysterious sage all to end up as +a mercenary with an uncommonly strong sense of honor probably isn't going to +lead to any praises for novelty either. Maybe you should drink to that. +(newline) +Or maybe you shouldn't. This isn't your first mug. Not your second either. +Drinking to forget that you are a stereotypical hero isn't going to solve +anything. Worse, the alcoholic trait is part of the image. +(newline) +As you contemplate your own pointless description, your gaze leaves what turns +out to be an already empty glass in your hand and finds the barman. + +(player_choice +   ( +      ( Ask the barman for a refill ) +      (visit get_a_refill) +   ) +   ( +      ( Fall asleep ) +      (jump_to fall_asleep) +   ) +) + +(require get_a_refill.fate) +(require falling_asleep.fate) + +(end) +{{< /fatecode >}}  With this, the story is much more easy to follow. Let's continue by looking  at [the actually-not-scary-at-all pointers](/learn/pointers). diff --git a/content/learn/06.pointers/default.md b/content/learn/06.pointers/default.md index a4108bb..8432b3e 100644 --- a/content/learn/06.pointers/default.md +++ b/content/learn/06.pointers/default.md @@ -22,69 +22,68 @@ Given a pointer `p`, the variable being pointed to can be referred to using  `(at p)`.  **data.fate:** +{{< fatecode >}}(fate_version 1) -         (fate_version 1) - -         (global int hero_money) -         (global string hero_name) - -         (set hero_money 42) +(global int hero_money) +(global string hero_name) +(set hero_money 42) +{{< /fatecode >}}  **get_a_refill.fate:** - -         (fate_version 1) - -         (require data.fate) -         (require actions.fate) - -         (define_sequence lower_price_of_booze -            ( -               ((ptr int) price_pointer) -               (int decrease) -            ) -            Great! The price of booze just lowered from (at price_pointer) -            (set (at price_pointer) -               (- -                  (at price_pointer) -                  (var decrease) -               ) -            ) -            to (at price_pointer)! -         ) - -         (define_sequence get_a_refill () -            (local int price_of_booze) - -            (set price_of_booze 12) - -            Staring straight at the barman, you raise your glass and proclaim: -            (newline) -            "This soon-to-be world savior needs more booze!" -            (newline) -            The barman's lack of reaction is disappointing, but seeing the beer -            being poured does help improve the mood. -            (newline) -            Satisfied, you hand the barman (var price_of_booze) copper coins. -            (visit pay (var price_of_booze)) -            (newline) -            The barman sighs, then asks: -            (prompt_string (ptr hero_name) 2 64 What is your name, then, hero?) -            (var hero_name)? -            (newline) -            The barman looks surprised. -            (newline) -            (visit lower_price_of_booze (ptr price_of_booze) 4) -            (newline) -            "I have heard of you, (var hero_name)," the barman exclaims, "I have -            a quest for you!" -            (newline) -            It's your turn to sigh. -            (newline) -            The barman hands you a bag, and says: -            (newline) -            "Take this pre-payment and head to the smithy." -            (newline) -         ) +{{< fatecode >}}(fate_version 1) + +(require data.fate) +(require actions.fate) + +(define_sequence lower_price_of_booze +   ( +      ((ptr int) price_pointer) +      (int decrease) +   ) +   Great! The price of booze just lowered from (at price_pointer) +   (set (at price_pointer) +      (- +         (at price_pointer) +         (var decrease) +      ) +   ) +   to (at price_pointer)! +) + +(define_sequence get_a_refill () +   (local int price_of_booze) + +   (set price_of_booze 12) + +   Staring straight at the barman, you raise your glass and proclaim: +   (newline) +   "This soon-to-be world savior needs more booze!" +   (newline) +   The barman's lack of reaction is disappointing, but seeing the beer being +   poured does help improve the mood. +   (newline) +   Satisfied, you hand the barman (var price_of_booze) copper coins. +   (visit pay (var price_of_booze)) +   (newline) +   The barman sighs, then asks: +   (prompt_string (ptr hero_name) 2 64 What is your name, then, hero?) +   (var hero_name)? +   (newline) +   The barman looks surprised. +   (newline) +   (visit lower_price_of_booze (ptr price_of_booze) 4) +   (newline) +   "I have heard of you, (var hero_name)," the barman exclaims, "I have a quest +   for you!" +   (newline) +   It's your turn to sigh. +   (newline) +   The barman hands you a bag, and says: +   (newline) +   "Take this pre-payment and head to the smithy." +   (newline) +) +{{< /fatecode >}}  * `(prompt_string (ptr hero_name) 2 64 What is your name, then, hero?)` prompts    the player with `What is your name, then, hero?` and expects a string input @@ -102,70 +101,67 @@ sheet, so [let's create one](/learn/structures).  ## Unchanged Files  **actions.fate:** +{{< fatecode >}}(fate_version 1) -         (fate_version 1) +(require data.fate) -         (require data.fate) - -         (define_sequence pay ( (int cost) ) -            (set hero_money -               (- (var hero_money) (var cost)) -            ) -         ) +(define_sequence pay ( (int cost) ) +   (set hero_money +      (- (var hero_money) (var cost)) +   ) +) +{{< /fatecode >}}  **falling_asleep.fate:** - -         (fate_version 1) - -         (require data.fate) - -         (define_sequence fall_asleep () -            Deciding to break away from the expected storyline, you promptly -            fall asleep. -            (newline) -            ... -            (newline) -            Upon waking up, your hard-trained reflexes inform you that someone -            stole all your money. -            (set hero_money 0) -            (newline) -            This set-back was more than you could take. You give up on this -            barely coherent story. -            (end) -         ) +{{< fatecode >}}(fate_version 1) + +(require data.fate) + +(define_sequence fall_asleep () +   Deciding to break away from the expected storyline, you promptly fall +   asleep. +   (newline) +   ... +   (newline) +   Upon waking up, your hard-trained reflexes inform you that someone stole all +   your money. +   (set hero_money 0) +   (newline) +   This set-back was more than you could take. You give up on this barely +   coherent story. +   (end) +) +{{< /fatecode >}}  **main.fate:** - -         (fate_version 1) - -         Once upon a time, starting a story with these words wasn't considered -         a cliche. Starting in a tavern might also not be seen as very -         original.  Having the main character be an street orphan, raised by -         some mysterious sage all to end up as a mercenary with an uncommonly -         strong sense of honor probably isn't going to lead to any praises for -         novelty either. Maybe you should drink to that. -         (newline) -         Or maybe you shouldn't. This isn't your first mug. Not your second -         either.  Drinking to forget that you are a stereotypical hero isn't -         going to solve anything. Worse, the alcoholic trait is part of the -         image. -         (newline) -         As you contemplate your own pointless description, your gaze leaves -         what turns out to be an already empty glass in your hand and finds the -         barman. - -         (player_choice -            ( -               ( Ask the barman for a refill ) -               (visit get_a_refill) -            ) -            ( -               ( Fall asleep ) -               (jump_to fall_asleep) -            ) -         ) - -         (require get_a_refill.fate) -         (require falling_asleep.fate) - -         (end) +{{< fatecode >}}(fate_version 1) + +Once upon a time, starting a story with these words wasn't considered a cliche. +Starting in a tavern might also not be seen as very original.  Having the main +character be an street orphan, raised by some mysterious sage all to end up as +a mercenary with an uncommonly strong sense of honor probably isn't going to +lead to any praises for novelty either. Maybe you should drink to that. +(newline) +Or maybe you shouldn't. This isn't your first mug. Not your second either. +Drinking to forget that you are a stereotypical hero isn't going to solve +anything. Worse, the alcoholic trait is part of the image. +(newline) +As you contemplate your own pointless description, your gaze leaves what turns +out to be an already empty glass in your hand and finds the barman. + +(player_choice +   ( +      ( Ask the barman for a refill ) +      (visit get_a_refill) +   ) +   ( +      ( Fall asleep ) +      (jump_to fall_asleep) +   ) +) + +(require get_a_refill.fate) +(require falling_asleep.fate) + +(end) +{{< /fatecode >}} diff --git a/content/learn/07.structures/default.md b/content/learn/07.structures/default.md index a87af08..8e2dede 100644 --- a/content/learn/07.structures/default.md +++ b/content/learn/07.structures/default.md @@ -24,41 +24,41 @@ instead of a instruction: the structure is not modified, but a copy with the  modifications performed is returned.  **data.fate:** - -         (fate_version 1) - -         (declare_structure weapon -            (text name) -            (int attack) -            (int precision) -         ) - -         (declare_structure armor -            (text name) -            (int defense) -         ) - -         (declare_structure character -            (string name) -            (int money) -            (weapon weapon) -            (armor armor) -         ) - -         (global character hero) - -         (set_fields! hero.weapon -            (name (text "Legendary" sword)) -            (attack 3) -            (precision 50) -         ) - -         (set_fields! hero.armor -            (name (text "Refined" attire)) -            (defense 1) -         ) - -         (set hero.money 42) +{{< fatecode >}}(fate_version 1) + +(declare_structure weapon +   (text name) +   (int attack) +   (int precision) +) + +(declare_structure armor +   (text name) +   (int defense) +) + +(declare_structure character +   (string name) +   (int money) +   (weapon weapon) +   (armor armor) +) + +(global character hero) + +(set_fields! hero.weapon +   (name (text "Legendary" sword)) +   (attack 3) +   (precision 50) +) + +(set_fields! hero.armor +   (name (text "Refined" attire)) +   (defense 1) +) + +(set hero.money 42) +{{< /fatecode >}}  * `(text "Refined" attire)` generates a `text` value containing a textual    representation of the values passed as parameter. `"Refined" attire` is, by @@ -76,126 +76,124 @@ collection is available at the smithy](/learn/collections).  ## (Mostly) Unchanged Files  **get_a_refill.fate:** - -         (fate_version 1) - -         (require data.fate) -         (require actions.fate) - -         (define_sequence lower_price_of_booze -            ( -               ((ptr int) price_pointer) -               (int decrease) -            ) -            Great! The price of booze just lowered from (at price_pointer) -            (set (at price_pointer) -               (- -                  (at price_pointer) -                  (var decrease) -               ) -            ) -            to (at price_pointer)! -         ) - -         (define_sequence get_a_refill () -            (local int price_of_booze) - -            (set price_of_booze 12) - -            Staring straight at the barman, you raise your glass and proclaim: -            (newline) -            "This soon-to-be world savior needs more booze!" -            (newline) -            The barman's lack of reaction is disappointing, but seeing the beer -            being poured does help improve the mood. -            (newline) -            Satisfied, you hand the barman (var price_of_booze) copper coins. -            (visit pay (var price_of_booze)) -            (newline) -            The barman sighs, then asks: -            (prompt_string (ptr hero.name) 2 64 What is your name, then, hero?) -            (var hero.name)? -            (newline) -            The barman looks surprised. -            (newline) -            (visit lower_price_of_booze (ptr price_of_booze) 4) -            (newline) -            "I have heard of you, (var hero.name)," the barman exclaims, "I have -            a quest for you!" -            (newline) -            It's your turn to sigh. -            (newline) -            The barman hands you a bag, and says: -            (newline) -            "Take this pre-payment and head to the smithy." -            (newline) -         ) +{{< fatecode >}}(fate_version 1) + +(require data.fate) +(require actions.fate) + +(define_sequence lower_price_of_booze +   ( +      ((ptr int) price_pointer) +      (int decrease) +   ) +   Great! The price of booze just lowered from (at price_pointer) +   (set (at price_pointer) +      (- +         (at price_pointer) +         (var decrease) +      ) +   ) +   to (at price_pointer)! +) + +(define_sequence get_a_refill () +   (local int price_of_booze) + +   (set price_of_booze 12) + +   Staring straight at the barman, you raise your glass and proclaim: +   (newline) +   "This soon-to-be world savior needs more booze!" +   (newline) +   The barman's lack of reaction is disappointing, but seeing the beer being +   poured does help improve the mood. +   (newline) +   Satisfied, you hand the barman (var price_of_booze) copper coins. +   (visit pay (var price_of_booze)) +   (newline) +   The barman sighs, then asks: +   (prompt_string (ptr hero.name) 2 64 What is your name, then, hero?) +   (var hero.name)? +   (newline) +   The barman looks surprised. +   (newline) +   (visit lower_price_of_booze (ptr price_of_booze) 4) +   (newline) +   "I have heard of you, (var hero.name)," the barman exclaims, "I have a quest +   for you!" +   (newline) +   It's your turn to sigh. +   (newline) +   The barman hands you a bag, and says: +   (newline) +   "Take this pre-payment and head to the smithy." +   (newline) +) +{{< /fatecode >}}  **actions.fate:** +{{< fatecode >}}(fate_version 1) -         (fate_version 1) +(require data.fate) -         (require data.fate) - -         (define_sequence pay ( (int cost) ) -            (set hero_money -               (- (var hero.money) (var cost)) -            ) -         ) +(define_sequence pay ( (int cost) ) +   (set hero_money +      (- (var hero.money) (var cost)) +   ) +) +{{< /fatecode >}}  **falling_asleep.fate:** -         (fate_version 1) - -         (require data.fate) - -         (define_sequence fall_asleep () -            Deciding to break away from the expected storyline, you promptly -            fall asleep. -            (newline) -            ... -            (newline) -            Upon waking up, your hard-trained reflexes inform you that someone -            stole all your money. -            (set hero.money 0) -            (newline) -            This set-back was more than you could take. You give up on this -            barely coherent story. -            (end) -         ) +{{< fatecode >}}(fate_version 1) + +(require data.fate) + +(define_sequence fall_asleep () +   Deciding to break away from the expected storyline, you promptly fall +   asleep. +   (newline) +   ... +   (newline) +   Upon waking up, your hard-trained reflexes inform you that someone stole all +   your money. +   (set hero.money 0) +   (newline) +   This set-back was more than you could take. You give up on this barely +   coherent story. +   (end) +) +{{< /fatecode >}}  **main.fate:** - -         (fate_version 1) - -         Once upon a time, starting a story with these words wasn't considered -         a cliche. Starting in a tavern might also not be seen as very -         original.  Having the main character be an street orphan, raised by -         some mysterious sage all to end up as a mercenary with an uncommonly -         strong sense of honor probably isn't going to lead to any praises for -         novelty either. Maybe you should drink to that. -         (newline) -         Or maybe you shouldn't. This isn't your first mug. Not your second -         either.  Drinking to forget that you are a stereotypical hero isn't -         going to solve anything. Worse, the alcoholic trait is part of the -         image. -         (newline) -         As you contemplate your own pointless description, your gaze leaves -         what turns out to be an already empty glass in your hand and finds the -         barman. - -         (player_choice -            ( -               ( Ask the barman for a refill ) -               (visit get_a_refill) -            ) -            ( -               ( Fall asleep ) -               (jump_to fall_asleep) -            ) -         ) - -         (require get_a_refill.fate) -         (require falling_asleep.fate) - -         (end) +{{< fatecode >}}(fate_version 1) + +Once upon a time, starting a story with these words wasn't considered a cliche. +Starting in a tavern might also not be seen as very original.  Having the main +character be an street orphan, raised by some mysterious sage all to end up as +a mercenary with an uncommonly strong sense of honor probably isn't going to +lead to any praises for novelty either. Maybe you should drink to that. +(newline) +Or maybe you shouldn't. This isn't your first mug. Not your second either. +Drinking to forget that you are a stereotypical hero isn't going to solve +anything. Worse, the alcoholic trait is part of the image. +(newline) +As you contemplate your own pointless description, your gaze leaves what turns +out to be an already empty glass in your hand and finds the barman. + +(player_choice +   ( +      ( Ask the barman for a refill ) +      (visit get_a_refill) +   ) +   ( +      ( Fall asleep ) +      (jump_to fall_asleep) +   ) +) + +(require get_a_refill.fate) +(require falling_asleep.fate) + +(end) +{{< /fatecode >}} diff --git a/content/learn/08.collections/default.md b/content/learn/08.collections/default.md index b4bae98..34310f3 100644 --- a/content/learn/08.collections/default.md +++ b/content/learn/08.collections/default.md @@ -20,56 +20,57 @@ There are [quite a few computations](/fate_v1/computations/collections) and  collections.  Let's add a new file, `smithy_inventory.fate`: -         (fate_version 1) - -         (require data.fate) - -         (global (list (cons weapon int)) smithy_weapons) -         (global (list (cons weapon int)) smithy_armors) - -         (add! -            (cons -               (set_fields (default weapon) -                  (name (text An Iron Rod)) -                  (attack 10) -                  (precision 70) -               ) -               176 -            ) -            smithy_weapons -         ) -         (add! -            (cons -               (set_fields (default weapon) -                  (name (text A Magnificient Brick)) -                  (attack 6) -                  (precision 90) -               ) -               110 -            ) -            smithy_weapons -         ) - -         (add! -            (cons -               (set_fields (default armor) -                  (name (text A raincoat?!)) -                  (defense 7) -               ) -               160 -            ) -            smithy_armors -         ) -         (add! -            (cons -               (set_fields (default armor) -                  (name (text A nice cape)) -                  (defense 3) -               ) -               50 -            ) -            smithy_armors -         ) +{{< fatecode >}}(fate_version 1) + +(require data.fate) + +(global (list (cons weapon int)) smithy_weapons) +(global (list (cons weapon int)) smithy_armors) + +(add! +   (cons +      (set_fields (default weapon) +         (name (text An Iron Rod)) +         (attack 10) +         (precision 70) +      ) +      176 +   ) +   smithy_weapons +) +(add! +   (cons +      (set_fields (default weapon) +         (name (text A Magnificient Brick)) +         (attack 6) +         (precision 90) +      ) +      110 +   ) +   smithy_weapons +) + +(add! +   (cons +      (set_fields (default armor) +         (name (text A raincoat?!)) +         (defense 7) +      ) +      160 +   ) +   smithy_armors +) +(add! +   (cons +      (set_fields (default armor) +         (name (text A nice cape)) +         (defense 3) +      ) +      50 +   ) +   smithy_armors +) +{{< /fatecode >}}  We'll also need the actual smithy scene, so let's put in another file,  `smithy.fate`. @@ -78,155 +79,155 @@ We'll also need the actual smithy scene, so let's put in another file,  going to introduce a lot of things to make it *much*, *much* easier to write.  **smithy.fate:** - -         (fate_version 1) - -         (require smithy_inventory.fate) - -         (define_sequence visit_smithy () -            ;; This thing is going to show up every time, which isn't great. -            As you approach the smithy, you notice that no one's there. All the -            wares are out for selling. It's almost as if this story didn't need -            more examples of lengthy dialogues. -            (newline) -            ;; We'll want to start here the next time we enter this sequence. -            You have (var hero.money) coins. -            (newline) -            What will you look at? -            (player_choice -               ( -                  ( Let's see the weapons ) -                  (jump_to see_weapons) -               ) -               ( -                  ( Let's see the armors ) -                  (jump_to see_armors) -               ) -               ( -                  ( Nothing, let's go back to the bar ) -               ) -            ) -         ) - -         (define_sequence see_weapons () -            ;; We'll soon replace this mess with something way better. - -            (local text weapon_a_label) -            (local text weapon_b_label) - -            (visit get_weapon_label -               (access smithy_weapons 0) -               (ptr weapon_a_label) -            ) -            (visit get_weapon_label -               (access smithy_weapons 1) -               (ptr weapon_b_label) -            ) - -            (player_choice -               ( -                  ( (var weapon_a_label) ) -                  (visit buy_weapon (access smithy_weapons 0)) -                  (jump_to visit_smithy) -               ) -               ( -                  ( (var weapon_a_label) ) -                  (visit buy_weapon (access smithy_weapons 1)) -                  (jump_to visit_smithy) -               ) -               ( -                  ( Nevermind ) -                  (jump_to visit_smithy) -               ) -            ) -         ) - -         (define_sequence see_armors () -            ;; We'll soon replace this mess with something way better. - -            (local text armor_a_label) -            (local text armor_b_label) - -            (visit get_armor_label -               (access smithy_armors 0) -               (ptr armor_a_label) -            ) -            (visit get_armor_label -               (access smithy_armors 1) -               (ptr armor_b_label) -            ) - -            (player_choice -               ( -                  ( (var armor_a_label) ) -                  (visit buy_armor (access smithy_armors 0)) -                  (jump_to visit_smithy) -               ) -               ( -                  ( (var armor_a_label) ) -                  (visit buy_armor (access smithy_armors 1)) -                  (jump_to visit_smithy) -               ) -               ( -                  ( Nevermind ) -                  (jump_to visit_smithy) -               ) -            ) -         ) - -         ;; A terrible way to get labels -         (define_sequence get_weapon_label -            ( -               ((cons weapon int) weapon_offer) -               ((ptr text) label) -            ) -            (local weapon weapon) -            (local int price) - -            (set weapon (car weapon_offer)) -            (set price (cdr weapon_offer)) - -            (set (at label) -               ( -                   Buy "(var weapon.name)" \(attack: (var weapon.attack), -                   precision: (var weapon.precision)\) for (var price) coins. -               ) -            ) -         ) - -         ;; A terrible way to get labels -         (define_sequence get_armor_label -            ( -               ((cons armor int) armor_offer) -               ((ptr text) label) -            ) -            (local armor armor) -            (local int price) - -            (set armor (car armor_offer)) -            (set price (cdr armor_offer)) - -            (set (at label) -               ( -                   Buy "(var armor.name)" \(defense: (var armor.defense)\), -                   for (var price) coins. -               ) -            ) -         ) - -         (define_sequence buy_weapon ( ((cons weapon int) weapon) ) -            ;; We can't even deny a sell yet... -            (set hero.weapon (car weapon)) -            Equipped (var hero.weapon.name). -            (newline) -         ) - -         (define_sequence buy_armor ( ((cons armor int) armor) ) -            ;; We can't even deny a sell yet... -            (set hero.armor (car armor)) -            Equipped (var hero.armor.name). -            (newline) -         ) +{{< fatecode >}}(fate_version 1) + +(require smithy_inventory.fate) + +(define_sequence visit_smithy () +   ;; This thing is going to show up every time, which isn't great. +   As you approach the smithy, you notice that no one's there. All the wares +   are out for selling. It's almost as if this story didn't need more examples +   of lengthy dialogues. +   (newline) +   ;; We'll want to start here the next time we enter this sequence. +   You have (var hero.money) coins. +   (newline) +   What will you look at? +   (player_choice +      ( +         ( Let's see the weapons ) +         (jump_to see_weapons) +      ) +      ( +         ( Let's see the armors ) +         (jump_to see_armors) +      ) +      ( +         ( Nothing, let's go back to the bar ) +      ) +   ) +) + +(define_sequence see_weapons () +   ;; We'll soon replace this mess with something way better. + +   (local text weapon_a_label) +   (local text weapon_b_label) + +   (visit get_weapon_label +      (access smithy_weapons 0) +      (ptr weapon_a_label) +   ) +   (visit get_weapon_label +      (access smithy_weapons 1) +      (ptr weapon_b_label) +   ) + +   (player_choice +      ( +         ( (var weapon_a_label) ) +         (visit buy_weapon (access smithy_weapons 0)) +         (jump_to visit_smithy) +      ) +      ( +         ( (var weapon_a_label) ) +         (visit buy_weapon (access smithy_weapons 1)) +         (jump_to visit_smithy) +      ) +      ( +         ( Nevermind ) +         (jump_to visit_smithy) +      ) +   ) +) + +(define_sequence see_armors () +   ;; We'll soon replace this mess with something way better. + +   (local text armor_a_label) +   (local text armor_b_label) + +   (visit get_armor_label +      (access smithy_armors 0) +      (ptr armor_a_label) +   ) +   (visit get_armor_label +      (access smithy_armors 1) +      (ptr armor_b_label) +   ) + +   (player_choice +      ( +         ( (var armor_a_label) ) +         (visit buy_armor (access smithy_armors 0)) +         (jump_to visit_smithy) +      ) +      ( +         ( (var armor_a_label) ) +         (visit buy_armor (access smithy_armors 1)) +         (jump_to visit_smithy) +      ) +      ( +         ( Nevermind ) +         (jump_to visit_smithy) +      ) +   ) +) + +;; A terrible way to get labels +(define_sequence get_weapon_label +   ( +      ((cons weapon int) weapon_offer) +      ((ptr text) label) +   ) +   (local weapon weapon) +   (local int price) + +   (set weapon (car weapon_offer)) +   (set price (cdr weapon_offer)) + +   (set (at label) +      ( +          Buy "(var weapon.name)" \(attack: (var weapon.attack), +          precision: (var weapon.precision)\) for (var price) coins. +      ) +   ) +) + +;; A terrible way to get labels +(define_sequence get_armor_label +   ( +      ((cons armor int) armor_offer) +      ((ptr text) label) +   ) +   (local armor armor) +   (local int price) + +   (set armor (car armor_offer)) +   (set price (cdr armor_offer)) + +   (set (at label) +      ( +          Buy "(var armor.name)" \(defense: (var armor.defense)\), +          for (var price) coins. +      ) +   ) +) + +(define_sequence buy_weapon ( ((cons weapon int) weapon) ) +   ;; We can't even deny a sell yet... +   (set hero.weapon (car weapon)) +   Equipped (var hero.weapon.name). +   (newline) +) + +(define_sequence buy_armor ( ((cons armor int) armor) ) +   ;; We can't even deny a sell yet... +   (set hero.armor (car armor)) +   Equipped (var hero.armor.name). +   (newline) +) +{{< /fatecode >}}  * `(list (cons weapon int))` indicates a list of `weapon` and `int` pairs.  * `(add! something smithy_weapons)` adds `something` to the `smithy_weapons` @@ -246,163 +247,160 @@ start with the least expected one: [lambda functions](/learn/lambdas).  ## Unchanged Files  **data.fate:** - -         (fate_version 1) - -         (declare_structure weapon -            (text name) -            (int attack) -            (int precision) -         ) - -         (declare_structure armor -            (text name) -            (int defense) -         ) - -         (declare_structure character -            (string name) -            (int money) -            (weapon weapon) -            (armor armor) -         ) - -         (global character hero) - -         (set_fields! hero.weapon -            (name (text "Legendary" sword)) -            (attack 3) -            (precision 50) -         ) - -         (set_fields! hero.armor -            (name (text "Refined" attire)) -            (defense 1) -         ) - -         (set hero.money 42) +{{< fatecode >}}(fate_version 1) + +(declare_structure weapon +   (text name) +   (int attack) +   (int precision) +) + +(declare_structure armor +   (text name) +   (int defense) +) + +(declare_structure character +   (string name) +   (int money) +   (weapon weapon) +   (armor armor) +) + +(global character hero) + +(set_fields! hero.weapon +   (name (text "Legendary" sword)) +   (attack 3) +   (precision 50) +) + +(set_fields! hero.armor +   (name (text "Refined" attire)) +   (defense 1) +) + +(set hero.money 42) +{{< /fatecode >}}  **get_a_refill.fate:** - -         (fate_version 1) - -         (require data.fate) -         (require actions.fate) - -         (define_sequence lower_price_of_booze -            ( -               ((ptr int) price_pointer) -               (int decrease) -            ) -            Great! The price of booze just lowered from (at price_pointer) -            (set (at price_pointer) -               (- -                  (at price_pointer) -                  (var decrease) -               ) -            ) -            to (at price_pointer)! -         ) - -         (define_sequence get_a_refill () -            (local int price_of_booze) - -            (set price_of_booze 12) - -            Staring straight at the barman, you raise your glass and proclaim: -            (newline) -            "This soon-to-be world savior needs more booze!" -            (newline) -            The barman's lack of reaction is disappointing, but seeing the beer -            being poured does help improve the mood. -            (newline) -            Satisfied, you hand the barman (var price_of_booze) copper coins. -            (visit pay (var price_of_booze)) -            (newline) -            The barman sighs, then asks: -            (prompt_string (ptr hero.name) 2 64 What is your name, then, hero?) -            (var hero.name)? -            (newline) -            The barman looks surprised. -            (newline) -            (visit lower_price_of_booze (ptr price_of_booze) 4) -            (newline) -            "I have heard of you, (var hero.name)," the barman exclaims, "I have -            a quest for you!" -            (newline) -            It's your turn to sigh. -            (newline) -            The barman hands you a bag, and says: -            (newline) -            "Take this pre-payment and head to the smithy." -            (newline) -         ) +{{< fatecode >}}(fate_version 1) + +(require data.fate) +(require actions.fate) + +(define_sequence lower_price_of_booze +   ( +      ((ptr int) price_pointer) +      (int decrease) +   ) +   Great! The price of booze just lowered from (at price_pointer) +   (set (at price_pointer) +      (- +         (at price_pointer) +         (var decrease) +      ) +   ) +   to (at price_pointer)! +) + +(define_sequence get_a_refill () +   (local int price_of_booze) + +   (set price_of_booze 12) + +   Staring straight at the barman, you raise your glass and proclaim: +   (newline) +   "This soon-to-be world savior needs more booze!" +   (newline) +   The barman's lack of reaction is disappointing, but seeing the beer being +   poured does help improve the mood. +   (newline) +   Satisfied, you hand the barman (var price_of_booze) copper coins. +   (visit pay (var price_of_booze)) +   (newline) +   The barman sighs, then asks: +   (prompt_string (ptr hero.name) 2 64 What is your name, then, hero?) +   (var hero.name)? +   (newline) +   The barman looks surprised. +   (newline) +   (visit lower_price_of_booze (ptr price_of_booze) 4) +   (newline) +   "I have heard of you, (var hero.name)," the barman exclaims, "I have a quest +   for you!" +   (newline) +   It's your turn to sigh. +   (newline) +   The barman hands you a bag, and says: +   (newline) +   "Take this pre-payment and head to the smithy." +   (newline) +) +{{< /fatecode >}}  **actions.fate:** +{{< fatecode >}}(fate_version 1) -         (fate_version 1) +(require data.fate) -         (require data.fate) - -         (define_sequence pay ( (int cost) ) -            (set hero_money -               (- (var hero.money) (var cost)) -            ) -         ) +(define_sequence pay ( (int cost) ) +   (set hero_money +      (- (var hero.money) (var cost)) +   ) +) +{{< /fatecode >}}  **falling_asleep.fate:** - -         (fate_version 1) - -         (require data.fate) - -         (define_sequence fall_asleep () -            Deciding to break away from the expected storyline, you promptly -            fall asleep. -            (newline) -            ... -            (newline) -            Upon waking up, your hard-trained reflexes inform you that someone -            stole all your money. -            (set hero.money 0) -            (newline) -            This set-back was more than you could take. You give up on this -            barely coherent story. -            (end) -         ) +{{< fatecode >}}(fate_version 1) + +(require data.fate) + +(define_sequence fall_asleep () +   Deciding to break away from the expected storyline, you promptly fall +   asleep. +   (newline) +   ... +   (newline) +   Upon waking up, your hard-trained reflexes inform you that someone stole all +   your money. +   (set hero.money 0) +   (newline) +   This set-back was more than you could take. You give up on this barely +   coherent story. +   (end) +) +{{< /fatecode >}}  **main.fate:** - -         (fate_version 1) - -         Once upon a time, starting a story with these words wasn't considered -         a cliche. Starting in a tavern might also not be seen as very -         original.  Having the main character be an street orphan, raised by -         some mysterious sage all to end up as a mercenary with an uncommonly -         strong sense of honor probably isn't going to lead to any praises for -         novelty either. Maybe you should drink to that. -         (newline) -         Or maybe you shouldn't. This isn't your first mug. Not your second -         either.  Drinking to forget that you are a stereotypical hero isn't -         going to solve anything. Worse, the alcoholic trait is part of the -         image. -         (newline) -         As you contemplate your own pointless description, your gaze leaves -         what turns out to be an already empty glass in your hand and finds the -         barman. - -         (player_choice -            ( -               ( Ask the barman for a refill ) -               (visit get_a_refill) -            ) -            ( -               ( Fall asleep ) -               (jump_to fall_asleep) -            ) -         ) - -         (require get_a_refill.fate) -         (require falling_asleep.fate) - -         (end) +{{< fatecode >}}(fate_version 1) + +Once upon a time, starting a story with these words wasn't considered a cliche. +Starting in a tavern might also not be seen as very original.  Having the main +character be an street orphan, raised by some mysterious sage all to end up as +a mercenary with an uncommonly strong sense of honor probably isn't going to +lead to any praises for novelty either. Maybe you should drink to that. +(newline) +Or maybe you shouldn't. This isn't your first mug. Not your second either. +Drinking to forget that you are a stereotypical hero isn't going to solve +anything. Worse, the alcoholic trait is part of the image. +(newline) +As you contemplate your own pointless description, your gaze leaves what turns +out to be an already empty glass in your hand and finds the barman. + +(player_choice +   ( +      ( Ask the barman for a refill ) +      (visit get_a_refill) +   ) +   ( +      ( Fall asleep ) +      (jump_to fall_asleep) +   ) +) + +(require get_a_refill.fate) +(require falling_asleep.fate) + +(end) +{{< /fatecode >}} diff --git a/content/learn/09.lambdas/default.md b/content/learn/09.lambdas/default.md index a2e6c24..91d5660 100644 --- a/content/learn/09.lambdas/default.md +++ b/content/learn/09.lambdas/default.md @@ -13,124 +13,124 @@ It can also take parameters. Since it's a computation, it cannot alter the  memory by itself, nor can it contain any instructions.  **smithy.fate:** +{{< fatecode >}}(fate_version 1) -         (fate_version 1) - -         (require smithy_inventory.fate) - -         (global (lambda text ((cons weapon int))) get_weapon_offer_label) -         (global (lambda text ((cons armor int))) get_armor_offer_label) - -         (set get_weapon_offer_label -            (lambda -               ( ((cons weapon int) offer) ) -               (let -                  ( -                     (weapon (car offer)) -                     (price (cdr offer)) -                  ) -                  (text -                     Buy "(var weapon.name)" \(attack: (var weapon.attack), -                     precision: (var weapon.precision)\) for (var price) coins. -                  ) -               ) -            ) -         ) +(require smithy_inventory.fate) -         (set get_armor_offer_label -            (lambda -               ( ((cons armor int) offer) ) -               (let -                  ( -                     (armor (car offer)) -                     (price (cdr offer)) -                  ) -                  (text -                     Buy "(var armor.name)" \(defense: (var armor.defense)\), -                     for (var price) coins. -                  ) -               ) -            ) -         ) +(global (lambda text ((cons weapon int))) get_weapon_offer_label) +(global (lambda text ((cons armor int))) get_armor_offer_label) -         (define_sequence visit_smithy () -            ;; This thing is going to show up every time, which isn't great. -            As you approach the smithy, you notice that no one's there. All the -            wares are out for selling. It's almost as if this story didn't need -            more examples of lengthy dialogues. -            (newline) -            ;; We'll want to start here the next time we enter this sequence. -            You have (var hero.money) coins. -            (newline) -            What will you look at? -            (player_choice -               ( -                  ( Let's see the weapons ) -                  (jump_to see_weapons) -               ) -               ( -                  ( Let's see the armors ) -                  (jump_to see_armors) -               ) -               ( -                  ( Nothing, let's go back to the bar ) -               ) -            ) +(set get_weapon_offer_label +   (lambda +      ( ((cons weapon int) offer) ) +      (let +         ( +            (weapon (car offer)) +            (price (cdr offer))           ) - -         (define_sequence see_weapons () -            ;; Still can be improved. -            (player_choice -               ( -                  ( (eval get_weapon_offer_label (access smithy_weapons 0)) ) -                  (visit buy_weapon (access smithy_weapons 0)) -                  (jump_to visit_smithy) -               ) -               ( -                  ( (eval get_weapon_offer_label (access smithy_weapons 1)) ) -                  (visit buy_weapon (access smithy_weapons 1)) -                  (jump_to visit_smithy) -               ) -               ( -                  ( Nevermind ) -                  (jump_to visit_smithy) -               ) -            ) -         ) - -         (define_sequence see_armors () -            ;; Still can be improved. -            (player_choice -               ( -                  ( (eval get_armor_offer_label (access smithy_armors 0)) ) -                  (visit buy_armor (access smithy_armors 0)) -                  (jump_to visit_smithy) -               ) -               ( -                  ( (eval get_armor_offer_label (access smithy_armors 1)) ) -                  (visit buy_armor (access smithy_armors 1)) -                  (jump_to visit_smithy) -               ) -               ( -                  ( Nevermind ) -                  (jump_to visit_smithy) -               ) -            ) +         (text +            Buy "(var weapon.name)" \(attack: (var weapon.attack), +            precision: (var weapon.precision)\) for (var price) coins.           ) - -         (define_sequence buy_weapon ( ((cons weapon int) weapon) ) -            ;; We can't even deny a sell yet... -            (set hero.weapon (car weapon)) -            Equipped (var hero.weapon.name). -            (newline) +      ) +   ) +) + +(set get_armor_offer_label +   (lambda +      ( ((cons armor int) offer) ) +      (let +         ( +            (armor (car offer)) +            (price (cdr offer))           ) - -         (define_sequence buy_armor ( ((cons armor int) armor) ) -            ;; We can't even deny a sell yet... -            (set hero.armor (car armor)) -            Equipped (var hero.armor.name). -            (newline) +         (text +            Buy "(var armor.name)" \(defense: (var armor.defense)\), +            for (var price) coins.           ) +      ) +   ) +) + +(define_sequence visit_smithy () +   ;; This thing is going to show up every time, which isn't great. +   As you approach the smithy, you notice that no one's there. All the wares +   are out for selling. It's almost as if this story didn't need more examples +   of lengthy dialogues. +   (newline) +   ;; We'll want to start here the next time we enter this sequence. +   You have (var hero.money) coins. +   (newline) +   What will you look at? +   (player_choice +      ( +         ( Let's see the weapons ) +         (jump_to see_weapons) +      ) +      ( +         ( Let's see the armors ) +         (jump_to see_armors) +      ) +      ( +         ( Nothing, let's go back to the bar ) +      ) +   ) +) + +(define_sequence see_weapons () +   ;; Still can be improved. +   (player_choice +      ( +         ( (eval get_weapon_offer_label (access smithy_weapons 0)) ) +         (visit buy_weapon (access smithy_weapons 0)) +         (jump_to visit_smithy) +      ) +      ( +         ( (eval get_weapon_offer_label (access smithy_weapons 1)) ) +         (visit buy_weapon (access smithy_weapons 1)) +         (jump_to visit_smithy) +      ) +      ( +         ( Nevermind ) +         (jump_to visit_smithy) +      ) +   ) +) + +(define_sequence see_armors () +   ;; Still can be improved. +   (player_choice +      ( +         ( (eval get_armor_offer_label (access smithy_armors 0)) ) +         (visit buy_armor (access smithy_armors 0)) +         (jump_to visit_smithy) +      ) +      ( +         ( (eval get_armor_offer_label (access smithy_armors 1)) ) +         (visit buy_armor (access smithy_armors 1)) +         (jump_to visit_smithy) +      ) +      ( +         ( Nevermind ) +         (jump_to visit_smithy) +      ) +   ) +) + +(define_sequence buy_weapon ( ((cons weapon int) weapon) ) +   ;; We can't even deny a sell yet... +   (set hero.weapon (car weapon)) +   Equipped (var hero.weapon.name). +   (newline) +) + +(define_sequence buy_armor ( ((cons armor int) armor) ) +   ;; We can't even deny a sell yet... +   (set hero.armor (car armor)) +   Equipped (var hero.armor.name). +   (newline) +) +{{< /fatecode >}}  * `(lambda return_type (param_type0 param_type1 ...))` is the type corresponding    to a lambda function returning a value of type `return_type` and taking as @@ -152,215 +152,213 @@ This was a first step toward cleaning up `smithy.fate`. Next, we'll use  ## Unchanged Files  **data.fate:** - -         (fate_version 1) - -         (declare_structure weapon -            (text name) -            (int attack) -            (int precision) -         ) - -         (declare_structure armor -            (text name) -            (int defense) -         ) - -         (declare_structure character -            (string name) -            (int money) -            (weapon weapon) -            (armor armor) -         ) - -         (global character hero) - -         (set_fields! hero.weapon -            (name (text "Legendary" sword)) -            (attack 3) -            (precision 50) -         ) - -         (set_fields! hero.armor -            (name (text "Refined" attire)) -            (defense 1) -         ) - -         (set hero.money 42) +{{< fatecode >}}(fate_version 1) + +(declare_structure weapon +   (text name) +   (int attack) +   (int precision) +) + +(declare_structure armor +   (text name) +   (int defense) +) + +(declare_structure character +   (string name) +   (int money) +   (weapon weapon) +   (armor armor) +) + +(global character hero) + +(set_fields! hero.weapon +   (name (text "Legendary" sword)) +   (attack 3) +   (precision 50) +) + +(set_fields! hero.armor +   (name (text "Refined" attire)) +   (defense 1) +) + +(set hero.money 42) +{{< /fatecode >}}  **get_a_refill.fate:** - -         (fate_version 1) - -         (require data.fate) -         (require actions.fate) - -         (define_sequence lower_price_of_booze -            ( -               ((ptr int) price_pointer) -               (int decrease) -            ) -            Great! The price of booze just lowered from (at price_pointer) -            (set (at price_pointer) -               (- -                  (at price_pointer) -                  (var decrease) -               ) -            ) -            to (at price_pointer)! -         ) - -         (define_sequence get_a_refill () -            (local int price_of_booze) - -            (set price_of_booze 12) - -            Staring straight at the barman, you raise your glass and proclaim: -            (newline) -            "This soon-to-be world savior needs more booze!" -            (newline) -            The barman's lack of reaction is disappointing, but seeing the beer -            being poured does help improve the mood. -            (newline) -            Satisfied, you hand the barman (var price_of_booze) copper coins. -            (visit pay (var price_of_booze)) -            (newline) -            The barman sighs, then asks: -            (prompt_string (ptr hero.name) 2 64 What is your name, then, hero?) -            (var hero.name)? -            (newline) -            The barman looks surprised. -            (newline) -            (visit lower_price_of_booze (ptr price_of_booze) 4) -            (newline) -            "I have heard of you, (var hero.name)," the barman exclaims, "I have -            a quest for you!" -            (newline) -            It's your turn to sigh. -            (newline) -            The barman hands you a bag, and says: -            (newline) -            "Take this pre-payment and head to the smithy." -            (newline) -         ) +{{< fatecode >}}(fate_version 1) + +(require data.fate) +(require actions.fate) + +(define_sequence lower_price_of_booze +   ( +      ((ptr int) price_pointer) +      (int decrease) +   ) +   Great! The price of booze just lowered from (at price_pointer) +   (set (at price_pointer) +      (- +         (at price_pointer) +         (var decrease) +      ) +   ) +   to (at price_pointer)! +) + +(define_sequence get_a_refill () +   (local int price_of_booze) + +   (set price_of_booze 12) + +   Staring straight at the barman, you raise your glass and proclaim: +   (newline) +   "This soon-to-be world savior needs more booze!" +   (newline) +   The barman's lack of reaction is disappointing, but seeing the beer being +   poured does help improve the mood. +   (newline) +   Satisfied, you hand the barman (var price_of_booze) copper coins. +   (visit pay (var price_of_booze)) +   (newline) +   The barman sighs, then asks: +   (prompt_string (ptr hero.name) 2 64 What is your name, then, hero?) +   (var hero.name)? +   (newline) +   The barman looks surprised. +   (newline) +   (visit lower_price_of_booze (ptr price_of_booze) 4) +   (newline) +   "I have heard of you, (var hero.name)," the barman exclaims, "I have a quest +   for you!" +   (newline) +   It's your turn to sigh. +   (newline) +   The barman hands you a bag, and says: +   (newline) +   "Take this pre-payment and head to the smithy." +   (newline) +) +{{< /fatecode >}}  **actions.fate:** +{{< fatecode >}}(fate_version 1) -         (fate_version 1) +(require data.fate) -         (require data.fate) - -         (define_sequence pay ( (int cost) ) -            (set hero_money -               (- (var hero.money) (var cost)) -            ) -         ) +(define_sequence pay ( (int cost) ) +   (set hero_money +      (- (var hero.money) (var cost)) +   ) +) +{{< /fatecode >}}  **falling_asleep.fate:** - -         (fate_version 1) - -         (require data.fate) - -         (define_sequence fall_asleep () -            Deciding to break away from the expected storyline, you promptly -            fall asleep. -            (newline) -            ... -            (newline) -            Upon waking up, your hard-trained reflexes inform you that someone -            stole all your money. -            (set hero.money 0) -            (newline) -            This set-back was more than you could take. You give up on this -            barely coherent story. -            (end) -         ) +{{< fatecode >}}(fate_version 1) + +(require data.fate) + +(define_sequence fall_asleep () +   Deciding to break away from the expected storyline, you promptly fall +   asleep. +   (newline) +   ... +   (newline) +   Upon waking up, your hard-trained reflexes inform you that someone stole all +   your money. +   (set hero.money 0) +   (newline) +   This set-back was more than you could take. You give up on this barely +   coherent story. +   (end) +) +{{< /fatecode >}}  **main.fate:** - -         (fate_version 1) - -         Once upon a time, starting a story with these words wasn't considered -         a cliche. Starting in a tavern might also not be seen as very -         original.  Having the main character be an street orphan, raised by -         some mysterious sage all to end up as a mercenary with an uncommonly -         strong sense of honor probably isn't going to lead to any praises for -         novelty either. Maybe you should drink to that. -         (newline) -         Or maybe you shouldn't. This isn't your first mug. Not your second -         either.  Drinking to forget that you are a stereotypical hero isn't -         going to solve anything. Worse, the alcoholic trait is part of the -         image. -         (newline) -         As you contemplate your own pointless description, your gaze leaves -         what turns out to be an already empty glass in your hand and finds the -         barman. - -         (player_choice -            ( -               ( Ask the barman for a refill ) -               (visit get_a_refill) -            ) -            ( -               ( Fall asleep ) -               (jump_to fall_asleep) -            ) -         ) - -         (require get_a_refill.fate) -         (require falling_asleep.fate) - -         (end) +{{< fatecode >}}(fate_version 1) + +Once upon a time, starting a story with these words wasn't considered a cliche. +Starting in a tavern might also not be seen as very original.  Having the main +character be an street orphan, raised by some mysterious sage all to end up as +a mercenary with an uncommonly strong sense of honor probably isn't going to +lead to any praises for novelty either. Maybe you should drink to that. +(newline) +Or maybe you shouldn't. This isn't your first mug. Not your second either. +Drinking to forget that you are a stereotypical hero isn't going to solve +anything. Worse, the alcoholic trait is part of the image. +(newline) +As you contemplate your own pointless description, your gaze leaves what turns +out to be an already empty glass in your hand and finds the barman. + +(player_choice +   ( +      ( Ask the barman for a refill ) +      (visit get_a_refill) +   ) +   ( +      ( Fall asleep ) +      (jump_to fall_asleep) +   ) +) + +(require get_a_refill.fate) +(require falling_asleep.fate) + +(end) +{{< /fatecode >}}  **smithy_inventory.fate:** -         (fate_version 1) - -         (require data.fate) - -         (global (list (cons weapon int)) smithy_weapons) -         (global (list (cons weapon int)) smithy_armors) - -         (add! -            (cons -               (set_fields (default weapon) -                  (name (text An Iron Rod)) -                  (attack 10) -                  (precision 70) -               ) -               176 -            ) -            smithy_weapons -         ) -         (add! -            (cons -               (set_fields (default weapon) -                  (name (text A Magnificient Brick)) -                  (attack 6) -                  (precision 90) -               ) -               110 -            ) -            smithy_weapons -         ) - -         (add! -            (cons -               (set_fields (default armor) -                  (name (text A raincoat?!)) -                  (defense 7) -               ) -               160 -            ) -            smithy_armors -         ) -         (add! -            (cons -               (set_fields (default armor) -                  (name (text A nice cape)) -                  (defense 3) -               ) -               50 -            ) -            smithy_armors -         ) +{{< fatecode >}}(fate_version 1) + +(require data.fate) + +(global (list (cons weapon int)) smithy_weapons) +(global (list (cons weapon int)) smithy_armors) + +(add! +   (cons +      (set_fields (default weapon) +         (name (text An Iron Rod)) +         (attack 10) +         (precision 70) +      ) +      176 +   ) +   smithy_weapons +) +(add! +   (cons +      (set_fields (default weapon) +         (name (text A Magnificient Brick)) +         (attack 6) +         (precision 90) +      ) +      110 +   ) +   smithy_weapons +) + +(add! +   (cons +      (set_fields (default armor) +         (name (text A raincoat?!)) +         (defense 7) +      ) +      160 +   ) +   smithy_armors +) +(add! +   (cons +      (set_fields (default armor) +         (name (text A nice cape)) +         (defense 3) +      ) +      50 +   ) +   smithy_armors +) +{{< /fatecode >}} diff --git a/content/learn/10.conditions/default.md b/content/learn/10.conditions/default.md index 8a4f339..0b449b4 100644 --- a/content/learn/10.conditions/default.md +++ b/content/learn/10.conditions/default.md @@ -27,157 +27,157 @@ All of these can be used within a `player_choice` to control what options are  available.  **smithy.fate:** +{{< fatecode >}}(fate_version 1) -         (fate_version 1) - -         (require smithy_inventory.fate) - -         (global (lambda text ((cons weapon int))) get_weapon_offer_label) -         (global (lambda text ((cons armor int))) get_armor_offer_label) - -         (set get_weapon_offer_label -            (lambda -               ( ((cons weapon int) offer) ) -               (let -                  ( -                     (weapon (car offer)) -                     (price (cdr offer)) -                  ) -                  (text -                     Buy "(var weapon.name)" \(attack: (var weapon.attack), -                     precision: (var weapon.precision)\) for (var price) coins. -                  ) -               ) -            ) -         ) +(require smithy_inventory.fate) -         (set get_armor_offer_label -            (lambda -               ( ((cons armor int) offer) ) -               (let -                  ( -                     (armor (car offer)) -                     (price (cdr offer)) -                  ) -                  (text -                     Buy "(var armor.name)" \(defense: (var armor.defense)\), -                     for (var price) coins. -                  ) -               ) -            ) -         ) +(global (lambda text ((cons weapon int))) get_weapon_offer_label) +(global (lambda text ((cons armor int))) get_armor_offer_label) -         (global bool has_visited_smithy) - -         (set has_visited_smithy (false)) - -         (define_sequence visit_smithy () -            (if (not (var has_visited_smithy)) -               As you approach the smithy, you notice that no one's there. All -               the wares are out for selling. It's almost as if this story -               didn't need more examples of lengthy dialogues. -               (newline) -               (set has_visited_smithy (true)) -            ) -            You have (var hero.money) coins. -            (newline) -            What will you look at? -            (player_choice -               ( -                  ( Let's see the weapons ) -                  (jump_to see_weapons) -               ) -               ( -                  ( Let's see the armors ) -                  (jump_to see_armors) -               ) -               ( -                  ( Nothing, let's go back to the bar ) -               ) -            ) +(set get_weapon_offer_label +   (lambda +      ( ((cons weapon int) offer) ) +      (let +         ( +            (weapon (car offer)) +            (price (cdr offer))           ) - -         (define_sequence see_weapons () -            ;; Still can be improved. -            (player_choice -               ( -                  ( (eval get_weapon_offer_label (access smithy_weapons 0)) ) -                  (visit buy_weapon (access smithy_weapons 0)) -                  (jump_to visit_smithy) -               ) -               ( -                  ( (eval get_weapon_offer_label (access smithy_weapons 1)) ) -                  (visit buy_weapon (access smithy_weapons 1)) -                  (jump_to visit_smithy) -               ) -               ( -                  ( Nevermind ) -                  (jump_to visit_smithy) -               ) -            ) +         (text +            Buy "(var weapon.name)" \(attack: (var weapon.attack), +            precision: (var weapon.precision)\) for (var price) coins.           ) - -         (define_sequence see_armors () -            ;; Still can be improved. -            (player_choice -               ( -                  ( (eval get_armor_offer_label (access smithy_armors 0)) ) -                  (visit buy_armor (access smithy_armors 0)) -                  (jump_to visit_smithy) -               ) -               ( -                  ( (eval get_armor_offer_label (access smithy_armors 1)) ) -                  (visit buy_armor (access smithy_armors 1)) -                  (jump_to visit_smithy) -               ) -               ( -                  ( Nevermind ) -                  (jump_to visit_smithy) -               ) -            ) +      ) +   ) +) + +(set get_armor_offer_label +   (lambda +      ( ((cons armor int) offer) ) +      (let +         ( +            (armor (car offer)) +            (price (cdr offer))           ) - -         (define_sequence buy_weapon ( ((cons weapon int) weapon) ) -            ;; We can't even deny a sell yet... -            (local int money_after) - -            (set money_after (- (var hero.money) (cdr weapon))) - -            (if_else (< (var money_after) 0) -               ( -                  You can't afford that. -                  (newline) -                  You would need (abs (var money_after)) more coins. -               ) -               ( -                  (set hero.weapon (car weapon)) -                  (set hero.money (var money_after)) -                  Equipped (var hero.weapon.name). -               ) -            ) -            (newline) -         ) - -         (define_sequence buy_armor ( ((cons armor int) armor) ) -            ;; We can't even deny a sell yet... -            (local int money_after) - -            (set money_after (- (var hero.money) (cdr armor))) - -            (if_else (< (var money_after) 0) -               ( -                  You can't afford that. -                  (newline) -                  You would need (abs (var money_after)) more coins. -               ) -               ( -                  (set hero.armor (car armor)) -                  (set hero.money (var money_after)) -                  Equipped (var hero.armor.name). -               ) -            ) -            (newline) +         (text +            Buy "(var armor.name)" \(defense: (var armor.defense)\), +            for (var price) coins.           ) +      ) +   ) +) + +(global bool has_visited_smithy) + +(set has_visited_smithy (false)) + +(define_sequence visit_smithy () +   (if (not (var has_visited_smithy)) +      As you approach the smithy, you notice that no one's there. All the wares +      are out for selling. It's almost as if this story didn't need more +      examples of lengthy dialogues. +      (newline) +      (set has_visited_smithy (true)) +   ) +   You have (var hero.money) coins. +   (newline) +   What will you look at? +   (player_choice +      ( +         ( Let's see the weapons ) +         (jump_to see_weapons) +      ) +      ( +         ( Let's see the armors ) +         (jump_to see_armors) +      ) +      ( +         ( Nothing, let's go back to the bar ) +      ) +   ) +) + +(define_sequence see_weapons () +   ;; Still can be improved. +   (player_choice +      ( +         ( (eval get_weapon_offer_label (access smithy_weapons 0)) ) +         (visit buy_weapon (access smithy_weapons 0)) +         (jump_to visit_smithy) +      ) +      ( +         ( (eval get_weapon_offer_label (access smithy_weapons 1)) ) +         (visit buy_weapon (access smithy_weapons 1)) +         (jump_to visit_smithy) +      ) +      ( +         ( Nevermind ) +         (jump_to visit_smithy) +      ) +   ) +) + +(define_sequence see_armors () +   ;; Still can be improved. +   (player_choice +      ( +         ( (eval get_armor_offer_label (access smithy_armors 0)) ) +         (visit buy_armor (access smithy_armors 0)) +         (jump_to visit_smithy) +      ) +      ( +         ( (eval get_armor_offer_label (access smithy_armors 1)) ) +         (visit buy_armor (access smithy_armors 1)) +         (jump_to visit_smithy) +      ) +      ( +         ( Nevermind ) +         (jump_to visit_smithy) +      ) +   ) +) + +(define_sequence buy_weapon ( ((cons weapon int) weapon) ) +   ;; We can't even deny a sell yet... +   (local int money_after) + +   (set money_after (- (var hero.money) (cdr weapon))) + +   (if_else (< (var money_after) 0) +      ( +         You can't afford that. +         (newline) +         You would need (abs (var money_after)) more coins. +      ) +      ( +         (set hero.weapon (car weapon)) +         (set hero.money (var money_after)) +         Equipped (var hero.weapon.name). +      ) +   ) +   (newline) +) + +(define_sequence buy_armor ( ((cons armor int) armor) ) +   ;; We can't even deny a sell yet... +   (local int money_after) + +   (set money_after (- (var hero.money) (cdr armor))) + +   (if_else (< (var money_after) 0) +      ( +         You can't afford that. +         (newline) +         You would need (abs (var money_after)) more coins. +      ) +      ( +         (set hero.armor (car armor)) +         (set hero.money (var money_after)) +         Equipped (var hero.armor.name). +      ) +   ) +   (newline) +) +{{< /fatecode >}}  This was a first step toward cleaning up `smithy.fate`. Next, we'll use @@ -188,215 +188,213 @@ This was a first step toward cleaning up `smithy.fate`. Next, we'll use  ## Unchanged Files  **data.fate:** - -         (fate_version 1) - -         (declare_structure weapon -            (text name) -            (int attack) -            (int precision) -         ) - -         (declare_structure armor -            (text name) -            (int defense) -         ) - -         (declare_structure character -            (string name) -            (int money) -            (weapon weapon) -            (armor armor) -         ) - -         (global character hero) - -         (set_fields! hero.weapon -            (name (text "Legendary" sword)) -            (attack 3) -            (precision 50) -         ) - -         (set_fields! hero.armor -            (name (text "Refined" attire)) -            (defense 1) -         ) - -         (set hero.money 42) +{{< fatecode >}}(fate_version 1) + +(declare_structure weapon +   (text name) +   (int attack) +   (int precision) +) + +(declare_structure armor +   (text name) +   (int defense) +) + +(declare_structure character +   (string name) +   (int money) +   (weapon weapon) +   (armor armor) +) + +(global character hero) + +(set_fields! hero.weapon +   (name (text "Legendary" sword)) +   (attack 3) +   (precision 50) +) + +(set_fields! hero.armor +   (name (text "Refined" attire)) +   (defense 1) +) + +(set hero.money 42) +{{< /fatecode >}}  **get_a_refill.fate:** - -         (fate_version 1) - -         (require data.fate) -         (require actions.fate) - -         (define_sequence lower_price_of_booze -            ( -               ((ptr int) price_pointer) -               (int decrease) -            ) -            Great! The price of booze just lowered from (at price_pointer) -            (set (at price_pointer) -               (- -                  (at price_pointer) -                  (var decrease) -               ) -            ) -            to (at price_pointer)! -         ) - -         (define_sequence get_a_refill () -            (local int price_of_booze) - -            (set price_of_booze 12) - -            Staring straight at the barman, you raise your glass and proclaim: -            (newline) -            "This soon-to-be world savior needs more booze!" -            (newline) -            The barman's lack of reaction is disappointing, but seeing the beer -            being poured does help improve the mood. -            (newline) -            Satisfied, you hand the barman (var price_of_booze) copper coins. -            (visit pay (var price_of_booze)) -            (newline) -            The barman sighs, then asks: -            (prompt_string (ptr hero.name) 2 64 What is your name, then, hero?) -            (var hero.name)? -            (newline) -            The barman looks surprised. -            (newline) -            (visit lower_price_of_booze (ptr price_of_booze) 4) -            (newline) -            "I have heard of you, (var hero.name)," the barman exclaims, "I have -            a quest for you!" -            (newline) -            It's your turn to sigh. -            (newline) -            The barman hands you a bag, and says: -            (newline) -            "Take this pre-payment and head to the smithy." -            (newline) -         ) +{{< fatecode >}}(fate_version 1) + +(require data.fate) +(require actions.fate) + +(define_sequence lower_price_of_booze +   ( +      ((ptr int) price_pointer) +      (int decrease) +   ) +   Great! The price of booze just lowered from (at price_pointer) +   (set (at price_pointer) +      (- +         (at price_pointer) +         (var decrease) +      ) +   ) +   to (at price_pointer)! +) + +(define_sequence get_a_refill () +   (local int price_of_booze) + +   (set price_of_booze 12) + +   Staring straight at the barman, you raise your glass and proclaim: +   (newline) +   "This soon-to-be world savior needs more booze!" +   (newline) +   The barman's lack of reaction is disappointing, but seeing the beer being +   poured does help improve the mood. +   (newline) +   Satisfied, you hand the barman (var price_of_booze) copper coins. +   (visit pay (var price_of_booze)) +   (newline) +   The barman sighs, then asks: +   (prompt_string (ptr hero.name) 2 64 What is your name, then, hero?) +   (var hero.name)? +   (newline) +   The barman looks surprised. +   (newline) +   (visit lower_price_of_booze (ptr price_of_booze) 4) +   (newline) +   "I have heard of you, (var hero.name)," the barman exclaims, "I have a quest +   for you!" +   (newline) +   It's your turn to sigh. +   (newline) +   The barman hands you a bag, and says: +   (newline) +   "Take this pre-payment and head to the smithy." +   (newline) +) +{{< /fatecode >}}  **actions.fate:** +{{< fatecode >}}(fate_version 1) -         (fate_version 1) +(require data.fate) -         (require data.fate) - -         (define_sequence pay ( (int cost) ) -            (set hero_money -               (- (var hero.money) (var cost)) -            ) -         ) +(define_sequence pay ( (int cost) ) +   (set hero_money +      (- (var hero.money) (var cost)) +   ) +) +{{< /fatecode >}}  **falling_asleep.fate:** - -         (fate_version 1) - -         (require data.fate) - -         (define_sequence fall_asleep () -            Deciding to break away from the expected storyline, you promptly -            fall asleep. -            (newline) -            ... -            (newline) -            Upon waking up, your hard-trained reflexes inform you that someone -            stole all your money. -            (set hero.money 0) -            (newline) -            This set-back was more than you could take. You give up on this -            barely coherent story. -            (end) -         ) +{{< fatecode >}}(fate_version 1) + +(require data.fate) + +(define_sequence fall_asleep () +   Deciding to break away from the expected storyline, you promptly fall +   asleep. +   (newline) +   ... +   (newline) +   Upon waking up, your hard-trained reflexes inform you that someone stole all +   your money. +   (set hero.money 0) +   (newline) +   This set-back was more than you could take. You give up on this barely +   coherent story. +   (end) +) +{{< /fatecode >}}  **main.fate:** - -         (fate_version 1) - -         Once upon a time, starting a story with these words wasn't considered -         a cliche. Starting in a tavern might also not be seen as very -         original.  Having the main character be an street orphan, raised by -         some mysterious sage all to end up as a mercenary with an uncommonly -         strong sense of honor probably isn't going to lead to any praises for -         novelty either. Maybe you should drink to that. -         (newline) -         Or maybe you shouldn't. This isn't your first mug. Not your second -         either.  Drinking to forget that you are a stereotypical hero isn't -         going to solve anything. Worse, the alcoholic trait is part of the -         image. -         (newline) -         As you contemplate your own pointless description, your gaze leaves -         what turns out to be an already empty glass in your hand and finds the -         barman. - -         (player_choice -            ( -               ( Ask the barman for a refill ) -               (visit get_a_refill) -            ) -            ( -               ( Fall asleep ) -               (jump_to fall_asleep) -            ) -         ) - -         (require get_a_refill.fate) -         (require falling_asleep.fate) - -         (end) +{{< fatecode >}}(fate_version 1) + +Once upon a time, starting a story with these words wasn't considered a cliche. +Starting in a tavern might also not be seen as very original.  Having the main +character be an street orphan, raised by some mysterious sage all to end up as +a mercenary with an uncommonly strong sense of honor probably isn't going to +lead to any praises for novelty either. Maybe you should drink to that. +(newline) +Or maybe you shouldn't. This isn't your first mug. Not your second either. +Drinking to forget that you are a stereotypical hero isn't going to solve +anything. Worse, the alcoholic trait is part of the image. +(newline) +As you contemplate your own pointless description, your gaze leaves what turns +out to be an already empty glass in your hand and finds the barman. + +(player_choice +   ( +      ( Ask the barman for a refill ) +      (visit get_a_refill) +   ) +   ( +      ( Fall asleep ) +      (jump_to fall_asleep) +   ) +) + +(require get_a_refill.fate) +(require falling_asleep.fate) + +(end) +{{< /fatecode >}}  **smithy_inventory.fate:** -         (fate_version 1) - -         (require data.fate) - -         (global (list (cons weapon int)) smithy_weapons) -         (global (list (cons weapon int)) smithy_armors) - -         (add! -            (cons -               (set_fields (default weapon) -                  (name (text An Iron Rod)) -                  (attack 10) -                  (precision 70) -               ) -               176 -            ) -            smithy_weapons -         ) -         (add! -            (cons -               (set_fields (default weapon) -                  (name (text A Magnificient Brick)) -                  (attack 6) -                  (precision 90) -               ) -               110 -            ) -            smithy_weapons -         ) - -         (add! -            (cons -               (set_fields (default armor) -                  (name (text A raincoat?!)) -                  (defense 7) -               ) -               160 -            ) -            smithy_armors -         ) -         (add! -            (cons -               (set_fields (default armor) -                  (name (text A nice cape)) -                  (defense 3) -               ) -               50 -            ) -            smithy_armors -         ) +{{< fatecode >}}(fate_version 1) + +(require data.fate) + +(global (list (cons weapon int)) smithy_weapons) +(global (list (cons weapon int)) smithy_armors) + +(add! +   (cons +      (set_fields (default weapon) +         (name (text An Iron Rod)) +         (attack 10) +         (precision 70) +      ) +      176 +   ) +   smithy_weapons +) +(add! +   (cons +      (set_fields (default weapon) +         (name (text A Magnificient Brick)) +         (attack 6) +         (precision 90) +      ) +      110 +   ) +   smithy_weapons +) + +(add! +   (cons +      (set_fields (default armor) +         (name (text A raincoat?!)) +         (defense 7) +      ) +      160 +   ) +   smithy_armors +) +(add! +   (cons +      (set_fields (default armor) +         (name (text A nice cape)) +         (defense 3) +      ) +      50 +   ) +   smithy_armors +) +{{< /fatecode >}} diff --git a/content/learn/_index.md b/content/learn/_index.md index 62706fc..2cc816c 100644 --- a/content/learn/_index.md +++ b/content/learn/_index.md @@ -2,6 +2,7 @@  title: "Starting"  menuTitle: "Learn"  chapter: true +weight: 2  ---  # Writing a story in Fate.  This chapter provides an example of narrative written in Fate. Concepts are | 


