(supposedly) Simple fix needed for Yami Pop Messages and Chatter Add On

Basically I'm having an error between Yami's Pop Message and Quack's Chatter Add On. The error is that I can't save with both of these scripts. The good news is that someone seems to have had the same problem in the past, and although they didn't post their script changes, they did explain what they did:

"Turns out I found that @quack_msgs and @qmsg_windows can't be marshalled. I managed to fix this by turn both of them into an empty array before saving, and redefine them after saving or loading is successful."

Unfortunately, I don't have enough knowledge of Ruby and scripting to make this change myself. Could someone show me how to do this?

Yami Pop Message: https://github.com/suppayami/rmvxa-collection/blob/master/yami-script-ace/10 - Pop Message.txt

Chatter Add On:
Objects to be included in save files should never have sprites 🙁

Put this into a new script slot below the other two and see if it helps. I haven't tested it, so if you get any error messages, please post back.

Code:
module DataManager
  class << self

  alias quack_make_save_contents make_save_contents
  def self.make_save_contents
    $game_message.prep_for_save
    contents = quack_make_save_contents
    $game_message.quack_msg_make
    contents
  end

  alias quack_extract_save_contents extract_save_contents
  def self.extract_save_contents(contents)
    quack_extract_save_contents(contents)
    $game_message.quack_msg_make
  end
end
 
class Game_Message
  def prep_for_save
    @quack_msgs = []
    @qmsg_windows = []
  end
end

It's not great, as it's not disposing of the sprites and is then recreating them every time you save. HOPEFULLY Ace has its own garbage collector that will pick them up and dispose of them. If it does start to consume memory and/or lag the more you save, just post back and I'll see if I have time to do a proper fix.
It's not great, as it's not disposing of the sprites and is then recreating them every time you save. HOPEFULLY Ace has its own garbage collector that will pick them up and dispose of them. If it does start to consume memory and/or lag the more you save, just post back and I'll see if I have time to do a proper fix.

Hmmm...wondering how I should appropriately test that. Would going into a room and saving 100 times or so make it clear whether there's a problem or not? Or would I need to apply certain conditions to make sure there isn't a problem? I.e. constantly saving with a bunch of chatter boxes going off around me 24/7?
I'd open the task manager and make it show memory and CPU usage. Then yes, you could go into a room and save 100 times (or maybe not that many). I expect the memory usage might go up a tiny bit with each save, but if you wait a while, hopefully it'll come back down again.

Or you could just play as you'd expect players to - they're not likely to be saving over and over again in a short duration. If you do the above and memory usage increases, but goes back down again, it's probably okay unless you notice the game lagging after each save.

Did you try it out and see if it actually runs without crashing? That'd be the first test 🙂
Oh I was gonna try it tomorrow. I need to get to bed now. x.x Anyway, I'm only in the early segments of my game right now. I'd say it's an hour long in total at the moment. I want to more or less "get everything right" before moving on. Imagine if I only realized, halfway through my game, that this wasn't working and I had to go all the way back to the start...and fix everything.

Which is why I was trying to find a method to quickly and thoroughly check if this will be a problem. But yeah, I'll try to see if I get the game to lag when I have the chance.
It's more important right now to know that you can run the script, as I didn't test it before posting. You can check for lag any time after that, and if it lags because of this, we'll fix it 🙂
OK really quick before I go to bed:

1) First time I tested it, it was missing an end. I just added an extra one to the bottom to see if it'd fix things. Keep in mind I don't know anything about Ruby. ^^;

2) After I added this, it crashed with the message "undefined method "quack_msg_make"" for the Chatter script. Note that the Chatter script was still operating (albeit couldn't be saved) before I put this in.

EDIT: Also I double checked. Qonvenience isn't actually necessary for the script itself. To make things easier, I'll just move forward with the assumption that it isn't being used.
It's not a good idea to just add things to scripts if you don't know what you're doing. I just rechecked mine, and there is no end missing. If there was when you added it to your script, and it specifically said it was that script that was missing an 'end', you may not have copied it correctly.

The only time I'd expect you'd get the "undefined method quack_msg_make" error is if you had removed the quack message script, played and saved a game, added the script, then tried to load the saved game. At what point did you get the error - when saving, or when loading? Try starting a new game, saving it, then loading it and see if you still get the error.
Yeah, I copied and pasted it in again. "unexpected $end, expecting keyword_end" for line 23. Not seeing why, it looks like there's enough ends to me too...
Are you sure it's on THIS script? Do you have all your script slots named, and does it specifically say that it's this script that has the issue? Can you show a screenshot of your script editor, with this script visible, and a screenshot of the error message?
To make absolutely sure there's nothing else that might be causing a problem, I started a new project with just the necessary scripts. Here's the screenshots:

https://i.imgur.com/eQPmBVj.png

https://i.imgur.com/fb4qiXs.png
That's crazy! I can't see anything wrong with that at all, and even the syntax highlighting matches everything up.

What if you just add an extra blank line at the bottom, so that line 23 has a line break right at the end. Does that make a difference?

Otherwise, maybe someone else can see what's wrong.


edit ... wait a sec. I do see a couple of things I missed, and one of them might cause this. I edited my script - can you copy it again from the earlier post and replace what you have in your project?
@Shaz I think you might need an end to enclose the class << self. Like this:
Code:
module DataManager
  class << self
    alias quack_make_save_contents make_save_contents
    def self.make_save_contents
      $game_message.prep_for_save
      contents = quack_make_save_contents
      $game_message.quack_msg_make
      contents
    end

    alias quack_extract_save_contents extract_save_contents
    def self.extract_save_contents(contents)
      quack_extract_save_contents(contents)
      $game_message.quack_msg_make
    end
  end
end
 
class Game_Message
  def prep_for_save
    @quack_msgs = []
    @qmsg_windows = []
  end
end
Same error from the new version (just on line 24). Moonless' script doesn't crash...but saving still isn't an option either.
@A-Moonless-Night I'm not seeing a difference between yours and mine, except the extra blank lines I have. Or did you post that while I was doing my edit? The def self.--- always gets me on modules! Does that mean the original script, posted in the first post, would also not work? It doesn't have self. at the start of the DataManager methods either.
Well neither "work" for the time being, but the one in the first post still crashes at line 24.
People, pls. If you use "class << ModuleName", then stop using "def self.methodname"
Code:
class << DataManager
  alias quack_make_save_contents make_save_contents
  def make_save_contents
    $game_message.prep_for_save
    contents = quack_make_save_contents
    $game_message.quack_msg_make
    contents
  end

  alias quack_extract_save_contents extract_save_contents
  def extract_save_contents(contents)
    quack_extract_save_contents(contents)
    $game_message.quack_msg_make
  end
end

class Game_Message
  def prep_for_save
    @quack_msgs = []
    @qmsg_windows = []
  end
end
Ninja'd by Theo, haha.
Theo's version also doesn't crash. It's still impossible to save unfortunately. ^^;
Remove any added scripts you got here from the others and add this one instead:
Spoiler
Code:
class Window_Message < Window_Base

  def dispose
    if @speech_bubble_tag
      @speech_bubble_tag.bitmap.dispose
      @speech_bubble_tag.dispose
    end
    if @thought_bubble_tag
      @thought_bubble_tag.bitmap.dispose
      @thought_bubble_tag.dispose
    end
    yse_pop_dispose
  end

end

class Game_Message

  def disp_stuff
    if @quack_msgs
      @quack_msgs.each {|msg| msg.disp_stuff }
      @quack_msgs = []
    end
    if @qmsg_windows
      @qmsg_windows.each {|win| win.dispose }
      @qmsg_windows = []
    end
  end
 
end

class << DataManager
  
  def create_game_objects
    quack_msg_create_game_objects
  end
 
  def setup_new_game
    qmsg_sng
  end
  
end

class Scene_Map < Scene_Base
 
  alias make_quacks0027 create_message_window
  def create_message_window
    $game_message.quack_msg_make
    make_quacks0027
  end
 
  def dispose_all_windows
    $game_message.disp_stuff
    super
  end
 
end

class Scene_Battle < Scene_Base
 
  alias make_quacks0021 create_message_window
  def create_message_window
    $game_message.quack_msg_make
    make_quacks0021
  end
 
  def dispose_all_windows
    $game_message.disp_stuff
    super
  end
 
end
Put it below Yami's and Quack's scripts.
And you should make sure that Quack's script is right below Yami's, and put all these 3 scripts as high as possible on your custom script list, because this fix overwrites some pretty important methods to get rid of issues created by Quack's script.
Alternatively, you can also remove the DataManager part from both Quack's script and from this fix, that should work, and it should be more compatible, leaving you more freedom to position these 3 scripts on your script list.

There are so many wrongs in Quack's script, it hurts. >.>
I can't guarantee that this fix will work with other scripts altering the message box related classes.

Original thread: https://forums.rpgmakerweb.com/threads/supposedly-simple-fix-needed-for-yami-pop-messages-and-chatter-add-on.105300/