feat(aiscript): Better env vars

This commit is contained in:
syuilo 2020-04-19 16:28:19 +09:00
parent 3e128d67a1
commit d61d46e1c4

View file

@ -3,8 +3,9 @@ import { utils, values } from '@syuilo/aiscript';
export function createAiScriptEnv(vm, opts) { export function createAiScriptEnv(vm, opts) {
let apiRequests = 0; let apiRequests = 0;
return { return {
USER_ID: values.STR(vm.$store.state.i.id), USER_ID: vm.$store.getters.isSignedIn ? values.STR(vm.$store.state.i.id) : values.NULL,
USER_USERNAME: values.STR(vm.$store.state.i.username), USER_NAME: vm.$store.getters.isSignedIn ? values.STR(vm.$store.state.i.name) : values.NULL,
USER_USERNAME: vm.$store.getters.isSignedIn ? values.STR(vm.$store.state.i.username) : values.NULL,
'Mk:dialog': values.FN_NATIVE(async ([title, text, type]) => { 'Mk:dialog': values.FN_NATIVE(async ([title, text, type]) => {
await vm.$root.dialog({ await vm.$root.dialog({
type: type ? type.value : 'info', type: type ? type.value : 'info',