From 5e330424f406d6214801838d402e21485cfc392a Mon Sep 17 00:00:00 2001 From: Joseph Kang Date: Sun, 18 May 2025 17:16:22 +0900 Subject: [PATCH] Add getDescription function (was missing) The `getDescription(triggerId)` function, documented at: https://kwaroran.github.io/docs/srp/lua/#getdescriptiontriggerid was missing from the codebase and has now been added. --- src/ts/process/lua.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/ts/process/lua.ts b/src/ts/process/lua.ts index 074ba707..4d48850a 100644 --- a/src/ts/process/lua.ts +++ b/src/ts/process/lua.ts @@ -418,6 +418,19 @@ export async function runLua(code:string, arg:{ setDatabase(db) }) + luaEngine.global.set('getDescription', async (id:string) => { + if(!LuaSafeIds.has(id)){ + return + } + const db = getDatabase() + const selectedChar = get(selectedCharID) + const char = db.characters[selectedChar] + if(char.type === 'group'){ + throw('Character is a group') + } + return char.desc + }) + luaEngine.global.set('setDescription', async (id:string, desc:string) => { if(!LuaSafeIds.has(id)){ return @@ -972,4 +985,4 @@ export async function runLuaButtonTrigger(char:character|groupChat|simpleCharact throw(error) } return runResult -} \ No newline at end of file +}