@vylos/core 0.4.4 → 0.4.5
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/README.md +111 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# @vylos/core
|
|
2
|
+
|
|
3
|
+
The engine, types, stores, and components for [Vylos](https://github.com/DevOpsBenjamin/Vylos) — a checkpoint-based visual novel engine built with Vue 3 and TypeScript.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@vylos/core)
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Checkpoint-based execution** — `engine.say()` and `engine.choice()` pause via async/await, rollback via re-execute + fast-forward (like Ren'Py)
|
|
10
|
+
- **Rollback & history** — full forward/back navigation through past dialogue
|
|
11
|
+
- **Save/load with mid-event resume** — checkpoint system preserves exact position
|
|
12
|
+
- **Inventory system** — bag-based `engine.inventory.add/remove/has/count/list/clear`
|
|
13
|
+
- **Location & action managers** — time-of-day backgrounds, linked locations, conditional actions
|
|
14
|
+
- **Drawable events** — clickable characters/objects on screen
|
|
15
|
+
- **i18n** — `string | Record<string, string>` for multi-language support
|
|
16
|
+
- **Plugin system** — DI-based (tsyringe) manager and component overrides
|
|
17
|
+
- **Dev console** — `window.Vylos` for debugging and cheating (state, inventory, engine)
|
|
18
|
+
- **H key** — hide all UI to view artwork (Ren'Py style)
|
|
19
|
+
- **AZERTY/QWERTY auto-detect** — keyboard input adapts automatically
|
|
20
|
+
|
|
21
|
+
## Install
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pnpm add @vylos/core
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Requires Vue 3 and Pinia.
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import {
|
|
33
|
+
createEngine,
|
|
34
|
+
GameShell,
|
|
35
|
+
useEngineStateStore,
|
|
36
|
+
ENGINE_INJECT_KEY,
|
|
37
|
+
type VylosEvent,
|
|
38
|
+
type VylosAPI,
|
|
39
|
+
type VylosGameState,
|
|
40
|
+
} from '@vylos/core';
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Writing events
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
const intro: VylosEvent = {
|
|
47
|
+
id: 'intro',
|
|
48
|
+
conditions: (state) => !state.flags['intro_done'],
|
|
49
|
+
async execute(engine: VylosAPI, state: VylosGameState) {
|
|
50
|
+
await engine.say('Welcome!');
|
|
51
|
+
|
|
52
|
+
const pick = await engine.choice([
|
|
53
|
+
{ text: 'Start', value: 'start' },
|
|
54
|
+
{ text: 'Learn more', value: 'more' },
|
|
55
|
+
]);
|
|
56
|
+
|
|
57
|
+
if (pick === 'more') {
|
|
58
|
+
await engine.say('Events pause at each say() and choice().');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
state.flags['intro_done'] = true;
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Extending types
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
import type { VylosCharacter, VylosGameState } from '@vylos/core';
|
|
70
|
+
|
|
71
|
+
interface Character extends VylosCharacter {
|
|
72
|
+
portrait?: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
interface GameState extends VylosGameState {
|
|
76
|
+
player: Character;
|
|
77
|
+
energy: number;
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Inventory
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
async execute(engine: VylosAPI, state: GameState) {
|
|
85
|
+
engine.inventory.add('backpack', 'potion', 3);
|
|
86
|
+
|
|
87
|
+
if (engine.inventory.has('backpack', 'key')) {
|
|
88
|
+
engine.inventory.remove('backpack', 'key', 1);
|
|
89
|
+
await engine.say('You used the key.');
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Key bindings
|
|
95
|
+
|
|
96
|
+
| Key | Action |
|
|
97
|
+
|-----|--------|
|
|
98
|
+
| Space / Enter / E | Advance dialogue |
|
|
99
|
+
| D / Arrow Right | Forward |
|
|
100
|
+
| A / Q / Arrow Left | Back |
|
|
101
|
+
| H | Toggle UI visibility |
|
|
102
|
+
| S | Toggle skip mode |
|
|
103
|
+
| Escape | Pause menu |
|
|
104
|
+
|
|
105
|
+
## Documentation
|
|
106
|
+
|
|
107
|
+
Full docs and examples: [github.com/DevOpsBenjamin/Vylos](https://github.com/DevOpsBenjamin/Vylos)
|
|
108
|
+
|
|
109
|
+
## License
|
|
110
|
+
|
|
111
|
+
[MIT](https://github.com/DevOpsBenjamin/Vylos/blob/main/LICENSE)
|