add scoped vars and fix hiding (scope->local->global)
This commit is contained in:
parent
0506451ee6
commit
d61fbc3992
|
@ -6,6 +6,7 @@ import { searchCharByName, getTagsList, tags } from "../tags.js";
|
|||
import { SlashCommandClosure } from "./SlashCommandClosure.js";
|
||||
import { SlashCommandEnumValue, enumTypes } from "./SlashCommandEnumValue.js";
|
||||
import { SlashCommandExecutor } from "./SlashCommandExecutor.js";
|
||||
import { SlashCommandScope } from "./SlashCommandScope.js";
|
||||
|
||||
/**
|
||||
* A collection of regularly used enum icons
|
||||
|
@ -134,16 +135,16 @@ export const commonEnumProviders = {
|
|||
* Can be filtered by `type` to only show global or local variables
|
||||
*
|
||||
* @param {...('global'|'local'|'scope'|'all')} type - The type of variables to include in the array. Can be 'all', 'global', or 'local'.
|
||||
* @returns {() => SlashCommandEnumValue[]}
|
||||
* @returns {(executor:SlashCommandExecutor, scope:SlashCommandScope) => SlashCommandEnumValue[]}
|
||||
*/
|
||||
variables: (...type) => () => {
|
||||
variables: (...type) => (executor, scope) => {
|
||||
const types = type.flat();
|
||||
const isAll = types.includes('all');
|
||||
return [
|
||||
...isAll || types.includes('global') ? Object.keys(extension_settings.variables.global ?? []).map(name => new SlashCommandEnumValue(name, null, enumTypes.macro, enumIcons.globalVariable)) : [],
|
||||
...isAll || types.includes('scope') ? scope.allVariableNames.map(name => new SlashCommandEnumValue(name, null, enumTypes.variable, enumIcons.scopeVariable)) : [],
|
||||
...isAll || types.includes('local') ? Object.keys(chat_metadata.variables ?? []).map(name => new SlashCommandEnumValue(name, null, enumTypes.name, enumIcons.localVariable)) : [],
|
||||
...isAll || types.includes('scope') ? [].map(name => new SlashCommandEnumValue(name, null, enumTypes.variable, enumIcons.scopeVariable)) : [], // TODO: Add scoped variables here, Lenny
|
||||
];
|
||||
...isAll || types.includes('global') ? Object.keys(extension_settings.variables.global ?? []).map(name => new SlashCommandEnumValue(name, null, enumTypes.macro, enumIcons.globalVariable)) : [],
|
||||
].filter((item, idx, list)=>idx == list.findIndex(it=>it.value == item.value));
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue