Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Italics

Can anyone help me with italics on RPGXP. I want some of the text boxes to come up with the text in italics. Is there anything that I can do to make this happen. Something like the \N[01] that you put in the textbox to have the name of that character to appear. Is there anything like that I can use to enable italics for a portion of the text?
 

Zeriab

Sponsor

The easiest way is by far to search for a custom message system which supports it. (I believe Dubealex's AMS and Ccoa's UMS supports it for example)

Since you have posted this under tutorials I will tell you how you can create say \I which toggles italics on and off. (Like a light switch telling whether to write the text in italics or not)

You have to edit Window_Message in the script editor since that deals with showing the messages.
To do this you have to open the script editor either by clicking on F11 from the map editor or Tools->Script Editor...
On the left hand side you see:
Game_Temp
Game_System
Game_Switches
...

Scroll down and find Window_Message
Click on the section when you find it.
On the right-hand side you now see code for the Window_Message section.
The processing of the text resides in the refresh method (def refresh) and is what you should scroll down to.
Scroll down until you find this section: (Around line 89)
[rgss]      # Change "\\C" to "\001" and "\\G" to "\002"
      text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
      text.gsub!(/\\[Gg]/) { "\002" }
[/rgss]
Let us just follow the way they do it and try to change "\\I" to "\003". The reason for "\\I" and not "\I" is that when you enter \I in a message it is internally stored as "\\I" because \ has a special meaning.
Let's insert this after that section:
[rgss]      text.gsub!(/\\[Ii]/) { "\003" }
[/rgss]
That part should now look as:
[rgss]      # Change "\\C" to "\001", "\\G" to "\002" and "\\I" to "\003"
      text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
      text.gsub!(/\\[Gg]/) { "\002" }
      text.gsub!(/\\[Ii]/) { "\003" }
      # Get 1 text character in c (loop until unable to get text)
[/rgss]
Note that /\\[Ii]/ will convert both \I and \i.

Now to around line 128 and insert this code:
[rgss]        # If \I
        if c == "\003"
          self.contents.font.italic = !self.contents.font.italic
        end
[/rgss]

The section should now look like this:
[rgss]          # go to next text
          next
        end
        # If \I
        if c == "\003"
          self.contents.font.italic = !self.contents.font.italic
        end
        # If new line text
        if c == "\n"
[/rgss]
Notice the c == "\003" which is exactly what we converted the \I and \i to. You can also look above that it's "\002" for \G and \g.
self.contents.font.italic is true if the text is drawn as italics and false if the text is not drawn as italics
!self.contents.font.italic is false if the text is drawn as italics and true if the text is not drawn as italics
self.contents.font.italic = !self.contents.font.italic means that future text will be drawn as italics if it is not currently drawn and that future text will not be drawn as italics if it is currently drawn as italics.

It should now work and you can test it out.
You may notice that if you turn on the italics, but does not turn it off again in the same message, then other messages will be affected.
If you do not want this behavior then 70 and insert self.contents.font.italic = Font.default_italic so the section comes to look like this:
[rgss]    self.contents.clear
    self.contents.font.color = normal_color
    self.contents.font.italic = Font.default_italic
    x = y = 0
[/rgss]

*hugs*
- Zeriab
 
Zeriab":2u411uuh said:
The easiest way is by far to search for a custom message system which supports it. (I believe Dubealex's AMS and Ccoa's UMS supports it for example)
AMS does not have commands for Italics and bolds, although it's not hard to add them.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top