Error with Universal Message System after a Battle (RPG Maker XP)

AveyondFan

Veteran
Veteran
Joined
Sep 19, 2018
Messages
33
Reaction score
1
First Language
English
Primarily Uses
RMXP
This involves Ccoa's Universal Message System.
After battles, I get the "NoMethodError" error message. I've split up the code into six parts for easier use, but I know where the line in the code is in the one page script you get from the download: 1214. I don't know what is causing this error to occur. The code reads as follows
if $game_system.face_graphic != "" and ($game_system.face_graphic_position == CENTER or $game_system.face_graphic_position == BOTTOM) width += @face.bitmap.width if height < @face.bitmap.height height = @face.bitmap.height - 32 end end
This error only happens when I am attempting to use a face, and it only ever happens after a battle. If a message without a face comes up, it's fine, and the faces work fine before a battle, but once the battle is finished and the game attempts to bring up the dialogue box with the face, the error occurs. This also happened when I replaced my split up version for the single version of the script.
I'm at a loss as to what is causing this error. Can anyone help me fix this or point me to what's causing the issue?
This is the link to where you can get the script, by the way: Universal Message System
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,486
Reaction score
14,818
First Language
English
Primarily Uses
RMMV

I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.



Which line is the one that gives the error, and what is the full text of the error message?

Is it ANY face? Is it ANY battle?

What other scripts do you have? If you create a brand new game and JUST have the UMS script, do you get the same issue?
 

AveyondFan

Veteran
Veteran
Joined
Sep 19, 2018
Messages
33
Reaction score
1
First Language
English
Primarily Uses
RMXP
The full error message is: Script 'UMS 3 Windows_Selectable' line 393: NoMethodError occured undefined method 'width' for nil:NilClass

In the single page version of UMS, this would be line 2936 (upon further inspection, there is a near identical line to this further up near the top of the script, but this is the line that is causing me grief at the moment)

The thing that's weird is I've tried every other way to cause this error message to occur, taking your advice and testing it in another game, testing it after battles, and the only way to get it to appear is through going through the entire cutscene this is a part of, both in this game and in a new test game.

I really don't know how to explain this in text. It's the weirdest thing. It's not the commands used, it's not the face, it's not the battle, it's the cutscene, and that baffles me. Outside of the cutscene - whether it's in a common event or in the thing you press to call the commands - I have not been able to replicate it, which is extremely annoying as I want this introduction to be a sort of battle tutorial of sorts.

Edit: To clarify, it does have something to do with the battle, because when I skip the battle using lables, everything works fine.
 
Last edited:

KK20

Just some XP Scripter
Veteran
Joined
Oct 11, 2018
Messages
365
Reaction score
141
First Language
English
Primarily Uses
RMXP
Well can you share how you're handling your cutscene then? If that's the only way you can reproduce it, no one else can help you.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,486
Reaction score
14,818
First Language
English
Primarily Uses
RMMV
The error is saying there is no bitmap for that face.

How have you defined your faces? Is it possible you haven't set it up properly, or that something in the battle has cleared it?

If you have a message window with a face prior to battle, then a message window with the same face after battle, does it work for the first one and crash for the second?

It's obviously something about your cutscene battle that is resetting something in the script.
 

AveyondFan

Veteran
Veteran
Joined
Sep 19, 2018
Messages
33
Reaction score
1
First Language
English
Primarily Uses
RMXP
The error is saying there is no bitmap for that face.

How have you defined your faces? Is it possible you haven't set it up properly, or that something in the battle has cleared it?

If you have a message window with a face prior to battle, then a message window with the same face after battle, does it work for the first one and crash for the second?

It's obviously something about your cutscene battle that is resetting something in the script.
As I'm doing further testing, forgive my ignorance, what's a bitmap?
 

AveyondFan

Veteran
Veteran
Joined
Sep 19, 2018
Messages
33
Reaction score
1
First Language
English
Primarily Uses
RMXP
An update...
Having a face in a message before the fight fixes it, but this brings me no closer to understanding how or why having no face before the fight caused an issue, and that's my main question now.
 

KK20

Just some XP Scripter
Veteran
Joined
Oct 11, 2018
Messages
365
Reaction score
141
First Language
English
Primarily Uses
RMXP
It's an inherent bug with the script when using ums_mode FIT_TEXT_TO_WINDOW in combination with the \face message code.

This can be reproduced by having $game_system.face_graphic as an empty string and reinitializing Scene_Map (i.e. go into menu or battle and return to map). Immediately run a "Show Text" with some \face[your_graphic] in it.

The reason can be explained with a combination of this:
Code:
def reset_window(change_opacity = true)
...
      # face stuff
      if $game_system.face_graphic != ""
        # the player has chosen to show a face graphic
        if @done and $game_system.resting_face != ""
          @face.bitmap = RPG::Cache.picture($game_system.face_graphic + $game_system.resting_face)
          if @face_frame * $game_system.face_frame_width >= @face.bitmap.width
            @face_frame = 0
          end
        else
          @face.bitmap = RPG::Cache.picture($game_system.face_graphic)
        end
and
Code:
def refresh
...
      @text.gsub!(/\\[Ff][Aa][Cc][Ee]\[(.*?)\]/) do
        $game_system.face_graphic = $1.to_s
        if $1.to_s == ""
          @face.opacity = 0
        end
        ""
      end
...
      # Resize the window to fit the contents?
      if $game_system.ums_mode == FIT_WINDOW_TO_TEXT
        # ... code omitted here for brevity ...

        if $game_system.face_graphic != "" and ($game_system.face_graphic_position == CENTER or $game_system.face_graphic_position == BOTTOM)
          width += @face.bitmap.width
          if height < @face.bitmap.height
            height = @face.bitmap.height - 32
          end
        end

reset_window is what creates the face's bitmap, but only if $game_system.face_graphic is not an empty string. reset_window is (mostly?) called at least once in refresh prior to the gsub! for "face". Unfortunately, there is no call to it anywhere in between the gsub! and the call to the face.bitmap.width.

Whenever you switch scenes from Scene_Map, the face sprite gets disposed. When you go back to Scene_Map, it gets reinitialized again with a nil'd bitmap.

We use the \face code, thereby setting $game_system.face_graphic to some non-empty string, but we never make the call again to reset_window to initialize the bitmap. However, if you set $game_system.face_graphic in a script call prior to the "Show Text", reset_window will pick up the change and initialize it in time.

Thus the solution I suggest is to make the call to reset_window after setting the \face, like so:
Code:
      @text.gsub!(/\\[Ff][Aa][Cc][Ee]\[(.*?)\]/) do
        $game_system.face_graphic = $1.to_s
        if $1.to_s == ""
          @face.opacity = 0
        end
        reset_window
        ""
      end
 

Latest Threads

Latest Posts

Latest Profile Posts

Create MiniMaps, Sprites for MV Enemies, & Aethereal Plane Battlebacks | RPG Maker News #74

Vtubers Vs MOTHER.png

This might be my next project. You like it?
I'm off to search the master script list for my skill issue. HOORAY! FUN!
Fun fact: Digimon is an isekai :kaoswt2:
The problem with being a perfectionist is that you are never done with something.

Forum statistics

Threads
112,326
Messages
1,067,402
Members
145,963
Latest member
Nekonix
Top