| 72 | * @returns {void} |
| 73 | */ |
| 74 | export function next (engine: VisualNovelEngine): Promise<void> { |
| 75 | // Advance 1 step |
| 76 | const currentStep = engine.state ('step'); |
| 77 | |
| 78 | engine.state ({ step: currentStep + 1 }); |
| 79 | |
| 80 | const label = engine.label (); |
| 81 | const step = engine.state ('step'); |
| 82 | |
| 83 | return new Promise<void> ((resolve) => { |
| 84 | // Clear the Stack using a Time Out instead of calling the function |
| 85 | // directly, preventing an Overflow |
| 86 | setTimeout (() => { |
| 87 | engine.run (label[step]).then (() => { |
| 88 | engine.global ('_engine_block', false); |
| 89 | resolve (); |
| 90 | }).catch (() => { |
| 91 | resolve (); |
| 92 | }); |
| 93 | }, 0); |
| 94 | }); |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * @static revert - Revert to the previous statement on the script |