Improve AiScript
This commit is contained in:
@@ -20,13 +20,13 @@ export default Vue.extend({
|
||||
methods: {
|
||||
click() {
|
||||
if (this.value.action === 'dialog') {
|
||||
this.script.reEval();
|
||||
this.script.eval();
|
||||
this.$root.dialog({
|
||||
text: this.script.interpolate(this.value.content)
|
||||
});
|
||||
} else if (this.value.action === 'resetRandom') {
|
||||
this.script.aiScript.updateRandomSeed(Math.random());
|
||||
this.script.reEval();
|
||||
this.script.eval();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ export default Vue.extend({
|
||||
watch: {
|
||||
v() {
|
||||
this.script.aiScript.updatePageVar(this.value.name, this.v);
|
||||
this.script.reEval();
|
||||
this.script.eval();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -26,7 +26,7 @@ export default Vue.extend({
|
||||
watch: {
|
||||
v() {
|
||||
this.script.aiScript.updatePageVar(this.value.name, this.v);
|
||||
this.script.reEval();
|
||||
this.script.eval();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -26,7 +26,7 @@ export default Vue.extend({
|
||||
watch: {
|
||||
v() {
|
||||
this.script.aiScript.updatePageVar(this.value.name, this.v);
|
||||
this.script.reEval();
|
||||
this.script.eval();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -26,7 +26,7 @@ export default Vue.extend({
|
||||
watch: {
|
||||
v() {
|
||||
this.script.aiScript.updatePageVar(this.value.name, this.v);
|
||||
this.script.reEval();
|
||||
this.script.eval();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -27,15 +27,21 @@ import { url } from '../../../../config';
|
||||
|
||||
class Script {
|
||||
public aiScript: AiScript;
|
||||
private onError: any;
|
||||
public vars: Record<string, any>;
|
||||
|
||||
constructor(aiScript) {
|
||||
constructor(aiScript, onError) {
|
||||
this.aiScript = aiScript;
|
||||
this.vars = this.aiScript.evaluateVars();
|
||||
this.onError = onError;
|
||||
this.eval();
|
||||
}
|
||||
|
||||
public reEval() {
|
||||
this.vars = this.aiScript.evaluateVars();
|
||||
public eval() {
|
||||
try {
|
||||
this.vars = this.aiScript.evaluateVars();
|
||||
} catch (e) {
|
||||
this.onError(e);
|
||||
}
|
||||
}
|
||||
|
||||
public interpolate(str: string) {
|
||||
@@ -86,7 +92,9 @@ export default Vue.extend({
|
||||
visitor: this.$store.state.i,
|
||||
page: page,
|
||||
url: url
|
||||
}));
|
||||
}), e => {
|
||||
console.dir(e);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user