narrat 2.0.0-rc3 → 2.0.0-rc4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/CHANGELOG.md +17 -3
  2. package/README.md +10 -12
  3. package/dist/.DS_Store +0 -0
  4. package/dist/audio/click.ogg +0 -0
  5. package/dist/audio/failure.ogg +0 -0
  6. package/dist/audio/game_start.ogg +0 -0
  7. package/dist/audio/success.wav +0 -0
  8. package/dist/data/characters.json +62 -0
  9. package/dist/data/config.json +176 -0
  10. package/dist/data/example.rpy +356 -0
  11. package/dist/data/refactor.rpy +31 -0
  12. package/dist/favicon.ico +0 -0
  13. package/dist/fonts/OpenDyslexic.ttf.eot +0 -0
  14. package/dist/fonts/OpenDyslexic.ttf.svg +2326 -0
  15. package/dist/fonts/OpenDyslexic.ttf.woff +0 -0
  16. package/dist/img/.DS_Store +0 -0
  17. package/dist/img/backgrounds/map.png +0 -0
  18. package/dist/img/backgrounds/narrat.png +0 -0
  19. package/dist/img/characters/cat_idle.jpg +0 -0
  20. package/dist/img/characters/helper_cat.png +0 -0
  21. package/dist/img/characters/inner_voice.png +0 -0
  22. package/dist/img/characters/music_cat.jpeg +0 -0
  23. package/dist/img/h01.gif +0 -0
  24. package/dist/img/items/book.png +0 -0
  25. package/dist/img/items/bread.png +0 -0
  26. package/dist/img/skills/agility.jpg +0 -0
  27. package/dist/img/skills/logic.jpg +0 -0
  28. package/dist/img/splash-texture.png +0 -0
  29. package/dist/img/ui/energy.png +0 -0
  30. package/dist/img/ui/money.png +0 -0
  31. package/dist/img/ui/park-button.png +0 -0
  32. package/dist/img/ui/shop-button.png +0 -0
  33. package/dist/lib.css +1 -0
  34. package/dist/music/.DS_Store +0 -0
  35. package/dist/music/calm.mp3 +0 -0
  36. package/dist/narrat.es.js +44137 -0
  37. package/dist/narrat.umd.js +194 -0
  38. package/dist/sounds/.DS_Store +0 -0
  39. package/package.json +46 -62
  40. package/lib/app.vue.d.ts +0 -106
  41. package/lib/components/MainMenu.vue.d.ts +0 -15
  42. package/lib/components/Skills.vue.d.ts +0 -26
  43. package/lib/components/debug/debug-menu.vue.d.ts +0 -48
  44. package/lib/components/dialog-picture.vue.d.ts +0 -9
  45. package/lib/components/hud.vue.d.ts +0 -12
  46. package/lib/components/inventory.vue.d.ts +0 -33
  47. package/lib/components/loading-bar.vue.d.ts +0 -10
  48. package/lib/components/menu.vue.d.ts +0 -21
  49. package/lib/components/notification-toast.vue.d.ts +0 -6
  50. package/lib/components/quests.vue.d.ts +0 -23
  51. package/lib/components/utils/modal.vue.d.ts +0 -6
  52. package/lib/components/volume-controls.vue.d.ts +0 -7
  53. package/lib/config.d.ts +0 -145
  54. package/lib/constants.d.ts +0 -1
  55. package/lib/defaultConfig.d.ts +0 -2
  56. package/lib/demo/demo.d.ts +0 -1
  57. package/lib/dialog-box.vue.d.ts +0 -35
  58. package/lib/exports/config.d.ts +0 -1
  59. package/lib/exports/display.d.ts +0 -2
  60. package/lib/exports/plugins.d.ts +0 -19
  61. package/lib/gameloop.d.ts +0 -3
  62. package/lib/index.d.ts +0 -17
  63. package/lib/index.esm.js +0 -10312
  64. package/lib/index.esm.js.map +0 -1
  65. package/lib/index.js +0 -10328
  66. package/lib/index.js.map +0 -1
  67. package/lib/lib.d.ts +0 -6
  68. package/lib/plugins/NarratPlugin.d.ts +0 -11
  69. package/lib/renpy/command-parser-functions.d.ts +0 -14
  70. package/lib/renpy/renpy-helpers.d.ts +0 -14
  71. package/lib/renpy/renpy-parser.d.ts +0 -9
  72. package/lib/store.d.ts +0 -12
  73. package/lib/stores/audio-store.d.ts +0 -12
  74. package/lib/stores/dialog-store.d.ts +0 -30
  75. package/lib/stores/hud-stats-store.d.ts +0 -22
  76. package/lib/stores/inventory-store.d.ts +0 -37
  77. package/lib/stores/main-store.d.ts +0 -275
  78. package/lib/stores/notification-store.d.ts +0 -12
  79. package/lib/stores/quest-log.d.ts +0 -39
  80. package/lib/stores/rendering-store.d.ts +0 -13
  81. package/lib/stores/screens-store.d.ts +0 -23
  82. package/lib/stores/skills.d.ts +0 -35
  83. package/lib/stores/vm-store.d.ts +0 -147
  84. package/lib/types/app-types.d.ts +0 -4
  85. package/lib/types/character-types.d.ts +0 -27
  86. package/lib/types/dialog-box-types.d.ts +0 -9
  87. package/lib/types/game-save.d.ts +0 -21
  88. package/lib/types/parser.d.ts +0 -92
  89. package/lib/types/state.d.ts +0 -3
  90. package/lib/types/vue3-mq/index.d.ts +0 -1
  91. package/lib/utils/ajax.d.ts +0 -1
  92. package/lib/utils/audio-loader.d.ts +0 -13
  93. package/lib/utils/characters.d.ts +0 -5
  94. package/lib/utils/data-helpers.d.ts +0 -19
  95. package/lib/utils/debounce.d.ts +0 -14
  96. package/lib/utils/error-handling.d.ts +0 -3
  97. package/lib/utils/helpers.d.ts +0 -6
  98. package/lib/utils/images-loader.d.ts +0 -6
  99. package/lib/utils/logger.d.ts +0 -11
  100. package/lib/utils/object-iterators.d.ts +0 -8
  101. package/lib/utils/promises.d.ts +0 -1
  102. package/lib/utils/randomId.d.ts +0 -1
  103. package/lib/utils/skillchecks.d.ts +0 -17
  104. package/lib/utils/string-helpers.d.ts +0 -3
  105. package/lib/utils/time-helpers.d.ts +0 -2
  106. package/lib/vm/commands/add.d.ts +0 -3
  107. package/lib/vm/commands/add_item.d.ts +0 -2
  108. package/lib/vm/commands/add_level.d.ts +0 -2
  109. package/lib/vm/commands/add_stat.d.ts +0 -3
  110. package/lib/vm/commands/add_xp.d.ts +0 -2
  111. package/lib/vm/commands/arithmetic-commands.d.ts +0 -17
  112. package/lib/vm/commands/audio-commands.d.ts +0 -8
  113. package/lib/vm/commands/choice.d.ts +0 -37
  114. package/lib/vm/commands/clear_dialog.d.ts +0 -2
  115. package/lib/vm/commands/command-helpers.d.ts +0 -2
  116. package/lib/vm/commands/command-plugin.d.ts +0 -30
  117. package/lib/vm/commands/flow-commands.d.ts +0 -14
  118. package/lib/vm/commands/if.d.ts +0 -10
  119. package/lib/vm/commands/index.d.ts +0 -2
  120. package/lib/vm/commands/inventory-commands.d.ts +0 -15
  121. package/lib/vm/commands/jump.d.ts +0 -2
  122. package/lib/vm/commands/logic-command.d.ts +0 -42
  123. package/lib/vm/commands/notify.d.ts +0 -4
  124. package/lib/vm/commands/pause.d.ts +0 -2
  125. package/lib/vm/commands/play.d.ts +0 -3
  126. package/lib/vm/commands/quest-commands.d.ts +0 -30
  127. package/lib/vm/commands/remove_item.d.ts +0 -2
  128. package/lib/vm/commands/run.d.ts +0 -2
  129. package/lib/vm/commands/screen-commands.d.ts +0 -8
  130. package/lib/vm/commands/set.d.ts +0 -6
  131. package/lib/vm/commands/set_button.d.ts +0 -2
  132. package/lib/vm/commands/set_screen.d.ts +0 -3
  133. package/lib/vm/commands/set_stat.d.ts +0 -3
  134. package/lib/vm/commands/skill-commands.d.ts +0 -33
  135. package/lib/vm/commands/stats-commands.d.ts +0 -12
  136. package/lib/vm/commands/stop.d.ts +0 -2
  137. package/lib/vm/commands/string-commands.d.ts +0 -9
  138. package/lib/vm/commands/talk.d.ts +0 -2
  139. package/lib/vm/commands/text.d.ts +0 -13
  140. package/lib/vm/commands/wait.d.ts +0 -4
  141. package/lib/vm/renpy-vm.d.ts +0 -11
  142. package/lib/vm/vm-helpers.d.ts +0 -16
  143. package/lib/vm/vm-parser.d.ts +0 -19
  144. package/lib/vm/vm.d.ts +0 -19
package/CHANGELOG.md CHANGED
@@ -1,10 +1,24 @@
1
1
  # Narrat changelog
2
2
 
3
+ ## 2.0.0-rc4
4
+
5
+ ### Important Note
6
+
7
+ The main CSS file from narrat must now be imported in games using it to have the default CSS.
8
+
9
+ Simply add `import 'narrat/dist/style.css';` at the top of your `index.ts` (before your own CSS).
10
+
11
+ ### Switch to vite
12
+
13
+ To make developping narrat easier, the bundler used has been switched from rollup to vite. Vite is recommended as the standard for Vue these days, and the rollup vue plugin is deprecated. The update was necessary to support more recent features.
14
+
15
+ This has no impact on end users, other than having to import the CSS file as explained above.
16
+
3
17
  ## 2.0.0-rc3
4
18
 
5
- * Improvements to debugging to show more useful info on parser/runtime errors
6
- * Corrected display of line numbers in errors
7
- * Made parser continue parsing after errors to make it easier to see all errors at once and to be able to play the game even if there are parser errors
19
+ - Improvements to debugging to show more useful info on parser/runtime errors
20
+ - Corrected display of line numbers in errors
21
+ - Made parser continue parsing after errors to make it easier to see all errors at once and to be able to play the game even if there are parser errors
8
22
 
9
23
  ## 2.0.0-rc1
10
24
 
package/README.md CHANGED
@@ -26,15 +26,13 @@ See the [Documentation](https://docs.get-narrat.com/) for more info, or jump dir
26
26
 
27
27
  ## Features
28
28
 
29
- * Flexible dialog writing with branching and conditions
30
- * Multiple script files support with labels and jumps to organise script writing
31
- * Multiple speaking characters support with icons and poses
32
- * Custom variables in scripts to create flags or other data the game needs to track
33
- * Seamless saving and reloading
34
- * UI with buttons that can be used for example to create world maps with clickable locations (the buttons can be controlled in scripts)
35
- * Sound and music support
36
- * Delays between script lines
37
- * Electron build to turn the game into a pc/mac/linux app (template to be updated with example soon)
38
- * Skill checks (Feature still early, needs a UI for viewing skills and creating characters)
39
-
40
-
29
+ - Flexible dialog writing with branching and conditions
30
+ - Multiple script files support with labels and jumps to organise script writing
31
+ - Multiple speaking characters support with icons and poses
32
+ - Custom variables in scripts to create flags or other data the game needs to track
33
+ - Seamless saving and reloading
34
+ - UI with buttons that can be used for example to create world maps with clickable locations (the buttons can be controlled in scripts)
35
+ - Sound and music support
36
+ - Delays between script lines
37
+ - Electron build to turn the game into a pc/mac/linux app (template to be updated with example soon)
38
+ - Skill checks (Feature still early, needs a UI for viewing skills and creating characters)
package/dist/.DS_Store ADDED
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,62 @@
1
+ {
2
+ "config": {
3
+ "imagesPath": "./img/characters/"
4
+ },
5
+ "characters": {
6
+ "game": {
7
+ "name": "",
8
+ "color": "white"
9
+ },
10
+ "player": {
11
+ "style": {
12
+ "color": "orange"
13
+ },
14
+ "name": "You"
15
+ },
16
+ "cat": {
17
+ "sprites": {
18
+ "idle": "cat_idle.jpg"
19
+ },
20
+ "style": {
21
+ "color": "white"
22
+ },
23
+ "name": "Generic Cat"
24
+ },
25
+ "shopkeeper": {
26
+ "sprites": {
27
+ "idle": "music_cat.jpeg"
28
+ },
29
+ "style": {
30
+ "color": "white"
31
+ },
32
+ "name": "Shopkeeper"
33
+ },
34
+ "helper": {
35
+ "sprites": {
36
+ "idle": "helper_cat.png"
37
+ },
38
+ "style": {
39
+ "color": "green"
40
+ },
41
+ "name": "Helper Cat"
42
+ },
43
+ "music_cat": {
44
+ "sprites": {
45
+ "idle": "music_cat.jpeg"
46
+ },
47
+ "style": {
48
+ "color": "green"
49
+ },
50
+ "name": "Music Cat"
51
+ },
52
+ "inner": {
53
+ "sprites": {
54
+ "idle": "inner_voice.png"
55
+ },
56
+ "style": {
57
+ "color": "red"
58
+ },
59
+ "name": "Inner Voice"
60
+ }
61
+ }
62
+ }
@@ -0,0 +1,176 @@
1
+ {
2
+ "gameTitle": "Narrat Game Example",
3
+ "images": {
4
+ "narrat": "img/backgrounds/narrat.png",
5
+ "map": "img/backgrounds/map.png",
6
+ "shopButton": "img/ui/shop-button.png",
7
+ "parkButton": "img/ui/park-button.png"
8
+ },
9
+ "layout": {
10
+ "backgrounds": {
11
+ "width": 880,
12
+ "height": 720
13
+ },
14
+ "dialogBottomPadding": 70,
15
+ "minTextWidth": 475,
16
+ "mobileDialogHeightPercentage": 60,
17
+ "verticalLayoutThreshold": 1000,
18
+ "portraits": {
19
+ "width": 100,
20
+ "height": 100
21
+ }
22
+ },
23
+ "screens": {
24
+ "default": {
25
+ "background": "narrat"
26
+ },
27
+ "map": {
28
+ "background": "map",
29
+ "buttons": ["shopButton", "parkButton"]
30
+ }
31
+ },
32
+ "buttons": {
33
+ "shopButton": {
34
+ "enabled": false,
35
+ "background": "shopButton",
36
+ "position": {
37
+ "left": 38,
38
+ "top": 6,
39
+ "width": 255,
40
+ "height": 226
41
+ },
42
+ "action": "shopButton"
43
+ },
44
+ "parkButton": {
45
+ "enabled": false,
46
+ "background": "parkButton",
47
+ "position": {
48
+ "left": 632,
49
+ "top": 86,
50
+ "width": 255,
51
+ "height": 226
52
+ },
53
+ "action": "parkButton"
54
+ }
55
+ },
56
+ "skills": {
57
+ "agility": {
58
+ "name": "Agility",
59
+ "description": "How good you are at moving around.",
60
+ "startingLevel": 0,
61
+ "icon": "img/skills/agility.jpg",
62
+ "hidden": true
63
+ },
64
+ "haggling": {
65
+ "name": "Haggling",
66
+ "description": "Get good prices on items",
67
+ "icon": "img/skills/logic.jpg",
68
+ "startingLevel": 1
69
+ }
70
+ },
71
+ "skillChecks": {
72
+ "rollRange": 100,
73
+ "skillMultiplier": 10,
74
+ "failureChance": 1,
75
+ "difficultyText": [
76
+ [0, "Very Easy"],
77
+ [10, "Easy"],
78
+ [30, "Medium"],
79
+ [50, "Hard"],
80
+ [70, "Very Hard"],
81
+ [80, "Extremely Hard"],
82
+ [90, "Near Impossible"]
83
+ ]
84
+ },
85
+ "scripts": ["data/example.rpy"],
86
+ "audio": {
87
+ "calm": {
88
+ "loop": true,
89
+ "src": "music/calm.mp3"
90
+ },
91
+ "click": {
92
+ "src": "audio/click.ogg"
93
+ },
94
+ "game_start": {
95
+ "src": "audio/game_start.ogg"
96
+ },
97
+ "failure": {
98
+ "src": "audio/failure.ogg"
99
+ },
100
+ "success": {
101
+ "src": "audio/success.wav"
102
+ }
103
+ },
104
+ "audioOptions": {
105
+ "volume": 0.5,
106
+ "musicFadeInTime": 0.5,
107
+ "musicFadeInDelay": 0.5,
108
+ "musicFadeOutTime": 0.5
109
+ },
110
+ "notifications": {
111
+ "timeOnScreen": 2.5,
112
+ "alsoPrintInDialogue": true
113
+ },
114
+ "hudStats": {
115
+ "money": {
116
+ "icon": "img/ui/money.png",
117
+ "name": "Money",
118
+ "startingValue": 10,
119
+ "minValue": 0
120
+ },
121
+ "energy": {
122
+ "icon": "img/ui/energy.png",
123
+ "name": "Energy",
124
+ "startingValue": 10,
125
+ "minValue": 0,
126
+ "maxValue": 10
127
+ }
128
+ },
129
+ "items": {
130
+ "bread": {
131
+ "name": "Bread",
132
+ "description": "A bread in the game.",
133
+ "icon": "img/items/bread.png",
134
+ "onUse": {
135
+ "action": "jump",
136
+ "label": "eat_bread"
137
+ }
138
+ },
139
+ "book": {
140
+ "name": "Ominous Book",
141
+ "description": "An ominous book. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque sed ullamcorper turpis. Aliquam tincidunt dolor sed mollis aliquet. Duis in odio eros. Maecenas sapien arcu, fermentum id tincidunt non, accumsan vel metus. Nullam pretium molestie accumsan. In ut rutrum tellus. Integer vitae nisl eleifend lorem tristique auctor quis sed nulla. Cras gravida viverra tristique. Mauris imperdiet tortor purus, fringilla vehicula metus ullamcorper eget. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla porta imperdiet justo, sed blandit orci. Aenean accumsan hendrerit arcu, laoreet vestibulum turpis vulputate eu. Etiam dignissim nibh dictum pharetra congue. Nulla ultrices, augue a blandit laoreet, metus enim sodales arcu, eget pellentesque lorem justo et ipsum. ",
142
+ "icon": "img/items/book.png",
143
+ "onUse": {
144
+ "action": "run_label",
145
+ "label": "read_book"
146
+ },
147
+ "tag": "always_interactable"
148
+ }
149
+ },
150
+ "interactionTags": {
151
+ "default": {
152
+ "onlyInteractOutsideOfScripts": true
153
+ }
154
+ },
155
+ "quests": {
156
+ "breadShopping": {
157
+ "title": "Bread Shopping",
158
+ "description": "The helper cat asked you to buy bread for him.",
159
+ "objectives": {
160
+ "bread": {
161
+ "description": "Buy bread for the helper cat."
162
+ },
163
+ "delivery": {
164
+ "hidden": true,
165
+ "description": "Deliver the bread to the helper cat."
166
+ }
167
+ }
168
+ }
169
+ },
170
+ "audioTriggers": {
171
+ "onPlayerAnswered": "click",
172
+ "onPressStart": "game_start",
173
+ "onSkillCheckFailure": "failure",
174
+ "onSkillCheckSuccess": "success"
175
+ }
176
+ }
@@ -0,0 +1,356 @@
1
+ main:
2
+ var meal (run_label takeout_menu Cake)
3
+ "The player chose to eat %{meal}"
4
+
5
+ takeout_menu third_option:
6
+ var meal ""
7
+ choice:
8
+ talk helper idle "Which meal do you want?"
9
+ "Pizza":
10
+ set meal pizza
11
+ "Burger":
12
+ set meal burger
13
+ "%{third_option}":
14
+ set meal $third_option
15
+ talk helper idle "Chosen %{meal}"
16
+ return $meal
17
+
18
+ test_functions:
19
+ talk player idle "Function test label"
20
+ return (+ 1 2)
21
+
22
+ test_scopes:
23
+ var test1 1
24
+ talk player idle "Declared test1: %{test1}"
25
+ run_label test_scopes_2
26
+ talk player idle "Back to original scope, shouldn't have access to test2: %{test2}"
27
+
28
+ test_scopes_2:
29
+ var test2 2
30
+ talk player idle "Entered scope 2, still have access to test1: %{test1}"
31
+ talk player idle "Declared test2 in scope 2: %{test2}"
32
+
33
+ random_tests:
34
+ var test 2
35
+ talk helper idle "%{test}"
36
+ add test 1
37
+ talk helper idle "%{test}"
38
+ talk helper idle "Hello world"
39
+ start_quest breadShopping
40
+ choice:
41
+ "Can we spend some energy?"
42
+ "Spend 5 energy" if (>= (get_stat_value energy) 5):
43
+ add_stat energy -5
44
+ talk player idle "Spent 5 energy!"
45
+ "Don't spend":
46
+ talk player idle "Didn't spend anything"
47
+ set data.winThreshold 10
48
+ set data.player.score 5
49
+ set data.player.scoreBonus 5
50
+ if (== (+ $data.player.score $data.player.scoreBonus) $data.winThreshold):
51
+ "The player won!"
52
+
53
+ if (roll testAudio agility 90):
54
+ "yahoo"
55
+ else:
56
+ "oh no"
57
+ if (quest_started? breadShopping):
58
+ "The quest has started"
59
+ else:
60
+ "It's not working"
61
+ if (|| (== (+ 1 2 3 4) 10) (== (+ 1 2 3) 5) (== (+ 1 2) 3 3 3 3)):
62
+ "It's true"
63
+ else:
64
+ "It's false"
65
+ set data.counter (+ 1 2)
66
+ add_item book 1
67
+ if (has_item? book 1):
68
+ "There's a book in the inventory"
69
+ if (== (item_amount? book) 1):
70
+ "We have 1 book"
71
+ talk helper idle "Hello world"
72
+ set data.counter 1
73
+ jump quest_demo
74
+ notify "Hello world!"
75
+ start_quest breadShopping
76
+ add_item bread 15
77
+ remove_item bread 10
78
+ if (> $items.bread.amount 0):
79
+ talk helper idle "You have %{items.bread.amount} bread"
80
+ else:
81
+ talk helper idle "You have no bread"
82
+ clear_dialog
83
+ complete_objective breadShopping bread
84
+ choice:
85
+ "Let's do a skill check"
86
+ roll aSkillCheck agility 70 "Test skill roll" hideAfterRoll:
87
+ success:
88
+ talk player idle "Woo I did it"
89
+ failure "Text if the skill check failed":
90
+ talk player idle "Oh no I failed"
91
+ "Another choice":
92
+ "Hello too"
93
+ complete_quest breadShopping "You helped the cat get bread"
94
+ if (roll someSkillCheck agility 40):
95
+ set data.skillcheckDone true
96
+ "You open the narrat demo and wonder how this thing even works"
97
+ choice:
98
+ "How about asking for help?"
99
+ "Ask for help":
100
+ jump askForHelp
101
+ "No, I don't want help 😡"
102
+ jump dontAskForHelp
103
+
104
+ functions_test:
105
+ run_label some_function
106
+ talk player idle "Back to functions_test"
107
+ run_label some_function
108
+
109
+ some_function:
110
+ talk player idle "Ran the function %{data.counter} times"
111
+ add data.counter 1
112
+
113
+ skillCheckTest:
114
+ choice:
115
+ "Let's do a skill check"
116
+ roll aSkillCheck agility 70 "Test skill roll":
117
+ success:
118
+ talk player idle "Woo I did it"
119
+ failure "Text if the skill check failed":
120
+ talk player idle "Oh no I failed"
121
+ "Another choice":
122
+ "Hello too"
123
+ if (roll someSkillCheck agility 40):
124
+ set data.skillcheckDone true
125
+ jump skillCheckTest
126
+ stats:
127
+ talk player idle "Trying energy feature"
128
+ choice:
129
+ "Can we spend some energy?"
130
+ "Spend 5 energy" if (>= $stats.energy 5):
131
+ add_stat energy -5
132
+ talk player idle "Spent 5 energy!"
133
+ "Don't spend":
134
+ talk player idle "Didn't spend anything"
135
+ jump stats
136
+
137
+ xpTest:
138
+ talk helper idle "Gaining 3 logic xp"
139
+ add_xp haggling 3
140
+ jump xpTest
141
+
142
+ askForHelp:
143
+ talk helper idle "Hello! I heard you're trying to play the narrat demo!"
144
+ talk helper idle "You can view the source script for this demo in the <a href=\"https:\/\/github.com\/nialna\/narrat-demo\" target=\"_blank\">demo repo</a>"
145
+ talk helper idle "There is also a <a href=\"https:\/\/github.com\/nialna\/narrat-template\" target=\"_blank\">game template</a> ready to use."
146
+ talk helper idle "As you've probably noticed, you can make choices in this."
147
+ talk helper idle "There are lots of things you can do to make an interactive story in Narrat really. Choices are one of the most useful ones."
148
+ talk helper idle "I'm going to send you to my other friend who has some questions for you."
149
+ jump askAboutChoices
150
+
151
+ askAboutChoices:
152
+ choice:
153
+ talk cat idle "Hi it's me, another generic cat! Do you like making choices in games?"
154
+ "Yes":
155
+ set data.choices true
156
+ "Cat will remember this."
157
+ "No":
158
+ add_level agility 2
159
+ "Cat will remember this."
160
+ choice:
161
+ talk helper idle "Now I think we should do an activity, what do you like doing?"
162
+ "let's make choices cause I like making choices!" if $data.likeChoices:
163
+ jump makeChoices
164
+ "let's do nothing!":
165
+ jump doNothing
166
+
167
+
168
+ dontAskForHelp:
169
+ // clear_dialog
170
+ talk inner idle "Maybe we should get help though? I don't really know what else to do"
171
+ jump main
172
+
173
+ makeChoices:
174
+ choice:
175
+ talk inner idle "I don't know, we've been making a lot of choices already lately."
176
+ "I still want to make a choice!":
177
+ talk helper idle "Well you just made one, it turns out. Can we continue now?"
178
+ jump doNothing
179
+ "I guess you're right":
180
+ jump doNothing
181
+
182
+
183
+ doNothing:
184
+ choice:
185
+ talk music_cat idle "How about we get some music in here?"
186
+ "Play some relaxing music":
187
+ "The music is going to start and stop with timers to show the feature"
188
+ play music calm
189
+ wait 2000
190
+ pause music
191
+ wait 500
192
+ play music calm
193
+ wait 500
194
+ stop music
195
+ wait 500
196
+ play music calm
197
+ "I hate music":
198
+ talk music_cat idle "Well too bad, it's up to you."
199
+ jump otherFeatures
200
+
201
+ otherFeatures:
202
+ talk helper idle "There are lots of other features, like skill checks and conditions."
203
+ if (roll someSkillCheck agility 40):
204
+ "For example this line only appears if you passed a skill check"
205
+ "This engine is still very early and not fully documented yet, but you can look at the example demo and how it is made."
206
+ "There is also a screen feature on the left where you can display background images with interactive buttons."
207
+ jump showMap
208
+
209
+ showMap:
210
+ set_screen map
211
+ set_button parkButton true
212
+ talk helper idle "This is an example map. There are buttons you can click on. It is possible to dynanically enable and disable buttons in your script"
213
+ talk helper idle "You can view the source script for this demo in the <a href=\"https:\/\/github.com\/nialna\/narrat-demo\">demo repo</a>"
214
+
215
+ quest_demo:
216
+ set_button shopButton true
217
+ set_button parkButton false
218
+ jump bread_quest
219
+
220
+ bread_quest:
221
+ choice:
222
+ talk helper idle "Can you get 2 pieces of bread for me?"
223
+ "Yes":
224
+ talk helper idle "Thanks, that's very nice!"
225
+ talk helper idle "I'll be waiting for you at the park"
226
+ jump bread_start
227
+ "No":
228
+ talk helper idle "Oh, okay"
229
+ jump quest_demo
230
+
231
+ bread_start:
232
+ start_quest breadShopping
233
+ talk inner idle "Time to go to the shop to buy some bread then."
234
+ set_screen map
235
+ set_button shopButton true
236
+
237
+ shopButton:
238
+ set_screen default
239
+ "You visit the bread shop"
240
+ talk shopkeeper idle "Hello, I'm a little baker selling bread!"
241
+ set data.breadPrice 5
242
+ jump shop_menu
243
+
244
+ parkButton:
245
+ choice:
246
+ talk helper idle "Ah, so do you have my bread?"
247
+ "Yes!" if (>= $items.bread.amount 2):
248
+ talk helper idle "Thanks a lot!"
249
+ complete_objective breadShopping delivery
250
+ complete_quest breadShopping
251
+ "No :(":
252
+ talk helper idle "Oh okay"
253
+ set_button parkButton false
254
+
255
+ shop_menu:
256
+ choice:
257
+ talk shopkeeper idle "So, do you want some bread?"
258
+ "Buy bread (costs %{data.breadPrice})" if (>= $stats.money.value $data.breadPrice):
259
+ add_item bread 1
260
+ if (== $data.breadPrice 5):
261
+ add_stat money -5
262
+ else:
263
+ add_stat money -4
264
+ jump map_update
265
+ roll bread_haggle haggling 50 "Try to haggle for bread" hideAfterRoll:
266
+ success "You explain that helper cat needs bread to feed his poor family":
267
+ set data.breadPrice 4
268
+ talk shopkeeper idle "I guess I can sell you bread for 4 coins"
269
+ jump shop_menu
270
+ failure "You try to pity trip the shopkeeper but he won't bulge":
271
+ talk shopkeeper idle "The price is 5 coins, nothing less, nothing more."
272
+ jump shop_menu
273
+ "Exit":
274
+ jump map_update
275
+
276
+ map_update:
277
+ if (>= $items.bread.amount 2):
278
+ complete_objective breadShopping bread
279
+ talk inner idle "I've got enough bread now, I'm going to go to the park."
280
+ start_objective breadShopping delivery
281
+ set_screen map
282
+ set_button parkButton true
283
+ set_button shopButton false
284
+ else:
285
+ talk inner idle "Hmm, I still need to buy more bread for helper cat."
286
+ set_screen map
287
+
288
+ eat_bread:
289
+ talk player idle "hmm, bread"
290
+
291
+ read_book:
292
+ talk inner idle "It's full of ocult rituals. I'm not sure what they are, but I'm sure they are useful."
293
+
294
+ label_to_jump:
295
+ talk cat idle "The code has now jumped to this label"
296
+
297
+ jump_example:
298
+ talk cat idle "Hello, this is an example about jumping to other labels"
299
+ talk cat idle "Use the jump command to jump to a different label in any of your scripts"
300
+ jump label_to_jump
301
+
302
+ choice_example:
303
+ talk cat idle "This example shows how to use the choice command"
304
+ choice:
305
+ "This is the choice prompt text"
306
+ "This is the first option the player can select":
307
+ talk cat idle "I will say this if you select the first option"
308
+ "This is the second choice the player can pick":
309
+ talk cat idle "I see you picked the second choice!"
310
+
311
+ choice_example_conditions:
312
+ talk cat idle "This example shows how to use conditions in choices"
313
+ choice:
314
+ "This is the choice prompt text"
315
+ "This choice will only appear if a condition is met" if $data.someFlag:
316
+ talk cat idle "Choice response"
317
+ roll someSkillCheck agility 50 "This choice will run a skill check":
318
+ success "Skill check succeeded":
319
+ "This line will appear if the skill check succeeds"
320
+ failure "Skill check failed":
321
+ "This line will appear if the skill check fails"
322
+
323
+
324
+ set_example:
325
+ choice:
326
+ talk cat idle "Do you like surprises?"
327
+ "Yes":
328
+ set data.like_surprises true
329
+ "No!":
330
+ set data.like_surprises false
331
+ if $data.like_surprises:
332
+ talk cat idle "Since you like surprises, here's a surprise message"
333
+
334
+
335
+ add_example:
336
+ set data.counter 0
337
+ jump add_example_add
338
+
339
+ add_example_add:
340
+ choice:
341
+ talk cat idle "Do you want to increase the counter? You can only do it 10 times":
342
+ "Increase the counter" if (< $data.counter 10):
343
+ add data.counter 1
344
+ "No!":
345
+ talk cat idle "Ok then"
346
+ "I'm done" if (>= $data.counter 10):
347
+ jump add_example_end
348
+ jump add_example_add
349
+
350
+ add_example_end:
351
+ talk cat idle "It seems you're done with the counter now"
352
+
353
+ talk_example:
354
+ talk cat idle "I'm talking to you!"
355
+ "This is a shortcut for the narrator talking"
356
+ talk player idle "The player can also talk"
@@ -0,0 +1,31 @@
1
+ main:
2
+ "hello world"
3
+ set data.player.name "Alice"
4
+ set data.player.rank "Beginner"
5
+ run_label update_rank_text
6
+ choice:
7
+ "Yes or no?"
8
+ "Yes" (== 1 2):
9
+ talk player idle "You said yes"
10
+ "no":
11
+ talk player idle "You said no"
12
+ roll bread_haggle haggling 70 "Try to haggle for bread":
13
+ success:
14
+ talk player idle "You haggled for bread"
15
+ failure:
16
+ talk player idle "You failed to haggle for bread"
17
+ talk cat idle $data.player.rankText
18
+ if (== (+ 1 3) 3)
19
+ talk player idle "condition is true"
20
+ else:
21
+ talk player idle "condition is false"
22
+ jump jump_test
23
+
24
+ update_rank_text:
25
+ set data.player.rankText "%{data.player.name} is a %{data.player.rank}."
26
+
27
+ run_test:
28
+ talk player idle "it's a function"
29
+
30
+ jump_test:
31
+ talk player idle "you jumped"
Binary file
Binary file