Add getDescription function to LUA script (was missing) (#852)

The `getDescription(triggerId)` function, documented at:
https://kwaroran.github.io/docs/srp/lua/#getdescriptiontriggerid was
missing from the codebase and has now been added.

# PR Checklist
- [ ] Have you checked if it works normally in all models? *Ignore this
if it doesn't use models.*
- [ o] 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?
- [  ] Have you added type definitions?

# Description
This commit is contained in:
kwaroran
2025-05-24 20:16:23 +09:00
committed by GitHub

View File

@@ -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
}
}