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.
This commit is contained in:
Joseph Kang
2025-05-18 17:16:22 +09:00
committed by GitHub
parent 0a792db7c2
commit 5e330424f4

View File

@@ -418,6 +418,19 @@ export async function runLua(code:string, arg:{
setDatabase(db) 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) => { luaEngine.global.set('setDescription', async (id:string, desc:string) => {
if(!LuaSafeIds.has(id)){ if(!LuaSafeIds.has(id)){
return return
@@ -972,4 +985,4 @@ export async function runLuaButtonTrigger(char:character|groupChat|simpleCharact
throw(error) throw(error)
} }
return runResult return runResult
} }