Finished up with chat prompt autocomplete.

This commit is contained in:
rainbow napkin 2025-01-05 00:05:19 -05:00
parent acbe0400c4
commit 9df7f52e9e
7 changed files with 197 additions and 100 deletions

View file

@ -143,7 +143,10 @@ class chatBox{
send(event){
if((!event || !event.key || event.key == "Enter") && this.chatPrompt.value){
this.commandPreprocessor.preprocess(this.chatPrompt.value);
//Clear our prompt and autocomplete nodes
this.chatPrompt.value = "";
this.autocompletePlaceholder.innerHTML = '';
this.autocompleteDisplay.innerHTML = '';
}
}
@ -198,11 +201,12 @@ class chatBox{
//I went with a for loop instead of a filter beacuse I wanted to pull the processed definition with pre/postfix
//and also directly push it into a shared array :P
for(let cmd of dictionary[set].cmds){
//Append the proper prefix/postfix to the current command
const definition = (`${dictionary[set].prefix}${cmd}${dictionary[set].postfix}`);
//if definition starts with the current word
if(word == '' ? false : definition.indexOf(word) == 0){
//Append the proper prefix/postfix to the current command
const definition = (`${dictionary[set].prefix}${cmd[0]}${dictionary[set].postfix}`);
//if definition starts with the current word and the command is enabled
if((word == '' ? false : definition.indexOf(word) == 0) && cmd[1]){
//Add definition to match list
matches.push(definition);
}