narrat 1.3.2 → 1.3.3

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.
package/CHANGELOG.md DELETED
@@ -1,541 +0,0 @@
1
- # Narrat changelog
2
-
3
- ## 1.3.2
4
-
5
- - Improvement to variables editor for debugging
6
- - Bugfixes to access quests in conditions
7
-
8
- ## 1.3.1
9
-
10
- New feature to "use" items.
11
-
12
- In an item config, an optional `onUse` value is available, which cn be set to a label to jump to when using the item.
13
-
14
- There are also interaction groups which allow scripts to toggle on/off whether using items is allowed. They can be configured to automatically be turned off during dialogue scripts (to avoid bugs/side effects that jumping to an item's label would cause halfway through dialogue).
15
-
16
- Config:
17
-
18
- ```json
19
- "items": {
20
- "bread": {
21
- "name": "Bread",
22
- "description": "A bread in the game.",
23
- "icon": "img/items/bread.png",
24
- "onUse": {
25
- "action": "jump",
26
- "label": "eat_bread"
27
- },
28
- "tag": "default"
29
- },
30
- "book": {
31
- "name": "Ominous Book",
32
- "description": "An ominous book",
33
- "icon": "img/items/book.png",
34
- "onUse": {
35
- "action": "run_label",
36
- "label": "read_book"
37
- },
38
- "tag": "always_interactable"
39
- }
40
- },
41
- "interactionTags": {
42
- "default": {
43
- "onlyInteractOutsideOfScripts": true
44
- }
45
- }
46
- ```
47
-
48
- The `onUse` `action` property can be either `jump` or `run_label`, allowing to either jump to a script, or run a script as a function (see [1.3.0 changes](#1.3.0) or [functions docs](https://docs.get-narrat.com/features/functions)), which effectively allows interrupting the current dialogue to run an item's function before going back to it.
49
-
50
- The `tag` property on an item data sets which interaction group it is part of. This allows fine control of which items can be allowed to be used when. For example, some items might be available to use all the time, while some should only be allowed to be used at certain points.
51
-
52
- By default if not provided, items have the `default` tag, and the default configuration has the `default` tag set to use `onlyInteractOutsideOfScripts`, which automatically disables interaction during scripts to avoid issues.
53
-
54
- In the example above, the bread can only be interacted with outside of scripts and will use a jump to a label, while the book can be interacted with at any time and will use a `run_label`, effectively running a label as a function and then going back to where the script was.
55
-
56
- In scripts, interaction tags can be controlled:
57
-
58
- ```py
59
- main:
60
- disable_interaction someTag
61
- talk player idle "Impossible to use items with the tag someTag for now"
62
- enable_interaction someTag
63
- talk player idle "It is now possible to use items with the tag someTag"
64
- ```
65
-
66
- ## 1.3.0
67
-
68
- New `run_label` function to run a label as a "function"
69
-
70
- The difference between this and jump is that using `run_label` will go back to where you were before once the label is over.
71
-
72
- For example:
73
-
74
- ```py
75
- main:
76
- set data.counter 1
77
- jump functions_test
78
-
79
- functions_test:
80
- run_label some_function
81
- talk player idle "Back to functions_test"
82
- run_label some_function
83
- talk player idle "We're back again"
84
-
85
- some_function:
86
- talk player idle "Ran the function %{data.counter} times"
87
- add data.counter 1
88
- ```
89
-
90
- In this example when running `functions_test`, the script in `some_function` will be ran, then the execution comes back to do the rest of `functions_test`.
91
-
92
- **Note:** Saving still only happens when _jumping_ to a label, because being at a specific label is the only way to make sure a save file can keep working if the code of the game gets changed in an update.
93
-
94
- ## 1.2.1
95
-
96
- Improved reset feature when returning to main menu to avoid potential bugs
97
-
98
- ## 1.2.0
99
-
100
- ## Quests system
101
-
102
- There is a new quests system.
103
-
104
- Quests can be defined in the config:
105
-
106
- ```json
107
- "quests": {
108
- "breadShopping": {
109
- "title": "Bread Shopping",
110
- "description": "The helper cat asked you to buy bread for him.",
111
- "objectives": {
112
- "bread": {
113
- "description": "Buy bread for the helper cat."
114
- },
115
- "delivery": {
116
- "description": "Deliver the bread to the helper cat."
117
- }
118
- }
119
- }
120
- }
121
- ```
122
-
123
- Scripts can interact with the quest system:
124
-
125
- - Start Quest: `start_quest breadShopping`
126
- - Start objective: `start_objective breadShopping delivery` (for hidden objectives)
127
- - Complete objective: `complete_objective breadShopping bread`
128
- - Complete quest: `complete_quest breadShopping`
129
-
130
- Example demo:
131
-
132
- ```py
133
- quest_demo:
134
- set_button shopButton true
135
- set_button parkButton false
136
- jump bread_quest
137
-
138
- bread_quest:
139
- choice:
140
- talk helper idle "Can you get 2 pieces of bread for me?"
141
- "Yes":
142
- talk helper idle "Thanks, that's very nice!"
143
- talk helper idle "I'll be waiting for you at the park"
144
- jump bread_start
145
- "No":
146
- talk helper idle "Oh, okay"
147
- jump quest_demo
148
-
149
- bread_start:
150
- start_quest breadShopping
151
- talk inner idle "Time to go to the shop to buy some bread then."
152
- set_screen map
153
- set_button shopButton true
154
-
155
- shopButton:
156
- set_screen default
157
- "You visit the bread shop"
158
- talk shopkeeper idle "Hello, I'm a little baker selling bread!"
159
- set data.breadPrice 5
160
- jump shop_menu
161
-
162
- parkButton:
163
- choice:
164
- talk helper idle "Ah, so do you have my bread?"
165
- "Yes!" $if this.items.bread.amount >= 2:
166
- talk helper idle "Thanks a lot!"
167
- complete_objective breadShopping delivery
168
- complete_quest breadShopping
169
- "No :(":
170
- talk helper idle "Oh okay"
171
- set_button parkButton false
172
-
173
- shop_menu:
174
- choice:
175
- talk shopkeeper idle "So, do you want some bread?"
176
- "Buy bread (costs %{data.breadPrice})" $if this.stats.money.value >= this.data.breadPrice:
177
- add_item bread 1
178
- $if this.data.breadPrice === 5:
179
- add_stat money -5
180
- else:
181
- add_stat money -4
182
- jump map_update
183
- roll bread_haggle haggling 50 "Try to haggle for bread" hideAfterRoll:
184
- success "You explain that helper cat needs bread to feed his poor family":
185
- set data.breadPrice 4
186
- talk shopkeeper idle "I guess I can sell you bread for 4 coins"
187
- jump shop_menu
188
- failure "You try to pity trip the shopkeeper but he won't bulge":
189
- talk shopkeeper idle "The price is 5 coins, nothing less, nothing more."
190
- jump shop_menu
191
- "Exit":
192
- jump map_update
193
-
194
- map_update:
195
- $if this.items.bread.amount >= 2:
196
- complete_objective breadShopping bread
197
- talk inner idle "I've got enough bread now, I'm going to go to the park."
198
- start_objective breadShopping delivery
199
- set_screen map
200
- set_button parkButton true
201
- set_button shopButton false
202
- else:
203
- talk inner idle "Hmm, I still need to buy more bread for helper cat."
204
- set_screen map
205
- ```
206
-
207
- ## 1.1.0
208
-
209
- ### Inventory system
210
-
211
- There is a new inventory system.
212
-
213
- Possible items can be defined in the config:
214
-
215
- ```json
216
- "items": {
217
- "bread": {
218
- "name": "Bread",
219
- "description": "A bread in the game.",
220
- "icon": "img/items/bread.png"
221
- }
222
- }
223
- ```
224
-
225
- Then items can be added/removed in scripts:
226
-
227
- ```py
228
- main:
229
- add_item bread 15
230
- remove_item bread 10
231
- $if this.items.bread.amount > 0:
232
- talk helper idle "You have %{items.bread.amount} bread"
233
- else:
234
- talk helper idle "You have no bread"
235
- ```
236
-
237
- ## 1.0.0
238
-
239
- ### State management rewrite
240
-
241
- Rewrote the state management of the engine using [pinia](https://pinia.vuejs.org/) instead of Vuex for state management.
242
-
243
- This allows the state to be more modular, easy to use and better compatible with Vue.js devtools for development of the engine, as pinia is now the official vue state management library.
244
-
245
- The version has been bumped to 1.0.0 as it's a major rewrite. No bugs have been found when testing though.
246
-
247
- ### Save files breaking change
248
-
249
- The save file format has changed, so saved games from previous versions would break. As no one is using this engine in production for now, this isn't an issue.
250
-
251
- A new `version` string has been added to save files, so that in the future it will be possible to add migrations from older save files to newer ones if needed
252
-
253
- ## Updated Vue version
254
-
255
- The Vue dependency version has been updated to the current latest (3.2.37)
256
-
257
- ## Vuex peer dependency deleted
258
-
259
- Vuex is no longer a peer dependency, and has been replaced with pinia.
260
-
261
- ## 0.11.1
262
-
263
- Fixed an error in how the narrat packaged is exported
264
-
265
- ## 0.11.0
266
-
267
- ### New Plugin system!
268
-
269
- There is now a plugin system developers can use to add new functionality to narrat (more documentation soon). See the [narrat-bitsy](https://github.com/liana-pigeot/narrat-bitsy) plugin for an example.
270
-
271
- ## 0.10.0
272
-
273
- ### New XP System
274
-
275
- - XP can be accumulated to level
276
- - config option: `skillOptions.xpPerLevel`
277
- - Use `add_xp` in script tso add xp, just like adding levels
278
- - XP now displayed in skills menu
279
-
280
- ### Other improvements
281
-
282
- - Improvements in skill checks display and difficulty
283
- - Bug fixes to skill check edge cases
284
- - Fixed a bug when not having a default title screen music
285
- - Added a new `hideAfterRoll` option to skill checks to hide their choice after they've happened once
286
- - Refactored skill check code for internal consistency between the different ways they're run
287
- - New CSS variables and classes to customise the look of skill check prompts
288
-
289
- ## 0.9.4
290
-
291
- - Fixed a bug when going back to the main menu and reloading the save without refreshing the page
292
- - New `defaultMusic` option in audio options for title screen music
293
-
294
- ## 0.9.3
295
-
296
- - Fixed a bug when loading a saved game
297
-
298
- ## 0.9.2
299
-
300
- - Added new CSS variables and id/classes to make it easier to theme games
301
-
302
- Current CSS variables list (Look at [main.css](https://github.com/liana-pigeot/narrat/blob/main/src/sass/main.css) in the narrat repo for up to date version):
303
-
304
- ```css
305
- :root {
306
- --bg-color: #131720;
307
- --text-color: #d9e1f2;
308
- --primary: hsl(255, 30%, 55%);
309
- --focus: hsl(210, 90%, 50%);
310
- --secondary: #42b983;
311
- --border-color: hsla(0, 0%, 100%, 0.2);
312
- --light-1: hsl(210, 30%, 40%);
313
- --light-2: hsl(255, 30%, 50%);
314
- --light-background: linear-gradient(to right, var(--light-1), var(--light-2));
315
- --shadow-1: hsla(236, 50%, 50%, 0.3);
316
- --shadow-2: hsla(236, 50%, 50%, 0.4);
317
- --hud-background: rgba(0, 0, 0, 0.4);
318
- --hud-text-color: var(--text-color);
319
- --notifications-bg: darkslateblue;
320
-
321
- --skills-text-background: rgba(0, 0, 0, 0.5);
322
- --skills-text-color: var(--text-color);
323
- --skills-level-background: rgba(0, 0, 0, 0.5);
324
- --skills-level-color: orange;
325
- }
326
- ```
327
-
328
- Can be edited in a game's CSS file by overriding those variables in a more specific selector. For example:
329
-
330
- ```css
331
- #app {
332
- --bg-color: white;
333
- --text-color: black;
334
- }
335
- ```
336
-
337
- would override the background and text colors of the game
338
-
339
- ## 0.9.1
340
-
341
- - Fixed a file capitalisation error in 0.9.0
342
-
343
- ## 0.9.0
344
-
345
- ### Breaking Changes
346
-
347
- New config options for skills:
348
-
349
- - `icon`: Path to the image to use for the skill's icon (currently the skill widget is 200x300, but you can override the CSS if needed)
350
- - `hidden`: Optional boolean to make the skill hidden until it is "obtained". A skill that is configured to be hidden will only start appearing in the skills menu once it's above level 0
351
-
352
- Example skills config:
353
-
354
- ```json
355
- "skills": {
356
- "agility": {
357
- "name": "Agility",
358
- "description": "How good you are at moving around.",
359
- "startingLevel": 0,
360
- "icon": "img/skills/agility.jpg",
361
- "hidden": true
362
- },
363
- "logic": {
364
- "name": "Logic",
365
- "description": "How good you are at solving problems",
366
- "icon": "img/skills/logic.jpg",
367
- "startingLevel": 0
368
- }
369
- },
370
- ```
371
-
372
- ### Bug Fixes
373
-
374
- - Music could play multiple times at once when replaying the same music
375
-
376
- ### New Features and improvements
377
-
378
- #### Development and debug
379
-
380
- - Improved debug menu with a **variable editor** to view and edit values in the `data` object.
381
- - Also added a separate editor for the entire engine/app state. Can be useful for debugging complex bugs by exploring the state of the app.
382
- - New **Quick label jump** feature to easily jump to specific labels for testing. Press **J** to open and type the name of a label then select a result with up/down arrows and press Enter
383
- - New keyboard shortcut to open debug menu (**d**)
384
- - Added a debug info panel on the main starting screen of the game with info on the shortcuts
385
-
386
- #### Engine improvements
387
-
388
- - Menu modal improved to be more compact with a cleaner design
389
- - Added fade in and fade outs when changing music (configurable in config)
390
- - **Improved the default UI** to be more pleasing to look at
391
- - Added a **return to Main Menu** button to the main menu for resetting the game
392
- - New **Skills Menu** allowing players to view their skills:
393
- - It only appears if the game has skills configured
394
- - It shows skill icons, name and current level on a grid
395
- - Clicking on a skill opens a skill page with more detailed info and the skill description
396
- - The skill menu button is next to the usual menu button
397
-
398
- ## 0.8.5
399
-
400
- - Fixed a bug with `clear_dialog` that was disabling all interaction upon use
401
-
402
- ## 0.8.4
403
-
404
- - Fixed many issues with save being broken (it didn't properly save the name of the last label the player was on, effectively restarting the game from scratch every time)
405
- - Added new things to the save function so their state gets reloaded properly on game launch:
406
- - Current music now gets saved and restarts when reloading the game, if any is active
407
- - Stats (the ones in the HUD) now get saved
408
- - Current screen is also saved
409
- - Removed many useless spammy `console.log` and added a `Logger` in the code so that most logs (outside of errors/important logs) will only appear in debug mode.
410
-
411
- ## 0.8.3
412
-
413
- - Fixed bug where menu button would move up as more text gets added to the game
414
-
415
- ## 0.8.2
416
-
417
- - Added css to hide scrollbars in the game UI
418
- - Added a new Menu button with the options to quit and change volume
419
- - Removed volume slider from the HUD and moved it to the new menu
420
-
421
- ## 0.8.1
422
-
423
- - Fixed a bug in accessing values inside conditions caused by changed in 0.7.2
424
-
425
- ## 0.8.0
426
-
427
- - Changed the `set` method to access things without caps (`data`, `skills`, `buttons` instead of `DATA`, `SKILLS`, `BUTTONS`) for consistency.
428
- - Changed string interpolation to have more accessible objects, now values in `data` need to be accessed with `%{data.something}` instead of just `%{something}`
429
- - Now possible to access skill levels in string interpolation with `%{skills.someSkill.level}`
430
- - Improvements to how skill checks are printed to be less awkward
431
-
432
- ## 0.7.1
433
-
434
- - Added `stop` and `pause` functions which work similarly to play for stopping or pausing audio.
435
-
436
- ## 0.6.5
437
-
438
- - Audio and music options from the config now get passed to howler
439
- - Renamed `path` to `src` in audio config (to be consistent with howler)
440
-
441
- ## 0.6.0
442
-
443
- Added stats feature for tracking numbers and displaying them in the hud
444
-
445
- Example config:
446
-
447
- ```
448
- "hudStats": {
449
- "money": {
450
- "icon": "img/ui/money.png",
451
- "name": "Money",
452
- "startingValue": 0,
453
- "minValue": 0
454
- },
455
- "energy": {
456
- "icon": "img/ui/energy.png",
457
- "name": "Energy",
458
- "startingValue": 10,
459
- "minValue": 0,
460
- "maxValue": 10
461
- }
462
- }
463
- ```
464
-
465
- ## 0.5.4
466
-
467
- - Improved responsive layout and fixed some issues in it
468
-
469
- New config keys required in the layout part of the config (to be documented):
470
-
471
- ```
472
- "layout": {
473
- "backgrounds": {
474
- "width": 880,
475
- "height": 720
476
- },
477
- "dialogBottomPadding": 70,
478
- "minTextWidth": 475,
479
- "mobileDialogHeightPercentage": 60,
480
- "verticalLayoutThreshold": 1000,
481
- "portraits": {
482
- "width": 100,
483
- "height": 100
484
- }
485
- },
486
- ```
487
-
488
- ## 0.4.0
489
-
490
- Added responsive layout for mobile and small screens. Still in progress, but functionnal enough to be better than before so I'm releasing it.
491
-
492
- ## 0.3.4
493
-
494
- - Improved string templating to work with deep nesting and also inside choice text
495
-
496
- ## 0.3.3
497
-
498
- - Now detects indentation size and can support any indentation size
499
-
500
- ## 0.3.2
501
-
502
- - Added a new `add_level` function for increasing the level of a skill. Example: `add_level someSkill 1` will increase the player's level in `someSkill` by 1
503
- - Added a new `notify` function for displaying a notification toast that disappears after a few seconds (duration configurable in `config.json`). Example: `notify "Hello, this is a notification"`.
504
-
505
- ## 0.3.1
506
-
507
- Added new config options for controlling how skill rolls are done and the display of their difficulty
508
-
509
- ## 0.3.0
510
-
511
- Breaking changes around renaming data access from scripts
512
-
513
- ### New Add Command
514
-
515
- New `add` command, works the same way as `set` but increments the value based on the existing value, ie. `set SKILLS.someSkill.level 2` will increment `someSkill.level` by 2.
516
-
517
- ### Skills
518
-
519
- - Now possible to set the starting value of a skill (in the config)
520
- - Now possible to edit a skill's value with `set SKILLS.someSkill.level 2` for example
521
- - Skillcheck command renamed to roll (`if this.roll("someSkillCheck", "testSkill", 40);`)
522
-
523
- ### General
524
-
525
- The `set` and `$if` command now refer to data in caps and have access to more data:
526
-
527
- - `set SKILLS.someSkill.level [value]` Sets the value of a skill
528
- - `set DATA.someData [value]` Sets a value in the data object (data is for any game-created variables)
529
- - `$if this.SKILLCHECKS.someSkillCheck.passed` now available for checking if a skillcheck has already been passed
530
-
531
- ## 0.0.14
532
-
533
- - Added the changelog (manually made for now)
534
-
535
- ## 0.0.13
536
-
537
- - Added debug menu for jumping to labels (currently doesn't support production builds disabling it)
538
- - Added saving and loading of the game (works by storing data, skills, skillchecks etc. When the game is reloaded, it is brought back at the last label visited)
539
- - Fixed a bug where conditional choices would play the wrong result if a choice is removed due to a condition
540
- - Made script loading and compilation happen during the initial loading, so everything is ready to play when pressing start game
541
- - Skill checks now also save and load their data, so a failed check becomes impossible to choose, and a succeeded skill check can be skipped if shown again
package/lib/lib.d.ts DELETED
@@ -1,6 +0,0 @@
1
- /// <reference types="@/types/character-types" />
2
- /// <reference types="@/types/config" />
3
- /// <reference types="@/types/dialog-box-types" />
4
- /// <reference types="@/types/parser" />
5
- /// <reference types="@/types/vuex" />
6
- export declare const lib: {};
@@ -1,14 +0,0 @@
1
- import { ParserContext } from './renpy-parser';
2
- export declare type CommandParserFunction = (ctx: CommandParsingContext) => void;
3
- export declare type ProcessCommandsFunction = (ctx: ParserContext, lines: Parser.Line[], parentLine: Parser.Line | undefined) => Parser.Branch;
4
- export interface CommandParsingContext {
5
- parserContext: ParserContext;
6
- processCommandsFunction: ProcessCommandsFunction;
7
- line: Parser.Line;
8
- command: Partial<Parser.Command>;
9
- lines: Parser.Line[];
10
- currentLine: number;
11
- }
12
- export declare const parserFunctions: {
13
- [key: string]: CommandParserFunction;
14
- };
@@ -1,14 +0,0 @@
1
- import { State } from 'vue';
2
- import { ActionContext } from 'vuex';
3
- export declare function processSkillCheck(ctx: ActionContext<State, State>, skillcheck: Parser.SkillCheckOptions): boolean;
4
- export interface SkillCheckParams {
5
- skill: string;
6
- value: number;
7
- id: string;
8
- success?: string;
9
- failure?: string;
10
- }
11
- export declare function runSkillCheck(ctx: ActionContext<State, State>, params: SkillCheckParams): boolean;
12
- export declare function runConditionCommand(ctx: ActionContext<State, State>, command: Parser.Command): Parser.Branch | undefined;
13
- export declare function writeText(ctx: ActionContext<State, State>, text: string): void;
14
- export declare function runCondition(ctx: ActionContext<State, State>, condition: string): boolean;
@@ -1,9 +0,0 @@
1
- import { ProcessCommandsFunction } from './command-parser-functions';
2
- export declare type ParserErrorHandler = (ctx: ParserContext, line: number, text: string) => void;
3
- export interface ParserContext {
4
- fileName: string;
5
- error: (line: number, text: string) => void;
6
- processCommandsFunction: ProcessCommandsFunction;
7
- indentSize: number;
8
- }
9
- export declare function parseRenpyScript(errorHandler: ParserErrorHandler, code: string, fileName: string): Parser.ParsedScript;
package/lib/store.d.ts DELETED
@@ -1,12 +0,0 @@
1
- import { InjectionKey, State } from 'vue';
2
- import { Store } from 'vuex';
3
- import { DialogKey, MachineStack } from './types/vuex';
4
- import { AppOptions } from '.';
5
- export declare type AddDialogParams = Omit<DialogKey, 'id'>;
6
- export interface SetupStoreResult {
7
- store: Store<State>;
8
- key: InjectionKey<Store<State>>;
9
- }
10
- export declare type AddStackOptions = Partial<MachineStack>;
11
- export declare function setupStore(options: AppOptions): SetupStoreResult;
12
- export declare function useStore(): Store<State>;
@@ -1,2 +0,0 @@
1
- import { CommandPlugin } from './command-plugin';
2
- export declare const addItemPlugin: CommandPlugin;
@@ -1,2 +0,0 @@
1
- import { CommandPlugin } from './command-plugin';
2
- export declare const removeItemPlugin: CommandPlugin;
@@ -1,11 +0,0 @@
1
- import { ActionContext, Commit } from 'vuex';
2
- import { State } from 'vue';
3
- import { DialogChoice } from '@/types/vuex';
4
- import { AddDialogParams } from '@/store';
5
- export declare function runLine(context: ActionContext<State, State>): Promise<void>;
6
- export declare function runCommand(context: ActionContext<State, State>, cmd: Parser.Command, choices?: DialogChoice[]): Promise<any>;
7
- export declare function playerAnswered(context: ActionContext<State, State>, choiceIndex: number): Promise<void>;
8
- export declare function runChoice(context: ActionContext<State, State>, cmd: Parser.Command): Promise<void>;
9
- export declare function textCommand(commit: Commit, dialog: AddDialogParams): Promise<void>;
10
- export declare function nextLine(ctx: ActionContext<State, State>): Promise<any>;
11
- export declare function finishGame({ commit, state }: ActionContext<State, State>): void;