chore: Add truthy operator to trigger conditions

This commit is contained in:
kwaroran
2024-05-28 20:42:26 +09:00
parent 2401b25bee
commit 0d28f1a381
3 changed files with 11 additions and 3 deletions

View File

@@ -26,13 +26,13 @@ export type triggerConditionsVar = {
type:'var'|'value'
var:string
value:string
operator:'='|'!='|'>'|'<'|'>='|'<='|'null'
operator:'='|'!='|'>'|'<'|'>='|'<='|'null'|'true'
}
export type triggerConditionsChatIndex = {
type:'chatindex'
value:string
operator:'='|'!='|'>'|'<'|'>='|'<='|'null'
operator:'='|'!='|'>'|'<'|'>='|'<='|'null'|'true'
}
export type triggerConditionsExists ={
@@ -186,6 +186,12 @@ export async function runTrigger(char:character,mode:triggerMode, arg:{
const conditionValue = risuChatParser(condition.value,{chara:char})
varValue = risuChatParser(varValue,{chara:char})
switch(condition.operator){
case 'true': {
if(varValue !== 'true' && varValue !== '1'){
pass = false
}
break
}
case '=':
if(varValue !== conditionValue){
pass = false