Parallel event to action event for dialogue

I have a script I am using to control players and when they are on screen that needs to run a parallel but I also need to be able to interact with this character as well and have dialogue boxes. Any help is appreciated.
.
// Get the event ID of the NPC (replace with the actual event ID)
const eventId = this._eventId; // 'this' refers to the Game_Interpreter (event running)
// Get the Game_Event object for the NPC
const event = $gameMap.event(eventId);
if (event) {
// Check if it's between 8 AM and 8 PM
if (TimeManager.getHour() >= 8 && TimeManager.getHour() < 20) {
// If within the hours, set the graphic to the visible NPC sprite
event.setImage('Ch_People06', 0); // Replace 'People1' and 0 with the actual filename and index
event.setOpacity(255);
$gameSwitches.setValue(10,false);
event.setThrough(false);
event.setGraphics();
} else {
// If outside the hours, set the graphic to a blank/invisible sprite
event.setImage('!$', 0); // Replace with filename and index to transparent sprite (character sprite)
event.setOpacity(0); //Completely Invisible
event.setThrough(true);
}
} else {
console.warn("Event with ID", eventId, "not found.");
}
please take a step back and tell us what you want to happen inside the game, not how you want something unknown to happen.

for example nothing in the script above couldn't be done much simpler with multiple event pages.
and if that is the case, you're probably overthinking it and looking for a complex solution where an easy one would be enough.

but we can't tell without more background info, especially because your wording in the request isn't clear either.
Fair enough in the game characters will be in certain places at certain times this particular character will be standing guard from 8am to 8 pm and at 8 pm he will disappear. I need to run is a parallel event with the timer that I've already got. But at the same time I also need to be able to interact with a character and have dialogue with them.
Idk if I get your problem, but lemme share how I'm handling my NPCs in my current game.
the first page is the empty one.
in x hour, the second page activates, with a variable checking the hour, so NPC walks to their destination. For this I have the page set to button press and a walking charset. If the player interacts with it it will trigger the next page (with self switch), a auto one, where all the dialogue is, and the charset on this page is using idle anim. then it goes back to the previous page and the NPC continues their path. (I belive a pathfinding plugin could help, I didn't tested that yet)

Edit:I took a look on pathfindings plugins and oh boe, it's not as easy as I thought.
my NPCs are set to buttom press so most pathfindings plugins don't work. What I did was using a automatic move route function to follow X Y on Galv's Move Route Extras. The only problem is I also use Qmovement, so map coordinates don't work, my workaroud was sending the event to another event, usually a door.
This is where I'm at right now. I have the time event set up to run as a parallel with a DAY NIGHT time plug in. at 8 pm this actor will vanish and not be accessible until 8 AM.

I still need to be able to walk up to him and spawn a dialogue box so what I'm asking is how do I do that is it a multi page thing how do I create an action event when I've already got a parallel going on that is absolutely necessary.
What happens if the player stays on the map long enough? Will the npc vanish or transform right before your eyes?

Anyway, I think you can use another paralell event to control this event so you can speak with it. Just replace the event Id in the script with a number.
@csevans84
I think a better solution is the following:

you'll need one variable "hours" containing the time of day in hours from 0 to 23.
then your NPC event needs three pages:

page one has no condition and no sprite, the NPC is away before business hours
page two has a condition hours >= 8 and the sprite of the NPC on position, being ready for conversation or whatever else
page three has a condition hours >=20 and again no sprite, the NPC is away after business hours

the only thing you would need is to configure your time management so that the hour variable automatically updates, no complex script needed at all.
and that means you can simply leave the middle page on action button for whatever.
I fixed it I just made a new event to control everything but appreciate the help.





(function() {
const pluginName = "NPCVisibilitySpecific";
const visibleStartHour = 8;
const visibleEndHour = 20;
const targetEventIds = [9, 16, 19, 20, 21, 22, 23, 24];
const _Scene_Map_update = Scene_Map.prototype.update;
Scene_Map.prototype.update = function() {
_Scene_Map_update.call(this);
updateNPCVisibility();
};

function updateNPCVisibility() {
if (!$gameMap) return;
targetEventIds.forEach(eventId => {
const event = $gameMap.event(eventId);
if (event) {

if (TimeManager.getHour() >= visibleStartHour && TimeManager.getHour() < visibleEndHour) {
// Visible state
// event.setImage('Ch_People05', 4); // Removed this line - no sprite change
event.setOpacity(255);
$gameSwitches.setValue(10, false); //Makes it work correctly
event.setThrough(false);
} else {

// Invisible state
// event.setImage('!$', 0); // Transparent sprite Removed this line
event.setOpacity(0);
event.setThrough(true);
}
} else {

console.warn("Event with ID", eventId, "not found.");
}
});
}
})();

Original thread: https://forums.rpgmakerweb.com/threads/parallel-event-to-action-event-for-dialogue.175710/