Multiple Message Windows Bugfix Request [XP]

Started by Heretic86, June 17, 2012, 06:05:31 am

Previous topic - Next topic

Heretic86

This one is well over my head.

Just using an unmodified version of Wachunga's Multiple Message Windows (ver 1.5).  The problem I am running into has something to do with Window_Selectable, but I need to explain more specifically.  When the Player is asked a question they are going to respond to, I am setting stuff up to have the character the player is controlling have a speech bubble with those choices come from them as opposed to the choices coming from the NPC.  As the name of the script implies, multiple speech bubbles can be displayed at the same time using \+ on the next line.  What I am trying to accomplish is to have the player walk into a shop, shopkeeper asks "Wanna buy something?" and display another window from the Players character that says "Well..." and then provide the choices in the Players characters speech bubble, not the shopkeepers. 

So here is the problem.  When choices are displayed in a secondary window, they are not selectable, like the first speech bubble is holding focus.  Pressing enter closes the first speech bubble (from shopkeeper) but doesnt provide any control to the player over the choices.  They print in the message window, but I cant select them.  Im stumped!

Im hoping someone can fix this without too much effort!
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

ForeverZer0

Have them pop up at the same time, just call the player's choice window first.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Heretic86

Thats a good idea, except for (*drum roll*) I made some changes...

I added another way to display the next message, by using a \* string in the original message text to display the next message in the queue, so they dont both immediately appear at the same time, but are both visible at the same time.  Only problem is the same problem.  Does it have anything to do maybe with $game_temp.message_proc[@msgindex] = nil?
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

ForeverZer0

Quote from: Heretic86 on June 17, 2012, 06:05:31 am
Just using an unmodified version of Wachunga's Multiple Message Windows (ver 1.5).


So this is a bit misleading then.
Maybe the edit preventing the next window from showing is causing the problem. Could you post that?
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Heretic86

I dont believe so.  It was just an extra set of characters to look for, and does the same thing as \+ (display multiple windows) which was just a matter of changing these two variables:

@multi_message = true
@message_waiting = false

And voila!  The next queued msg displays.  I think that because there are multiple windows being displayed, the first one is still holding focus over the next sequential window.  Is there a "generic" way to change which window is holding focus?  Im not familiar enough with the window classes...
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

Heretic86

That didnt mean the problem is solved...  What else can I try to fix this?
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

ForeverZer0

Does the same thing happen in an unedited version of the script. I only because although you are saying it is not, the edit you made deals specifically with the same thing you are having problems with, and you didn't say you confirmed it's not by testing.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Heretic86

Yeah, the problem still occurs in the unedited version.  Sorry if I misphrased it to elude that it was working.  It still does the same thing as described in the OP.
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

ForeverZer0

You can simply set the window as active.
@myWindow.active = true


This works on Windows that inherit from Window_Selectable, which the choice window does.
Since MMS uses and array of windows that can be found in Scene_Map if I remember correctly, you can get the last created window with:
@message_windows[-1]


You will have to be sure to not set "active" on non-Window_Selectable windows, as well as deactivate any other window that may be "active", else the player will be controlling multiple windows with each key press.

@message_windows.each {|window| 
 if window.is_a?(Window_Selectable)
   window.active = false
 end
}
last = @message_windows[-1]
if last != nil && last.is_a?(Window_Selectable)
 last.active = true
end


That's some ugly hackish code, but hopefully you get the main idea.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Heretic86

I thought that would have fixed it, but no luck.  Looks like Wachunga already did that...

    # If choice
    if $game_temp.choice_max > 0
      @item_max = $game_temp.choice_max
      self.active = true
      self.index = 0
    end


Any other thoughts on how to pull this rabbit out of the hat?
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

ForeverZer0

Thats not it. That simply activates a choice window if it has selectable options.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Heretic86

After looking further, youre correct as usual sir.  But the code was in there after all.

  def setup_choices(parameters)
    # Set Select Window to Active
    $scene.message_window[@msgindex].active = true


So looks like my theory of active or focus is a dead end.

Turns out (suprise) I was causing one of the issues by trying to use the \? command (wait for input) before displaying the choices.  The code \? returns when found so the rest of the script quits executing.  As it turns out, both windows being displayed now have Select Boxes appearing.  Im so stumped.
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

Heretic86

So I got something sort of working.  But now the choices fail to process correctly...

General suggestions?
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

ForeverZer0

I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Heretic86

June 21, 2012, 02:09:20 am #14 Last Edit: June 25, 2012, 02:26:04 am by Heretic86
Well, I havent had as much time to focus on this as I would like so only been taking pot shots at it for an hour here or half hour there.  What I got working is the select window does appear correctly in the right window, and it is selectable, but any choices submitted when the selection is appearing in the correct window fails to process at all.  I came across a reference to command_402 to process and tried digging into that, but the variables arent getting passed to it, so it just exits without executing choices.

Wanna buy something?

When Yes
shop_processing
When No
get lost

It does neither.  Just skips right over anythign that would be executed from the conditional branch event statements.

---

Edit instead of a New Post.  Turns out what I needed was TIME to wrap my head around the problem.  Solution to the previous problem had to do with trying to process wrong window's index.  Thats fixed.  If anyone else is following this thread, a lot of the bugs have been resolved, but there are still a couple that are nasty and evil.  Pretty much have to do everything all over again for Battle System Message Bubbles.  When I get this resolved, it will be part of my 1.98 release of my Caterpillar script (that I pretty much stole from Zeriab and Wachunga).  Of course, they are still getting credited.
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

Heretic86

Ok, hopefully an easy one.

I got the previous problem fixed.  Have a NEW PROBLEM.  In Scene_Map, I am able to bring up a new msg window at any time the text is updated by setting @multi_message = true and @message_waiting = false, but can not seem to get a new window to be created in Scene_Battle.  Setting those Variables doesnt cause the new msg to be displayed because calling command_101 isnt being called, but calling command_101 causes a crash cuz $game_temp.message_text[@msgindex] = @list[@index].parameters[0] + "\n" brings up a non text command that is battle related.  (Win Processing).  Im stuck again...

Suggestions?
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

ForeverZer0

Why are you calling Interpreter commands to display messages? Even if not calling directly, if whatever you have implemented causes it to happen down the line, then the problem lies in your implementation. It may seem like an easy way to do things, simply inserting commands, but it is basically just asking for trouble. The Interpreter relies on having perfect structure to work, and one false command or a wrong "indent" will cause bugs that are going to be hard to track, and may evade testing, since they may only occur during specific situations in their processing.

If your implementation is altering event lists, then sorry to say, my best advice is going to be to go back to the drawing board and find another way. There shouldn't be any need to do it that way.

I may be misunderstanding what exactly you are doing, but you weren't very specific on what "I am able to bring up a new msg window at any time" means. Setting some instance variables to whatever value doesn't explain the logic behind what it happening. Would you be able to post some code or explain a bit more in-depth?
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Heretic86

Interpreter command was tried because command_101 is an interpreter call, and what makes Multiple Windows work in the first place is the slight changes to command_101.

Spoiler: ShowHide
        # start multimessage if next line is "Show Text" starting with "\+"
        elsif @list[@index+1].code == 101
          if @list[@index+1].parameters[0][0..1]=="\\+"
            @multi_message = true
            @message_waiting = false
          end
        end


That is new to command_101

Modified MMW code

Spoiler: ShowHide
  #--------------------------------------------------------------------------
  # * Show Text
  #--------------------------------------------------------------------------
  def command_101
    # If other text has been set to message_text
    if $game_temp.message_text[@msgindex] != nil
      if @multi_message
        @msgindex += 1
        $scene.new_message_window(@msgindex)
      else
        # End
        return false
      end
    end
    @msgindex = 0 if !@multi_message
    @multi_message = false
    # Set message end waiting flag and callback
    @message_waiting = true
    # just adding indexes
    $game_temp.message_proc[@msgindex] = Proc.new { @message_waiting = false }
    # Set message text on first line
   
    #if not $game_temp.in_battle
      $game_temp.message_text[@msgindex] = @list[@index].parameters[0] + "\n"
    #else
    #end
    line_count = 1
    # Loop
    loop do
      # If next event command text is on the second line or after
      if @list[@index+1].code == 401
        # Add the second line or after to message_text
        # just adding index
        $game_temp.message_text[@msgindex]+=@list[@index+1].parameters[0]+"\n"
        line_count += 1
      # If event command is not on the second line or after
      else
        # If next event command is show choices
        if @list[@index+1].code == 102
          # If choices fit on screen
          if @list[@index+1].parameters[0].size <= 4 - line_count
            # Prevent the closure of a single window with multiple windows
            $game_temp.input_in_window = true           
            # Flag this window as having choices displayed for multi
            $scene.message_window[@msgindex].choice_window = @msgindex
            # Advance index
            @index += 1
            # Choices setup
            $game_temp.choice_start = line_count
            setup_choices(@list[@index].parameters)
          end
        # If next event command is input number
        elsif @list[@index+1].code == 103
          # If number input window fits on screen
          if line_count < 4
            # Prevent the closure of a single window with multiple windows
            $game_temp.input_in_window = true
            # Flag this window as having choices displayed
            $scene.message_window[@msgindex].choice_window = @msgindex
            # Advance index
            @index += 1
            # Number input setup
            $game_temp.num_input_start = line_count
            $game_temp.num_input_variable_id = @list[@index].parameters[0]
            $game_temp.num_input_digits_max = @list[@index].parameters[1]
            $game_temp.num_input_variable_id_backup =
              @list[@index].parameters[0]
          end
        # start multimessage if next line is "Show Text" starting with "\+"
        elsif @list[@index+1].code == 101
          if @list[@index+1].parameters[0][0..1]=="\\+"
            @multi_message = true
            @message_waiting = false
          end
        end
        # Continue
        return true
      end
      # Advance index
      @index += 1
    end
  end


Original code

Spoiler: ShowHide
  #--------------------------------------------------------------------------
  # * Show Text
  #--------------------------------------------------------------------------
  def command_101
    # If other text has been set to message_text
    if $game_temp.message_text != nil
      # End
      return false
    end
    # Set message end waiting flag and callback
    @message_waiting = true
    $game_temp.message_proc = Proc.new { @message_waiting = false }
    # Set message text on first line
    $game_temp.message_text = @list[@index].parameters[0] + "\n"
    line_count = 1
    # Loop
    loop do
      # If next event command text is on the second line or after
      if @list[@index+1].code == 401
        # Add the second line or after to message_text
        $game_temp.message_text += @list[@index+1].parameters[0] + "\n"
        line_count += 1
      # If event command is not on the second line or after
      else
        # If next event command is show choices
        if @list[@index+1].code == 102
          # If choices fit on screen
          if @list[@index+1].parameters[0].size <= 4 - line_count
            # Advance index
            @index += 1
            # Choices setup
            $game_temp.choice_start = line_count
            setup_choices(@list[@index].parameters)
          end
        # If next event command is input number
        elsif @list[@index+1].code == 103
          # If number input window fits on screen
          if line_count < 4
            # Advance index
            @index += 1
            # Number input setup
            $game_temp.num_input_start = line_count
            $game_temp.num_input_variable_id = @list[@index].parameters[0]
            $game_temp.num_input_digits_max = @list[@index].parameters[1]
          end
        end
        # Continue
        return true
      end
      # Advance index
      @index += 1
    end
  end



I didnt make any modifications to mess with @list.  That was already there.  What I was trying to do was add the same functionality at a different time.  Like I said, what I tried doesnt work, which seems to be because command_101 isnt called again at all, which is where Im stuck.  I dont really care how I do it, as long as I can get it to work!
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

ForeverZer0

You missed the point, but it don't matter, its your game.

What exactly does "$scene.new_message_window" do, and whats with the array of Procs for $game_temp.message_proc? I'm just failing to see what the end result of these modifications is accomplishing. It appears as if you are attempting to make a multiple-multiple message windows, as in trying to carry separate threads of logic instead of a single stream-lined one.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Heretic86

Honestly, not really sure.  99.9% of the stuff I didnt do, so no clue why it was done the way it was.  I've read through it, but not 100% certain why it was done this way.

  #--------------------------------------------------------------------------
  # * New Message Window Addition
  #--------------------------------------------------------------------------
  def new_message_window(index)
    if @message_window[index] != nil
      # clear message windows at and after this index
      last_index = @message_window.size - 1
      last_index.downto(index) do |i|
        if @message_window[i] != nil
          @message_window[i].dispose
          @message_window[i] = nil
        end
      end
      @message_window.compact!
    end
    new_message = Window_Message.new(index)
    @message_window.push(new_message)
  end


Thats not mine, and I didnt modify it either.  But you're right about the array.  It looks like what happens is it just takes the text from the next event entry with a 101 code (or 102, 3, or 4 for choices and number inputs and what not) and pushes it on to the array.  So I guess what I should be hoping for is to do the same thing.  Looking a bit deeper at @list during Scene_Battle, list still holds Map Event related stuff.  I think I need to access the next Battle Event from @page somehow maybe. 

Quickie on how to access that?
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

ForeverZer0

I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Heretic86

Okay, I got something happening.  No where near right yet, but its a step forward.  Thank you.  I'll mess with the rest later after I get some sleep and time to focus instead of 20 minutes here 15 minutes there.
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)