Logic to determine new available dialog.

I have 3 main NPCs that can be randomly on different maps depending on time of day, and I'm wanting a way to indicate to the player via an icon above its head to denote new/available chat dialog.

My issue is thinking of the logic for checking that, since the way I'm seeing it I can do this 2 ways(note, this is not accounting for a plugin i'd likely need for the icon itself, just the logic leading up to it)
  1. Make all dialog based off 2 variables, the
    Code:
    dialog available
    and
    Code:
    dialog_read
    , so if
    Code:
    dialog_available > dialog_read
    , then show the icon. Issue is this is very linear and doesn't allow for route specific dialog. Each time you read dialog dialog_read goes up, and maxes out when it meets dialog_available.
  2. Manually check for each conversation_available switch, and compare it to each conversation_read switch to see if there is any available. Results in 2 switches for each, which sounds like it can be cumbersome.
  3. Occurred to me- use scripting to make a little array of dictionaries like
    Code:
    {conversation name: "Joe meets sandwitch", read: false"}
    and I can check off of that using some if(!convo.read) logic, but I'm not in the mood to make a plugin just for this.
Is there anything I might not be considering? If anything doesn't make sense feel free to ask and I'll elaborate further.
Right now I'm thinking option 2 is the best, since I will have different routes. That or a combination of the two. This will be a massive pain but it's all the more reason to not bother implementing all the dialog until the gameplay is actually ready for it.(Thank you yanfly for teaching me its better to fully make the gameplay part itself then worry about the inbetween scenes and dialog)

The plugin I will use is probably going to be this one by VisuStella.
(note, this is not accounting for a plugin i'd likely need for the icon itself, just the logic leading up to it)
It probably makes sense to find/decide on that plugin first, since you're going to have to accommodate whatever it uses to determine when icons are shown.

However, you don't necessarily need a plugin for this at all. Just use an image editor to make a version of the NPC's image with the icon over its head. Assign that image to the event, then when you finish the dialog it sets a self switch to go to the next page which uses the icon-less version.

As far as your implementation options...the problem is getting them to determine an event page. The only one that does that natively is 1, since you can have a Variable >= condition with a Switch On condition on a higher page number.

For the others, you'd also need to use a plugin that allows you to have customized page conditions via comments.

To implement your option 3, you wouldn't need to write any kind of plugin, just use some script calls in the editor.

Use one to choose a variable and make it be an array - $gameVariables.setValue(42, [])

From then on, you can freely add and check and modify elements using $gameVariables.value()

1716395246887.png
The way I implement it will likely be a common event that then checks all the possible dialog, and when you get one then run exit event processing, to avoid the 50 if else lines like I've seen in Fear & Hunger. (There is a reason in the sequel he doesn't have features like having a book to give you any item in game, bc he'd have to do 50 if elses again since he didn't know about exit event processing. )

I like that!
From what you're saying, I can just check $gameVariables.value(3)["Joe meets sanditch"] which will be false or some equivalent by default, which allows me to check if it exists, idk the exact command but for example I know another language has something like that with the .has(value) function to show you if it has something.

Then I can actually check it itself to get a false if the dialog hasn't been read and true if it has? I might make a few functions in a plugin to rude repetitive code if it does work like that.
From what you're saying, I can just check $gameVariables.value(3)["Joe meets sanditch"] which will be false or some equivalent by default, which allows me to check if it exists
Once you've initialized that variable to be an array like I showed you, yes.

Then I can actually check it itself to get a false if the dialog hasn't been read and true if it has? I might make a few functions in a plugin to rude repetitive code if it does work like that.
Right. It's up to you if you want to make some kind of plugin out of that, but all you have to do is paste the line into the Script field of a Conditional Branch then replace the name of the dialogue branch (which you have to re-type regardless).
Thank you for the help! Also to clarify in case anyone finds this and needs it, when you initialize it like in line 2 of ATT_Turan's screenshot, I had to put = false at the end otherwise it didn't assign anything.
Edit: That wasn't intention of original screenshot, read on their next reply.
when you initialize it like in line 2 of ATT_Turan's screenshot, I had to put = false at the end otherwise it didn't assign anything.
That's not correct - line 2 is not initializing anything. Per the comment right below it, that is what you put into the Script field of a Conditional Branch to check if it's true.

The only initializing you have to do is to make the variable be an array, as I described and showed on the first line of the screenshot. Everything you try to reference will automatically come back as false (undefined) until you assign something to be true.

The process should be pretty self-explanatory from the series of commands I took the screenshot of. As you see, there's no need to set it to false before I set it to true. That screenshot was me typing directly into MZ's console, so if yours acts differently there might be some kind of issue with your system.

If you want to use the array to track not just binary values but whether a dialogue is available and then read, simply use 1 and 2 instead of true.
when programming complex decisions, try modelling the flow by operations: "On this action, *this* must happen".
work by positive, with no question.
that way you'll arrive at a situation where you'll see the question evidently.

in your case, an operation would be "on this interaction, trigger dialogue"
from there: "Which dialogue?" -> the one specified by X.
from where, stems: "How do I read X?", and "How do I set X?"
those two by themselves become two new operations, and you repeat the process until you get to the root of the problem.
Gotcha, that makes sense. I'll go ahead and do that instead of going off true/false. Thank you again.

Original thread: https://forums.rpgmakerweb.com/threads/logic-to-determine-new-available-dialog.168912/