Odd Issue When Eventing A Scrolling Adventure Log - PLEASE HELP!

Ok, so Zombie is at his wits end and this is killing me for a 2nd time. I have been struggling with this for days and I have tried everything I can think of to figure out what is going wrong. I have finally narrowed down to WHAT seems to be happening, but I can't figure out WHY it is happening. I must be missing something obvious that I just can't see.

I am going to make this post shorter by using SPOILERS for all the screenshots. I apologize for how many screenshots there are.

What is supposed to be happening?

I have a Parallel Map Event that is adding string Text to an Array that is storing Messages for a scrolling Adventure Log. I have a Parallel Common Event that is displaying the Messages from the Adventure Log Array on the screen. The Array should never get longer than 14 Messages. So, I am removing the Array element at Position 0 when I need to add a new Message to the end of the Array after the Array has 14 elements. So, I remove the first Message and then add a new Message at the end.

After many mistakes in design and then troubleshooting, (dumb Zombie) everything seems to be working fine except in 2 specific spots of the Map Event. Those spots don't seem to be any different from other parts of the Event and the behavior is consistent with every test.

Some things in the Events probably seem unnecessary, but they are remnants of me trying to figure out what is going on and trying to fix the problem. I also have another Common Event to display the scrolling Adventure Log that is designed differently and it ends up having the exact same problems in the exact same spot. So I believe the issue is in the Map Event somehow.

Anyway, I would GREATLY appreciate anyone who takes the time to read this, look through the screenshots, and who can offer advice. Here come the SPOILERS. THANKS in advance! Urgh...Argh!

Spoiler: 4 Things I Am Asking
  1. Is the an error in the Event Commands or with the logic that is causing this problem? If so, what?
  2. If there doesn't seem to be any errors, WHY is this happening?
  3. Can you suggest a different/easier/better way to Event this? If so, can you please show me?
  4. Is there a plugin that you would suggest to do the same thing to just show a scrolling log of whatever text I want?

Spoiler: Screenshots Of Problem
These screenshots are of Show Text Commands I used to try to narrow down the problem. The top Variable is the value of the Message stored in Position 13 of the Array. The middle Variable is the value that is being used to identify the Array Position to pull from (13). The bottom Variable is the length of the Array. Once the Array gets to a length of 14, the Map Event starts to remove the Message at Position 0 in the Array and then pushes the new Message to the end of the Array.

This works fine multiple times before the problem manifests. In this screenshot you can see the Variable values of a Message that matches the last Message displayed in the log ("Gale takes 15 damage!" and you can see it through the Show Text Window) and then 13 (Array Position) / 14 Array Length.

Log Issue 1.png
In this screenshot you can see that the Message from the Array is 0 (empty - nothing in that Position), 13 for the Array Position, and 13 for the Array Length. So it is trying to pull an element from the Array that doesn't exit. But you can see in the Adventure Log display that a Message does get show ("Gale is Burned!") with a blank space that would have shown "0" except I made it so the Common Event wouldn't show the 0. So, it seems like the element at Position 0 in the Array is being removed to reduce the length of the Array to 13 instead of 14, but the script that pushes the new Message to the Array is happening, but the length of the array is still 13 when the Show Text Command happens and it should be 14.
Log Issue 2.png
Then it seems to fix itself.
Log Issue 3.png
Then it happens again.
Log Issue 4.pngThen it fixes itself again.

Log Issue 5.png

Spoiler: Map Event
The first screenshot is full to show the left side of the Event. Page 2 is Self-Switch A that the Event moves to at the end to stop the Parallel process. Pages 3 & 4 were just experiments and they are set to the Conditions of Self-Switch B & C so they will never be active. The rest of the screenshots start with the last line that was visible in the previous screenshot and only show the Contents window. As shown in the previous SPOILER, I believe the problems are with the Messages for "Gale is Burned!" and "Test 2".

Log Issue Feeder Event 1.png

Log Issue Feeder Event 2.pngLog Issue Feeder Event 3.pngLog Issue Feeder Event 4.pngLog Issue Feeder Event 5.pngLog Issue Feeder Event 6.pngLog Issue Feeder Event 7.pngLog Issue Feeder Event 8.pngLog Issue Feeder Event 9.pngLog Issue Feeder Event 10.pngLog Issue Feeder Event 11.pngLog Issue Feeder Event 12.pngLog Issue Feeder Event 13.pngLog Issue Feeder Event 14.png

Spoiler: Common Event
Here is the Common Event.
Log Issue CE 1.pngLog Issue CE 2.pngLog Issue CE 3.pngLog Issue CE 4.pngLog Issue CE 5.pngLog Issue CE 6.pngLog Issue CE 7.png

The part about Erasing Picture #6 was my fix to make it so the "0" wouldn't be shown in the Adventure Log display. But if someone can figure out why that "0" value is happening in the first place, then that part of the Common Event shouldn't be necessary.
One quick advice i can give you is to maybe separate the eventing logic into 2 different events perhaps.

One parallel event which is used to handle the refreshing of the text lines you want to draw and also handle removing the first element.

And another event which just adds text inside the variable array, 901 in your case.
This will eliminate the need to copy-paste the logic to check if the array is at a length of 14 or not.

You could also try using script calls in order to add the text without using temporary variables, this would make the eventing cleaner.

I'll help out more if no one else decides to step in.

Spoiler: Script Call Example
Screenshot_625.png
condition of < 14 or > 14 never checks 14 in general, either one should
be <= or =>.

as the count always gives +1, it could go over 14, as 14 on index = 15 messages.

additional check for clean up is to remove the line:
$gameVariables.value(901).remove($gameVariables.value(901)[0]
and set that in a separate common event in parallel with the condition:

wait 5 frames.
if: script: $gameVariables.value(901) >= 14
$gameVariables.value(901).remove($gameVariables.value(901)[0])
end

this automatically clean the first array for you in case it happens
depending how fast you can go through all the messages.

but other than that, I don't really see any other issues as it keeps looping
through all the messages?

not entirely sure what should happen if it's outside of battle?
Yes as mentioned above, you check if ALogArrayLength=14, but in reality it is possble the value is 15, 16, etc. Because you push multiple strings into the array.
If you don't use script, you can at least make the process a common event and call it every time you add a new log entry.


◆Control Variables:newLog = blahblah...
◆Common Event:addNewLog
...
◆Control Variables:newLog = oooooo...
◆Common Event:addNewLog
....
◆Control Variables:newLog = ******...
◆Common Event:addNewLog
Thanks for these responses! I will go back and try some things.

Just to clarify, the Map Event was just to test the concept of adding Messages to the Array so the Parallel Common Event could display the messages as it ran.

In reality, the Adventure Log messages would only be added to the Array as things happened in the game. There wouldn't be one Event adding a bunch of stuff.

It would be more like something happens that should be in the Adventure Log so it is added as it happens.

So some of the Map Event design is just to test the concept/mechanic so any applicable Event could add Messages to the Array and the Parallel Common Event would just run in the background updating as appropriate.

I figured after I got to the point that the Array was supposed to be full, then the Parallel Common Event should be just one applicable part after that.

Thanks again and I will go experiment with some of these suggestions to see what happens.
if you re-use the variables over and over, you can create a mini function.

so you can do AdventureLog(string, args) {
let text = eval(string);
let args = "whatever needs to be done";
let log = $gameVariables.value(901);
log.push(text, args)
}

and you can do everything automatic, even check if the log has more
than 14 entries to remove the first, so you only need to insert waits
and you basicly have an easy to go function to use over and over.

just make all variables use it correctly whatever you want to show though 🙂
as it can be helper function, so copy paste, copy paste isn't required that way 😀
@TobyYasha @ShadowDragon @utunnels

This is very frustrating. I have tried a bunch more things and nothing fixes the original Map Event test to simulate adding things to the Adventure Log Array. But I did get a different Map Event test to run smoothly with 2 modified Common Events. But not the original Map Event test.

Here is what I tried:
  • Adding the remove Position 0 from the Array in the Common Event that updates the display
  • Adding a new Common Event that just removes Position 0 if the Array length is > 14
  • Deleted all parts after the spot in the Event where the first problem appears and everything worked fine
  • Added another Message (17th Message) and the same problem happened
  • Added more Messages and the same problems happened in the exact same two spots
Now, for the smooth running Events.
  • I have a Map Event that Loops to add strings (Messages) to the Array
  • I have a Parallel Common Event that just removes Position 0 if the Array length is >14
  • I have a smaller Parallel Common Event that updates the displayed Messages
Everything works perfectly.

So, it is terribly confusing why that original Map Event was having problems.

@utunnels I don't think I want to call the Common Event every time the game would add a Message to the Adventure Log since it would be easy to miss a time when it should happen. I think it would be easier to just have the Common Event running in Parallel. But maybe not. I will keep it in mind.

@ShadowDragon I appreciate the thoughts on making a function, but properly using functions in JS still eludes me. I look at your example and I'm not really sure how to implement it. I still need to learn more about functions and how they work.

@TobyYasha I will experiment with the script call example you gave so I can get more familiar with how it is used.

Here are screenshots of the much simpler and smaller Map Event test and the 2 Common Events that make for a smooth test.

I will have to do more testing with Events adding longer strings to the Adventure Array to see if the same problems appear again. If they do, then I don't have any idea what is causing it.

When I run the Test it smoothly displays Test 1, Test 2, Test 3...up to Test 30 and then stops. No problems at all.

Spoiler: Screenshots of 3 Events
The cut off portion of the first screenshot is just turning on Self-Switch A to stop the Parallel Event process.

AL New Test.pngAL New Test CE 1.pngAL New Test CE 2-1.pngAL New Test CE 2-2.pngAL New Test CE 2-3.png

EDIT: Thank you for your responses and assistance! If you have any other thoughts, please share!
you set 5 variables to 0, 1, 2, ,3 ,4 ,5 (why the specific numbers)?
arrays are mostly empty, best testing this kind is to use 5 message or 6
and max array length 3 (index 0, 1, 2).

you can do a function like:

JavaScript:
let AddToLog(text, textTwo, arrLen = 3) {
    let varOne = $gameVariables.value(901);
    if (varOne >= arrLen) {
        varOne.remove(varOne[0])
    }
    let first = eval(text);
    let second = eval(textTwo)
    let combined = `${first} ${second}`
    varOne.push(combined);
}

when you define somewhere variable 901 = [] (it become an array to be used).

using this in an event: AddToLog($gameActors.actor(5).name, " found a chest")
will push this to the log.

you can use any kind of wait (120 wait) or whatever you need.

if you use more variables to control, you can do the same, as you just save
it as a plugin and throw it on the bottom of your plugin list 🙂

Edit:
correct minor mistake in the function 🙂
@ShadowDragon Thanks for that example! I understand a lot of it and I will experiment with it to see if I can understand the rest.

What I am eventually trying to have is a Log where it displays a certain number of Messages that scroll as more Messages are added. I want the Messages to scroll smoothly in the Log area and I also want to implement the functionality where the player can Expand the Log to show all 14 Messages instead of say 5-7. So the Max the player could see would be 14 or whatever Max limit I set.

So, I am trying to test ways to accomplish that. Everything I am working on is just tests to see if I can get the functionality to work.

Messages would be added to the Array based on what the player is doing at any given time. So, many different Events could be adding Messages to the Array.

Not sure if that makes sense.

But again, thanks for that function example. I probably understand about 80-90% of what is in there. I will do some searching and experimenting to see if I can really get a good grasp of it.
you can make the log differently to show it more like:

varOne[0]
varOne[1]
varOne[2]
etc

this shows simply the index in order, but you need to set something as well
like if (varOne == null || varOne == undefined) return "".

another way is a bit long plugin, to define the array.
I dont know how to make it scrolling work if it's a static window that is always open.
than it require more work, but 5 different variables for the list is not really needed.

I'm no expert coder, but I do learn a lot.
@ShadowDragon I am using 5 Variables because I am using the TextPicture plugin to display the Messages and it only accepts the typical things you can do with Show Picture. So, unless I am mistaken, if I want to show 5 different values from an Array, I need 5 Variables. I could show them all in the same TextPicture command line, but I think I would still need 5.
so varOne[1] to pick from the array doesn't work?

if it has eval, it might work, but you need to test it as I don't have MZ to try.
I doubt MV has a similar plugin to try out.

if it doesn't work, than set each variable to 0, instead of 0, 1, 2, 3, 4.

as those aren't arrays, but it it has to do with "lines" than I could understand it.
I don't believe so. If you try to do that varOne[1] in Show Text I don't think that works. The TextPicture works the same way as Show Text.
Not sure if this is breaking a rule about double posting in my own thread, but I wanted to give a quick update.

I am continuing to experiment with options, but I took the long Map Event for my initial test that was having issues and I moved part of the Event to a new page a few Messages before the first problem. Then I moved the last part of the Event to another new page just before the second problem.

And guess what? It works better. There are a couple of visual glitches where it looks like the last two Messages blink once, but it doesn't show the blank space or a zero.

So, I still have no idea why that Event was having problems in those two particular spots or why breaking the Event up into different pages would make a difference.

But I am going to do a more realistic test of my newest approach with different Events that generate Messages for the Log based on different triggers and interactions. Just to see if the newest approach still runs smoothly.

Original thread: https://forums.rpgmakerweb.com/threads/odd-issue-when-eventing-a-scrolling-adventure-log-please-help.174837/