fix: Respect module lowLevelAccess for Lua button triggers (#866)
# PR Checklist - [ ] Have you checked if it works normally in all models? *Ignore this if it doesn't use models.* - [x] Have you checked if it works normally in all web, local, and node hosted versions? If it doesn't, have you blocked it in those versions? - [x] Have you added type definitions? # Description For Lua scripts triggered by button clicks, `lowLevelAccess` flag is not respecting module level settings, only character's. This PR allows modules with low level access set run low level functions in `onButtonClick`.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { getChatVar, hasher, setChatVar, getGlobalChatVar, type simpleCharacterArgument, risuChatParser } from "../parser.svelte";
|
import { getChatVar, hasher, setChatVar, getGlobalChatVar, type simpleCharacterArgument, risuChatParser } from "../parser.svelte";
|
||||||
import { LuaEngine, LuaFactory } from "wasmoon";
|
import { LuaEngine, LuaFactory } from "wasmoon";
|
||||||
import { getCurrentCharacter, getCurrentChat, getDatabase, setDatabase, type Chat, type character, type groupChat, type loreBook } from "../storage/database.svelte";
|
import { getCurrentCharacter, getCurrentChat, getDatabase, setDatabase, type Chat, type character, type groupChat, type triggerscript } from "../storage/database.svelte";
|
||||||
import { get } from "svelte/store";
|
import { get } from "svelte/store";
|
||||||
import { ReloadGUIPointer, selectedCharID } from "../stores.svelte";
|
import { ReloadGUIPointer, selectedCharID } from "../stores.svelte";
|
||||||
import { alertSelect, alertError, alertInput, alertNormal } from "../alert";
|
import { alertSelect, alertError, alertInput, alertNormal } from "../alert";
|
||||||
@@ -948,13 +948,16 @@ export async function runLuaEditTrigger<T extends any>(char:character|groupChat|
|
|||||||
export async function runLuaButtonTrigger(char:character|groupChat|simpleCharacterArgument, data:string):Promise<any>{
|
export async function runLuaButtonTrigger(char:character|groupChat|simpleCharacterArgument, data:string):Promise<any>{
|
||||||
let runResult
|
let runResult
|
||||||
try {
|
try {
|
||||||
const triggers = char.type === 'group' ? getModuleTriggers() : char.triggerscript.concat(getModuleTriggers())
|
const triggers = char.type === 'group' ? getModuleTriggers() : char.triggerscript.map<triggerscript>((v) => ({
|
||||||
const lowLevelAccess = char.type !== 'simple' ? char.lowLevelAccess ?? false : false
|
...v,
|
||||||
|
lowLevelAccess: char.type !== 'simple' ? char.lowLevelAccess ?? false : false
|
||||||
|
})).concat(getModuleTriggers())
|
||||||
|
|
||||||
for(let trigger of triggers){
|
for(let trigger of triggers){
|
||||||
if(trigger?.effect?.[0]?.type === 'triggerlua'){
|
if(trigger?.effect?.[0]?.type === 'triggerlua'){
|
||||||
runResult = await runLua(trigger.effect[0].code, {
|
runResult = await runLua(trigger.effect[0].code, {
|
||||||
char: char,
|
char: char,
|
||||||
lowLevelAccess: lowLevelAccess,
|
lowLevelAccess: trigger.lowLevelAccess,
|
||||||
mode: 'onButtonClick',
|
mode: 'onButtonClick',
|
||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user