# PR Checklist
- [ ] Did you check if it works normally in all models? *ignore this
when it dosen't uses models*
- [ ] Did you check if it works normally in all of web, local and node
hosted versions? if it dosen't, did you blocked it in those versions?
- [ ] Did you added a type def?
# Description
With the recent increased utilization of custom styles, I've modified
the '{{chat_index}}' and '{{roll}}' cbs to cover a bit more cases.
Please review them to see if they meet your vision.

### 1 Access key was not added properly
First commit fixes this
### 2 Lua engine was getting killed when it waits for async function
runLua function gets run in two different paths (i.e. runLua for lua
edit triggers and another one for onOuput handling) However, when one of
invocations waits for another promise from js side (i.e. low level
function) to finish, it gives chance for next trigger mode to run which
would call `if(luaEngine){ luaEngine.global.close() }` that will close
lua engine for the invocation that was waiting for promise which is
problematic.
Second commit fixes this by having a pool of engine for each trigger
mode having single mutex that prevents running same engine at the same
time while allowing different tigger modes to run parallely
### 3 Break statements were missing making every trigger to run for
input event.
This was causing insane lagging and buggy behaviours. Third commit fixes
this.
Asset list can be different depending on character. Technically, we
should also invalidate cache when asset list is changed but I doubt
people will hit this case often. (bot maker somewhat hit it though so
maybe worth taking care of)
All of these functions were not working since it needs a special trick
to call javscript async function within lua:
https://github.com/ceifa/wasmoon/issues/22
The proper trick for allowing async function was added.
Also added missing awaits for similarity search.
You can use following lua trigger to test out the behaviour:
```lua
listenEdit("editOutput", function(triggerId, data)
local res = similarity(triggerId, data, {"happy", "angry", "sad"}):await()
return res[1]
end)
```
Note you need https://github.com/kwaroran/RisuAI/pull/572 to test this
out since low level access is disabled for lua right now.
# PR Checklist
- [ ] Did you check if it works normally in all models? *ignore this
when it dosen't uses models*
- [ ] Did you check if it works normally in all of web, local and node
hosted versions? if it dosen't, did you blocked it in those versions?
- [ ] Did you added a type def?
# Description
It appears that the current date time formatting in CBS is not working
as intended, I also added a format for the day of the week (`ddd` and
`dddd`), please review if this is appropriate.
# PR Checklist
- [ ] Did you check if it works normally in all models? *ignore this
when it dosen't uses models*
- [ ] Did you check if it works normally in all of web, local and node
hosted versions? if it dosen't, did you blocked it in those versions?
- [ ] Did you added a type def?
# Description
Currently, some of the operators in the trigger block seem to be working
in reverse.