narrat 0.7.0 → 0.8.1
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 +15 -0
- package/lib/index.esm.js +114 -34
- package/lib/index.js +114 -34
- package/lib/renpy/renpy-helpers.d.ts +2 -0
- package/lib/utils/audio-loader.d.ts +2 -0
- package/lib/utils/data-helpers.d.ts +3 -3
- package/lib/vm/renpy-vm.d.ts +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Narrat changelog
|
|
2
2
|
|
|
3
|
+
## 0.8.1
|
|
4
|
+
|
|
5
|
+
- Fixed a bug in accessing values inside conditions caused by changed in 0.7.2
|
|
6
|
+
|
|
7
|
+
## 0.8.0
|
|
8
|
+
|
|
9
|
+
- Changed the `set` method to access things without caps (`data`, `skills`, `buttons` instead of `DATA`, `SKILLS`, `BUTTONS`) for consistency.
|
|
10
|
+
- Changed string interpolation to have more accessible objects, now values in `data` need to be accessed with `%{data.something}` instead of just `%{something}`
|
|
11
|
+
- Now possible to access skill levels in string interpolation with `%{skills.someSkill.level}`
|
|
12
|
+
- Improvements to how skill checks are printed to be less awkward
|
|
13
|
+
|
|
14
|
+
## 0.7.1
|
|
15
|
+
|
|
16
|
+
- Added `stop` and `pause` functions which work similarly to play for stopping or pausing audio.
|
|
17
|
+
|
|
3
18
|
## 0.6.5
|
|
4
19
|
|
|
5
20
|
- Audio and music options from the config now get passed to howler
|
package/lib/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Version: 0.
|
|
1
|
+
// Version: 0.8.1 - April 26, 2022 13:28:12
|
|
2
2
|
import 'es6-promise/auto';
|
|
3
3
|
import { ref, reactive, readonly, defineComponent, openBlock, createElementBlock, normalizeStyle, createElementVNode, createCommentVNode, Fragment, renderList, createBlock, Transition, withCtx, renderSlot, createTextVNode, resolveComponent, toDisplayString, createVNode, TransitionGroup, createApp } from 'vue';
|
|
4
4
|
import { createLogger, createStore } from 'vuex';
|
|
@@ -4079,16 +4079,20 @@ function addDataHelper(sourceObj, path, value) {
|
|
|
4079
4079
|
}
|
|
4080
4080
|
function getModifiableData(state) {
|
|
4081
4081
|
return {
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4082
|
+
data: state.machine.data,
|
|
4083
|
+
skills: state.skills,
|
|
4084
|
+
buttons: state.buttons,
|
|
4085
4085
|
};
|
|
4086
4086
|
}
|
|
4087
4087
|
|
|
4088
4088
|
function processText(store, text) {
|
|
4089
4089
|
return text.replace(/%{[^}]*}/g, (match) => {
|
|
4090
4090
|
const key = match.substr(2, match.length - 3);
|
|
4091
|
-
const
|
|
4091
|
+
const searchableState = {
|
|
4092
|
+
data: store.state.machine.data,
|
|
4093
|
+
skills: store.state.skills,
|
|
4094
|
+
};
|
|
4095
|
+
const [obj, newKey] = findDataHelper(searchableState, key);
|
|
4092
4096
|
return obj[newKey];
|
|
4093
4097
|
});
|
|
4094
4098
|
}
|
|
@@ -4197,8 +4201,12 @@ async function loadAudio(key, config) {
|
|
|
4197
4201
|
function changeMusic(ctx, newMusic) {
|
|
4198
4202
|
if (ctx.state.audio.currentMusic) {
|
|
4199
4203
|
const oldMusic = getAudio(ctx.state.audio.currentMusic);
|
|
4204
|
+
const newMusicHowl = getAudio(newMusic);
|
|
4200
4205
|
if (oldMusic) {
|
|
4201
|
-
oldMusic
|
|
4206
|
+
if (oldMusic !== newMusicHowl) {
|
|
4207
|
+
// Stop the previous music if it's a different one
|
|
4208
|
+
oldMusic.stop();
|
|
4209
|
+
}
|
|
4202
4210
|
}
|
|
4203
4211
|
}
|
|
4204
4212
|
ctx.commit('setMusic', newMusic);
|
|
@@ -4217,6 +4225,24 @@ function playAudio(commit, key) {
|
|
|
4217
4225
|
}
|
|
4218
4226
|
function getAudio(key) {
|
|
4219
4227
|
return audio[key];
|
|
4228
|
+
}
|
|
4229
|
+
function stopAudio(commit, key) {
|
|
4230
|
+
const sound = getAudio(key);
|
|
4231
|
+
if (sound) {
|
|
4232
|
+
sound.stop();
|
|
4233
|
+
}
|
|
4234
|
+
else {
|
|
4235
|
+
error(commit, `Sound effect ${key} not found!`);
|
|
4236
|
+
}
|
|
4237
|
+
}
|
|
4238
|
+
function pauseAudio(commit, key) {
|
|
4239
|
+
const sound = getAudio(key);
|
|
4240
|
+
if (sound) {
|
|
4241
|
+
sound.pause();
|
|
4242
|
+
}
|
|
4243
|
+
else {
|
|
4244
|
+
error(commit, `Sound effect ${key} not found!`);
|
|
4245
|
+
}
|
|
4220
4246
|
}
|
|
4221
4247
|
|
|
4222
4248
|
function debounce(func, waitMilliseconds = 50, options = {}) {
|
|
@@ -4694,6 +4720,8 @@ function processSkillCheck(ctx, skillcheck) {
|
|
|
4694
4720
|
skill: skillcheck.skill,
|
|
4695
4721
|
value: skillcheck.value,
|
|
4696
4722
|
id: skillcheck.id,
|
|
4723
|
+
success: skillcheck.success.text,
|
|
4724
|
+
failure: skillcheck.failure.text,
|
|
4697
4725
|
});
|
|
4698
4726
|
}
|
|
4699
4727
|
function runSkillCheck(ctx, params) {
|
|
@@ -4712,11 +4740,11 @@ function runSkillCheck(ctx, params) {
|
|
|
4712
4740
|
}
|
|
4713
4741
|
if (success) {
|
|
4714
4742
|
ctx.commit('passSkillCheck', params.id);
|
|
4715
|
-
writeText(ctx, `[${skill.name} - Success]`);
|
|
4743
|
+
writeText(ctx, `[${skill.name} - Success] ${params.success || ''}`);
|
|
4716
4744
|
return true;
|
|
4717
4745
|
}
|
|
4718
4746
|
ctx.commit('failSkillCheck', params.id);
|
|
4719
|
-
writeText(ctx, `[${skill.name} - Failure]`);
|
|
4747
|
+
writeText(ctx, `[${skill.name} - Failure] ${params.failure || ''}`);
|
|
4720
4748
|
return false;
|
|
4721
4749
|
}
|
|
4722
4750
|
function runConditionCommand(ctx, command) {
|
|
@@ -4747,10 +4775,10 @@ function runCondition(ctx, condition) {
|
|
|
4747
4775
|
function conditionFunction(ctx, condition) {
|
|
4748
4776
|
const { state } = ctx;
|
|
4749
4777
|
const context = {
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4778
|
+
data: state.machine.data,
|
|
4779
|
+
skills: state.skills,
|
|
4780
|
+
skillChecks: state.skillChecks,
|
|
4781
|
+
stats: state.hudStats,
|
|
4754
4782
|
roll: (checkId, skill, value) => {
|
|
4755
4783
|
const skillCheckState = getSkillCheckState(ctx, checkId);
|
|
4756
4784
|
if (skillCheckState) {
|
|
@@ -4850,12 +4878,36 @@ async function runCommand(context, cmd, choices) {
|
|
|
4850
4878
|
});
|
|
4851
4879
|
return dispatch('nextLine');
|
|
4852
4880
|
case 'play':
|
|
4853
|
-
const
|
|
4854
|
-
if (
|
|
4855
|
-
changeMusic(context,
|
|
4881
|
+
const playOptions = cmd.options;
|
|
4882
|
+
if (playOptions.mode === 'music') {
|
|
4883
|
+
changeMusic(context, playOptions.audio);
|
|
4884
|
+
}
|
|
4885
|
+
else {
|
|
4886
|
+
playAudio(context.commit, playOptions.audio);
|
|
4887
|
+
}
|
|
4888
|
+
return dispatch('nextLine');
|
|
4889
|
+
case 'stop':
|
|
4890
|
+
const stopOptions = cmd.options;
|
|
4891
|
+
if (stopOptions.mode === 'music') {
|
|
4892
|
+
stopAudio(commit, context.state.audio.currentMusic);
|
|
4893
|
+
}
|
|
4894
|
+
else if (stopOptions.mode === 'sound' && stopOptions.audio) {
|
|
4895
|
+
stopAudio(commit, stopOptions.audio);
|
|
4856
4896
|
}
|
|
4857
4897
|
else {
|
|
4858
|
-
|
|
4898
|
+
error(commit, `stop option needs to either be in music mode, or if stopping a sound needs to have the sound name supplied as second argument.`);
|
|
4899
|
+
}
|
|
4900
|
+
return dispatch('nextLine');
|
|
4901
|
+
case 'pause':
|
|
4902
|
+
const pauseOptions = cmd.options;
|
|
4903
|
+
if (pauseOptions.mode === 'music') {
|
|
4904
|
+
pauseAudio(commit, context.state.audio.currentMusic);
|
|
4905
|
+
}
|
|
4906
|
+
else if (stopOptions.mode === 'sound' && stopOptions.audio) {
|
|
4907
|
+
pauseAudio(commit, stopOptions.audio);
|
|
4908
|
+
}
|
|
4909
|
+
else {
|
|
4910
|
+
error(commit, `pause first option needs to either be in music mode, or if stopping a sound needs to have the sound name supplied as second argument.`);
|
|
4859
4911
|
}
|
|
4860
4912
|
return dispatch('nextLine');
|
|
4861
4913
|
case 'wait':
|
|
@@ -4907,6 +4959,7 @@ async function runCommand(context, cmd, choices) {
|
|
|
4907
4959
|
}
|
|
4908
4960
|
catch (err) {
|
|
4909
4961
|
console.log(state.machine.stack[state.machine.stack.length - 1].label);
|
|
4962
|
+
console.error(err);
|
|
4910
4963
|
error(commit, `Narrat script runtime error at <span class="error-filename">${cmd.fileName}:${cmd.line + 1}</span>
|
|
4911
4964
|
<b>${err}</b>
|
|
4912
4965
|
Script: ${cmd.code}
|
|
@@ -4933,18 +4986,21 @@ async function playerAnswered(context, choiceIndex) {
|
|
|
4933
4986
|
const result = processSkillCheck(context, skillcheck);
|
|
4934
4987
|
const winner = result ? skillcheck.success : skillcheck.failure;
|
|
4935
4988
|
newBranch = winner.branch;
|
|
4936
|
-
playerText =
|
|
4989
|
+
playerText = undefined;
|
|
4937
4990
|
}
|
|
4938
4991
|
}
|
|
4939
4992
|
else {
|
|
4940
4993
|
newBranch = choice.branch;
|
|
4941
4994
|
}
|
|
4942
|
-
|
|
4943
|
-
|
|
4944
|
-
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
|
|
4995
|
+
if (playerText) {
|
|
4996
|
+
// If the choice involves printing a player dialog, show it
|
|
4997
|
+
const dialog = {
|
|
4998
|
+
speaker: 'player',
|
|
4999
|
+
text: playerText,
|
|
5000
|
+
interactive: false,
|
|
5001
|
+
};
|
|
5002
|
+
commit('addDialog', { dialog });
|
|
5003
|
+
}
|
|
4948
5004
|
if (newBranch) {
|
|
4949
5005
|
const newStack = {
|
|
4950
5006
|
currentIndex: 0,
|
|
@@ -5022,9 +5078,10 @@ async function textCommand(commit, dialog) {
|
|
|
5022
5078
|
dialog,
|
|
5023
5079
|
});
|
|
5024
5080
|
}
|
|
5025
|
-
async function nextLine(
|
|
5081
|
+
async function nextLine(ctx) {
|
|
5082
|
+
const { state, getters, dispatch, commit } = ctx;
|
|
5026
5083
|
if (state.machine.stack.length === 0) {
|
|
5027
|
-
finishGame(
|
|
5084
|
+
finishGame(ctx);
|
|
5028
5085
|
return;
|
|
5029
5086
|
}
|
|
5030
5087
|
const machineHead = getters.machineHead;
|
|
@@ -5037,19 +5094,21 @@ async function nextLine({ state, getters, dispatch, commit, }) {
|
|
|
5037
5094
|
return dispatch('nextLine');
|
|
5038
5095
|
}
|
|
5039
5096
|
if (state.machine.stack.length === 0) {
|
|
5040
|
-
finishGame(
|
|
5097
|
+
finishGame(ctx);
|
|
5041
5098
|
}
|
|
5042
5099
|
else {
|
|
5043
5100
|
return dispatch('runLine');
|
|
5044
5101
|
}
|
|
5045
5102
|
}
|
|
5046
|
-
function finishGame(commit) {
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5103
|
+
function finishGame({ commit, state }) {
|
|
5104
|
+
if (state.options.debug) {
|
|
5105
|
+
commit('addDialog', {
|
|
5106
|
+
dialog: {
|
|
5107
|
+
speaker: 'game',
|
|
5108
|
+
text: '[DEBUG] Game Script is finished. This is the end of the game flow. This message only appears in debug mode.',
|
|
5109
|
+
},
|
|
5110
|
+
});
|
|
5111
|
+
}
|
|
5053
5112
|
}
|
|
5054
5113
|
|
|
5055
5114
|
function jump(ctx) {
|
|
@@ -5151,6 +5210,24 @@ function play(ctx) {
|
|
|
5151
5210
|
};
|
|
5152
5211
|
ctx.currentLine++;
|
|
5153
5212
|
}
|
|
5213
|
+
function stop(ctx) {
|
|
5214
|
+
const { command } = ctx;
|
|
5215
|
+
command.commandType = 'stop';
|
|
5216
|
+
command.options = {
|
|
5217
|
+
mode: command.args[0],
|
|
5218
|
+
audio: command.args[1],
|
|
5219
|
+
};
|
|
5220
|
+
ctx.currentLine++;
|
|
5221
|
+
}
|
|
5222
|
+
function pause(ctx) {
|
|
5223
|
+
const { command } = ctx;
|
|
5224
|
+
command.commandType = 'pause';
|
|
5225
|
+
command.options = {
|
|
5226
|
+
mode: command.args[0],
|
|
5227
|
+
audio: command.args[1],
|
|
5228
|
+
};
|
|
5229
|
+
ctx.currentLine++;
|
|
5230
|
+
}
|
|
5154
5231
|
function wait(ctx) {
|
|
5155
5232
|
const { command } = ctx;
|
|
5156
5233
|
command.commandType = 'wait';
|
|
@@ -5182,6 +5259,8 @@ const parserFunctions = {
|
|
|
5182
5259
|
set_button: setButton,
|
|
5183
5260
|
clear_dialog: clearDialog,
|
|
5184
5261
|
play,
|
|
5262
|
+
stop,
|
|
5263
|
+
pause,
|
|
5185
5264
|
wait,
|
|
5186
5265
|
text,
|
|
5187
5266
|
add_level,
|
|
@@ -5478,6 +5557,7 @@ function setupStore(options) {
|
|
|
5478
5557
|
},
|
|
5479
5558
|
notifications: {},
|
|
5480
5559
|
hudStats: {},
|
|
5560
|
+
options,
|
|
5481
5561
|
},
|
|
5482
5562
|
getters: {
|
|
5483
5563
|
machineHead(state) {
|
|
@@ -5732,7 +5812,7 @@ async function startApp(config, options) {
|
|
|
5732
5812
|
mousePos.x = e.clientX;
|
|
5733
5813
|
mousePos.y = e.clientY;
|
|
5734
5814
|
});
|
|
5735
|
-
console.log('%c Narrat game engine – 0.
|
|
5815
|
+
console.log('%c Narrat game engine – 0.8.1 - April 26, 2022 13:28:12', 'background: #222; color: #bada55');
|
|
5736
5816
|
const storeSetup = setupStore(options);
|
|
5737
5817
|
store$1 = storeSetup.store;
|
|
5738
5818
|
app = createApp(script$8, {
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Version: 0.
|
|
1
|
+
// Version: 0.8.1 - April 26, 2022 13:28:12
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
@@ -4083,16 +4083,20 @@ function addDataHelper(sourceObj, path, value) {
|
|
|
4083
4083
|
}
|
|
4084
4084
|
function getModifiableData(state) {
|
|
4085
4085
|
return {
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4086
|
+
data: state.machine.data,
|
|
4087
|
+
skills: state.skills,
|
|
4088
|
+
buttons: state.buttons,
|
|
4089
4089
|
};
|
|
4090
4090
|
}
|
|
4091
4091
|
|
|
4092
4092
|
function processText(store, text) {
|
|
4093
4093
|
return text.replace(/%{[^}]*}/g, (match) => {
|
|
4094
4094
|
const key = match.substr(2, match.length - 3);
|
|
4095
|
-
const
|
|
4095
|
+
const searchableState = {
|
|
4096
|
+
data: store.state.machine.data,
|
|
4097
|
+
skills: store.state.skills,
|
|
4098
|
+
};
|
|
4099
|
+
const [obj, newKey] = findDataHelper(searchableState, key);
|
|
4096
4100
|
return obj[newKey];
|
|
4097
4101
|
});
|
|
4098
4102
|
}
|
|
@@ -4201,8 +4205,12 @@ async function loadAudio(key, config) {
|
|
|
4201
4205
|
function changeMusic(ctx, newMusic) {
|
|
4202
4206
|
if (ctx.state.audio.currentMusic) {
|
|
4203
4207
|
const oldMusic = getAudio(ctx.state.audio.currentMusic);
|
|
4208
|
+
const newMusicHowl = getAudio(newMusic);
|
|
4204
4209
|
if (oldMusic) {
|
|
4205
|
-
oldMusic
|
|
4210
|
+
if (oldMusic !== newMusicHowl) {
|
|
4211
|
+
// Stop the previous music if it's a different one
|
|
4212
|
+
oldMusic.stop();
|
|
4213
|
+
}
|
|
4206
4214
|
}
|
|
4207
4215
|
}
|
|
4208
4216
|
ctx.commit('setMusic', newMusic);
|
|
@@ -4221,6 +4229,24 @@ function playAudio(commit, key) {
|
|
|
4221
4229
|
}
|
|
4222
4230
|
function getAudio(key) {
|
|
4223
4231
|
return audio[key];
|
|
4232
|
+
}
|
|
4233
|
+
function stopAudio(commit, key) {
|
|
4234
|
+
const sound = getAudio(key);
|
|
4235
|
+
if (sound) {
|
|
4236
|
+
sound.stop();
|
|
4237
|
+
}
|
|
4238
|
+
else {
|
|
4239
|
+
error(commit, `Sound effect ${key} not found!`);
|
|
4240
|
+
}
|
|
4241
|
+
}
|
|
4242
|
+
function pauseAudio(commit, key) {
|
|
4243
|
+
const sound = getAudio(key);
|
|
4244
|
+
if (sound) {
|
|
4245
|
+
sound.pause();
|
|
4246
|
+
}
|
|
4247
|
+
else {
|
|
4248
|
+
error(commit, `Sound effect ${key} not found!`);
|
|
4249
|
+
}
|
|
4224
4250
|
}
|
|
4225
4251
|
|
|
4226
4252
|
function debounce(func, waitMilliseconds = 50, options = {}) {
|
|
@@ -4698,6 +4724,8 @@ function processSkillCheck(ctx, skillcheck) {
|
|
|
4698
4724
|
skill: skillcheck.skill,
|
|
4699
4725
|
value: skillcheck.value,
|
|
4700
4726
|
id: skillcheck.id,
|
|
4727
|
+
success: skillcheck.success.text,
|
|
4728
|
+
failure: skillcheck.failure.text,
|
|
4701
4729
|
});
|
|
4702
4730
|
}
|
|
4703
4731
|
function runSkillCheck(ctx, params) {
|
|
@@ -4716,11 +4744,11 @@ function runSkillCheck(ctx, params) {
|
|
|
4716
4744
|
}
|
|
4717
4745
|
if (success) {
|
|
4718
4746
|
ctx.commit('passSkillCheck', params.id);
|
|
4719
|
-
writeText(ctx, `[${skill.name} - Success]`);
|
|
4747
|
+
writeText(ctx, `[${skill.name} - Success] ${params.success || ''}`);
|
|
4720
4748
|
return true;
|
|
4721
4749
|
}
|
|
4722
4750
|
ctx.commit('failSkillCheck', params.id);
|
|
4723
|
-
writeText(ctx, `[${skill.name} - Failure]`);
|
|
4751
|
+
writeText(ctx, `[${skill.name} - Failure] ${params.failure || ''}`);
|
|
4724
4752
|
return false;
|
|
4725
4753
|
}
|
|
4726
4754
|
function runConditionCommand(ctx, command) {
|
|
@@ -4751,10 +4779,10 @@ function runCondition(ctx, condition) {
|
|
|
4751
4779
|
function conditionFunction(ctx, condition) {
|
|
4752
4780
|
const { state } = ctx;
|
|
4753
4781
|
const context = {
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4782
|
+
data: state.machine.data,
|
|
4783
|
+
skills: state.skills,
|
|
4784
|
+
skillChecks: state.skillChecks,
|
|
4785
|
+
stats: state.hudStats,
|
|
4758
4786
|
roll: (checkId, skill, value) => {
|
|
4759
4787
|
const skillCheckState = getSkillCheckState(ctx, checkId);
|
|
4760
4788
|
if (skillCheckState) {
|
|
@@ -4854,12 +4882,36 @@ async function runCommand(context, cmd, choices) {
|
|
|
4854
4882
|
});
|
|
4855
4883
|
return dispatch('nextLine');
|
|
4856
4884
|
case 'play':
|
|
4857
|
-
const
|
|
4858
|
-
if (
|
|
4859
|
-
changeMusic(context,
|
|
4885
|
+
const playOptions = cmd.options;
|
|
4886
|
+
if (playOptions.mode === 'music') {
|
|
4887
|
+
changeMusic(context, playOptions.audio);
|
|
4888
|
+
}
|
|
4889
|
+
else {
|
|
4890
|
+
playAudio(context.commit, playOptions.audio);
|
|
4891
|
+
}
|
|
4892
|
+
return dispatch('nextLine');
|
|
4893
|
+
case 'stop':
|
|
4894
|
+
const stopOptions = cmd.options;
|
|
4895
|
+
if (stopOptions.mode === 'music') {
|
|
4896
|
+
stopAudio(commit, context.state.audio.currentMusic);
|
|
4897
|
+
}
|
|
4898
|
+
else if (stopOptions.mode === 'sound' && stopOptions.audio) {
|
|
4899
|
+
stopAudio(commit, stopOptions.audio);
|
|
4860
4900
|
}
|
|
4861
4901
|
else {
|
|
4862
|
-
|
|
4902
|
+
error(commit, `stop option needs to either be in music mode, or if stopping a sound needs to have the sound name supplied as second argument.`);
|
|
4903
|
+
}
|
|
4904
|
+
return dispatch('nextLine');
|
|
4905
|
+
case 'pause':
|
|
4906
|
+
const pauseOptions = cmd.options;
|
|
4907
|
+
if (pauseOptions.mode === 'music') {
|
|
4908
|
+
pauseAudio(commit, context.state.audio.currentMusic);
|
|
4909
|
+
}
|
|
4910
|
+
else if (stopOptions.mode === 'sound' && stopOptions.audio) {
|
|
4911
|
+
pauseAudio(commit, stopOptions.audio);
|
|
4912
|
+
}
|
|
4913
|
+
else {
|
|
4914
|
+
error(commit, `pause first option needs to either be in music mode, or if stopping a sound needs to have the sound name supplied as second argument.`);
|
|
4863
4915
|
}
|
|
4864
4916
|
return dispatch('nextLine');
|
|
4865
4917
|
case 'wait':
|
|
@@ -4911,6 +4963,7 @@ async function runCommand(context, cmd, choices) {
|
|
|
4911
4963
|
}
|
|
4912
4964
|
catch (err) {
|
|
4913
4965
|
console.log(state.machine.stack[state.machine.stack.length - 1].label);
|
|
4966
|
+
console.error(err);
|
|
4914
4967
|
error(commit, `Narrat script runtime error at <span class="error-filename">${cmd.fileName}:${cmd.line + 1}</span>
|
|
4915
4968
|
<b>${err}</b>
|
|
4916
4969
|
Script: ${cmd.code}
|
|
@@ -4937,18 +4990,21 @@ async function playerAnswered(context, choiceIndex) {
|
|
|
4937
4990
|
const result = processSkillCheck(context, skillcheck);
|
|
4938
4991
|
const winner = result ? skillcheck.success : skillcheck.failure;
|
|
4939
4992
|
newBranch = winner.branch;
|
|
4940
|
-
playerText =
|
|
4993
|
+
playerText = undefined;
|
|
4941
4994
|
}
|
|
4942
4995
|
}
|
|
4943
4996
|
else {
|
|
4944
4997
|
newBranch = choice.branch;
|
|
4945
4998
|
}
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
|
|
4949
|
-
|
|
4950
|
-
|
|
4951
|
-
|
|
4999
|
+
if (playerText) {
|
|
5000
|
+
// If the choice involves printing a player dialog, show it
|
|
5001
|
+
const dialog = {
|
|
5002
|
+
speaker: 'player',
|
|
5003
|
+
text: playerText,
|
|
5004
|
+
interactive: false,
|
|
5005
|
+
};
|
|
5006
|
+
commit('addDialog', { dialog });
|
|
5007
|
+
}
|
|
4952
5008
|
if (newBranch) {
|
|
4953
5009
|
const newStack = {
|
|
4954
5010
|
currentIndex: 0,
|
|
@@ -5026,9 +5082,10 @@ async function textCommand(commit, dialog) {
|
|
|
5026
5082
|
dialog,
|
|
5027
5083
|
});
|
|
5028
5084
|
}
|
|
5029
|
-
async function nextLine(
|
|
5085
|
+
async function nextLine(ctx) {
|
|
5086
|
+
const { state, getters, dispatch, commit } = ctx;
|
|
5030
5087
|
if (state.machine.stack.length === 0) {
|
|
5031
|
-
finishGame(
|
|
5088
|
+
finishGame(ctx);
|
|
5032
5089
|
return;
|
|
5033
5090
|
}
|
|
5034
5091
|
const machineHead = getters.machineHead;
|
|
@@ -5041,19 +5098,21 @@ async function nextLine({ state, getters, dispatch, commit, }) {
|
|
|
5041
5098
|
return dispatch('nextLine');
|
|
5042
5099
|
}
|
|
5043
5100
|
if (state.machine.stack.length === 0) {
|
|
5044
|
-
finishGame(
|
|
5101
|
+
finishGame(ctx);
|
|
5045
5102
|
}
|
|
5046
5103
|
else {
|
|
5047
5104
|
return dispatch('runLine');
|
|
5048
5105
|
}
|
|
5049
5106
|
}
|
|
5050
|
-
function finishGame(commit) {
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5107
|
+
function finishGame({ commit, state }) {
|
|
5108
|
+
if (state.options.debug) {
|
|
5109
|
+
commit('addDialog', {
|
|
5110
|
+
dialog: {
|
|
5111
|
+
speaker: 'game',
|
|
5112
|
+
text: '[DEBUG] Game Script is finished. This is the end of the game flow. This message only appears in debug mode.',
|
|
5113
|
+
},
|
|
5114
|
+
});
|
|
5115
|
+
}
|
|
5057
5116
|
}
|
|
5058
5117
|
|
|
5059
5118
|
function jump(ctx) {
|
|
@@ -5155,6 +5214,24 @@ function play(ctx) {
|
|
|
5155
5214
|
};
|
|
5156
5215
|
ctx.currentLine++;
|
|
5157
5216
|
}
|
|
5217
|
+
function stop(ctx) {
|
|
5218
|
+
const { command } = ctx;
|
|
5219
|
+
command.commandType = 'stop';
|
|
5220
|
+
command.options = {
|
|
5221
|
+
mode: command.args[0],
|
|
5222
|
+
audio: command.args[1],
|
|
5223
|
+
};
|
|
5224
|
+
ctx.currentLine++;
|
|
5225
|
+
}
|
|
5226
|
+
function pause(ctx) {
|
|
5227
|
+
const { command } = ctx;
|
|
5228
|
+
command.commandType = 'pause';
|
|
5229
|
+
command.options = {
|
|
5230
|
+
mode: command.args[0],
|
|
5231
|
+
audio: command.args[1],
|
|
5232
|
+
};
|
|
5233
|
+
ctx.currentLine++;
|
|
5234
|
+
}
|
|
5158
5235
|
function wait(ctx) {
|
|
5159
5236
|
const { command } = ctx;
|
|
5160
5237
|
command.commandType = 'wait';
|
|
@@ -5186,6 +5263,8 @@ const parserFunctions = {
|
|
|
5186
5263
|
set_button: setButton,
|
|
5187
5264
|
clear_dialog: clearDialog,
|
|
5188
5265
|
play,
|
|
5266
|
+
stop,
|
|
5267
|
+
pause,
|
|
5189
5268
|
wait,
|
|
5190
5269
|
text,
|
|
5191
5270
|
add_level,
|
|
@@ -5482,6 +5561,7 @@ function setupStore(options) {
|
|
|
5482
5561
|
},
|
|
5483
5562
|
notifications: {},
|
|
5484
5563
|
hudStats: {},
|
|
5564
|
+
options,
|
|
5485
5565
|
},
|
|
5486
5566
|
getters: {
|
|
5487
5567
|
machineHead(state) {
|
|
@@ -5736,7 +5816,7 @@ async function startApp(config, options) {
|
|
|
5736
5816
|
mousePos.x = e.clientX;
|
|
5737
5817
|
mousePos.y = e.clientY;
|
|
5738
5818
|
});
|
|
5739
|
-
console.log('%c Narrat game engine – 0.
|
|
5819
|
+
console.log('%c Narrat game engine – 0.8.1 - April 26, 2022 13:28:12', 'background: #222; color: #bada55');
|
|
5740
5820
|
const storeSetup = setupStore(options);
|
|
5741
5821
|
store$1 = storeSetup.store;
|
|
5742
5822
|
app = vue.createApp(script$8, {
|
|
@@ -5,6 +5,8 @@ export interface SkillCheckParams {
|
|
|
5
5
|
skill: string;
|
|
6
6
|
value: number;
|
|
7
7
|
id: string;
|
|
8
|
+
success?: string;
|
|
9
|
+
failure?: string;
|
|
8
10
|
}
|
|
9
11
|
export declare function runSkillCheck(ctx: ActionContext<State, State>, params: SkillCheckParams): boolean;
|
|
10
12
|
export declare function runConditionCommand(ctx: ActionContext<State, State>, command: Parser.Command): Parser.Branch | undefined;
|
|
@@ -10,3 +10,5 @@ export declare function loadAudio(key: string, config: AudioConfig | MusicConfig
|
|
|
10
10
|
export declare function changeMusic(ctx: ActionContext<State, State>, newMusic: string): void;
|
|
11
11
|
export declare function playAudio(commit: Commit, key: string): void;
|
|
12
12
|
export declare function getAudio(key: string): Howl | undefined;
|
|
13
|
+
export declare function stopAudio(commit: Commit, key: string): void;
|
|
14
|
+
export declare function pauseAudio(commit: Commit, key: string): void;
|
|
@@ -3,7 +3,7 @@ export declare function findDataHelper<T>(sourceObj: any, path: string): [T, str
|
|
|
3
3
|
export declare function setDataHelper<T>(sourceObj: any, path: string, value: T): void;
|
|
4
4
|
export declare function addDataHelper<T>(sourceObj: any, path: string, value: T): void;
|
|
5
5
|
export declare function getModifiableData(state: State): {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
data: import("../types/vuex").DataState;
|
|
7
|
+
skills: import("../types/vuex").SkillsState;
|
|
8
|
+
buttons: import("vue").ButtonsState;
|
|
9
9
|
};
|
package/lib/vm/renpy-vm.d.ts
CHANGED
|
@@ -6,5 +6,5 @@ export declare function runCommand(context: ActionContext<State, State>, cmd: Pa
|
|
|
6
6
|
export declare function playerAnswered(context: ActionContext<State, State>, choiceIndex: number): Promise<void>;
|
|
7
7
|
export declare function runChoice(context: ActionContext<State, State>, cmd: Parser.Command): Promise<void>;
|
|
8
8
|
export declare function textCommand(commit: Commit, dialog: DialogKey): Promise<void>;
|
|
9
|
-
export declare function nextLine(
|
|
10
|
-
export declare function finishGame(commit:
|
|
9
|
+
export declare function nextLine(ctx: ActionContext<State, State>): Promise<any>;
|
|
10
|
+
export declare function finishGame({ commit, state }: ActionContext<State, State>): void;
|