I have a piece of Javascript that includes an event listener for a keypress event. When the f
key is pressed and certain conditions are met (such as distance being less than 5 and npc.talkedTo
being falsy), I want to trigger a dialogue and set the value of an element with ID xb1TalkedTo
to true
. However, the value of xb1TalkedTo
doesn’t seem to be updating as expected.
Here’s a simplified version of the code:
function handleInterest(event, npc) {
if (event.key == 'f' && distance < 5 && !npc.talkedTo) {
triggerDiablogue(currentDialogue);
let xb1TalkedTo = document.querySelector('#xb1TalkedTo');
xb1TalkedTo.value = true;
}
}