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:
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user