Change the Text Color in the Script Call command

Good afternoon everyone.

I believe this is the right place now.

Based on this topic: https://forums.rpgmakerweb.com/inde...via-script-call-on-event.172078/#post-1538650,

I'd like to know if you programming wizards could create a code or script that would allow changing the text color of commands:
$game_map.show_text($game_player,message)
$game_map.show_text($game_map.events[1],message)
,

unfortunately the Maker standard only allows the color white, which is the default.
Normally, text color changes occur within the dialog box, using the code "\c[]". But this snippet cannot be inserted within a script call command; like:$game_map.show_text($game_player,\c[2]30) or $game_map.show_text($game_player,\c[2]"30"), errors occur.

I imagine a small script that can change the settings of: Game_Message, Window_Message, or Game_Interpreter that should be enough. Maybe even a small edit to the original script.

I would be grateful to anyone who can help.
I don't remember what script this was for, All I can find is SAS IV that uses show_text in Game_Map
The command makes a damage popup under Sprite_Damage
The class does not have any processing for escape codes.
It also draws the text as a bitmap.
So the easiest method to use a different colour would be to add more colour options to the damage sprites script.
So if you are using SAS IV Damage Sprites then
something like this.
Ruby:
module Damage_Core
  Damage_Font = "Georgia"
  Damage_Size = 22
  Damage_Italic = false
  Damage_Bold = true
  Damage_Color = [Color.new(255,255,255), Color.new(255,0,0), Color.new(0,255,0)]
  Damage_Level = true
  Damage_LString = "Level up!"
end
class Sprite_Damage < Sprite
  attr_accessor :done
  include Damage_Core
  def initialize(target,value,opt=0)
    super(nil)
    @value = value.to_s
    self.bitmap = Bitmap.new(160,20)
    self.bitmap.font.name = Damage_Font
    self.bitmap.font.size = Damage_Size
    self.bitmap.font.bold = Damage_Bold
    self.bitmap.font.italic = Damage_Italic
    self.bitmap.font.color = Damage_Color[opt]
    self.bitmap.draw_text(0,0,160,20,@value,1)
    self.x = target.screen_x
    self.y = target.screen_y
    self.ox = 50
    self.oy = 50
    side = (rand(2) == 0 ? 1 : -1)
    @x_speed = (rand(2)+1)*side
    @y_speed = 6
    @g_force = -0.5
    @erase = false
  end
end

The initialize method is changed to have an option value.
So the new command would be
$game_map.show_text($game_player,"30",2)
and it will use the colour (0,255,0)

If you are not using this script, then what script is it?
I don't see show_text in the default scripts
I don't remember what script this was for, All I can find is SAS IV that uses show_text in Game_Map
The command makes a damage popup under Sprite_Damage
The class does not have any processing for escape codes.
It also draws the text as a bitmap.
So the easiest method to use a different colour would be to add more colour options to the damage sprites script.
So if you are using SAS IV Damage Sprites then
something like this.
Ruby:
module Damage_Core
  Damage_Font = "Georgia"
  Damage_Size = 22
  Damage_Italic = false
  Damage_Bold = true
  Damage_Color = [Color.new(255,255,255), Color.new(255,0,0), Color.new(0,255,0)]
  Damage_Level = true
  Damage_LString = "Level up!"
end
class Sprite_Damage < Sprite
  attr_accessor :done
  include Damage_Core
  def initialize(target,value,opt=0)
    super(nil)
    @value = value.to_s
    self.bitmap = Bitmap.new(160,20)
    self.bitmap.font.name = Damage_Font
    self.bitmap.font.size = Damage_Size
    self.bitmap.font.bold = Damage_Bold
    self.bitmap.font.italic = Damage_Italic
    self.bitmap.font.color = Damage_Color[opt]
    self.bitmap.draw_text(0,0,160,20,@value,1)
    self.x = target.screen_x
    self.y = target.screen_y
    self.ox = 50
    self.oy = 50
    side = (rand(2) == 0 ? 1 : -1)
    @x_speed = (rand(2)+1)*side
    @y_speed = 6
    @g_force = -0.5
    @erase = false
  end
end

The initialize method is changed to have an option value.
So the new command would be
$game_map.show_text($game_player,"30",2)
and it will use the colour (0,255,0)

If you are not using this script, then what script is it?
I don't see show_text in the default scripts
Good morning, Roninator.
Thank you for your reply.

You're correct, it's Khas's script. I didn't know that this message command was exclusive to it; I thought it was a maker standard. Good to know.

To get straight to the point, the new attempts resulted in new errors.
Using the same code you pointed out, $game_map.show_text($game_player,"30",2), the following error appears (image on the left). If I use the same code but with " ' ", like '$game_map.show_text($game_player,"30",2)' , nothing happens: no error, nor any message appears, nothing.

And if I use this command:
"message = "11 xp"
$game_map.show_text($game_player,message)
", (without "")
this is the error that appears(image on the right):

The attempts were made directly in the SASIV demo; I did not use my project with the other scripts.
All I did was replace
Ruby:
module Damage_Core
  # Nome da fonte
  Damage_Font = "Georgia"
  # Tamanho da fonte
  Damage_Size = 22
  # Itálico?
  Damage_Italic = false
  # Negrito?
  Damage_Bold = true
  # Cor - Color.new(red, green, blue)
  Damage_Color = Color.new(255,255,255)
  # Mostrar novo nível?
  Damage_Level = true
  # String de novo nível
  Damage_LString = "Level up!"
end

of the respective class, for
Ruby:
module Damage_Core
  Damage_Font = "Georgia"
  Damage_Size = 22
  Damage_Italic = false
  Damage_Bold = true
  Damage_Color = [Color.new(255,255,255), Color.new(255,0,0), Color.new(0,255,0)]
  Damage_Level = true
  Damage_LString = "Level up!"
end
class Sprite_Damage < Sprite
  attr_accessor :done
  include Damage_Core
  def initialize(target,value,opt=0)
    super(nil)
    @value = value.to_s
    self.bitmap = Bitmap.new(160,20)
    self.bitmap.font.name = Damage_Font
    self.bitmap.font.size = Damage_Size
    self.bitmap.font.bold = Damage_Bold
    self.bitmap.font.italic = Damage_Italic
    self.bitmap.font.color = Damage_Color[opt]
    self.bitmap.draw_text(0,0,160,20,@value,1)
    self.x = target.screen_x
    self.y = target.screen_y
    self.ox = 50
    self.oy = 50
    side = (rand(2) == 0 ? 1 : -1)
    @x_speed = (rand(2)+1)*side
    @y_speed = 6
    @g_force = -0.5
    @erase = false
  end
end

as you instructed.

Sorry, I confess I thought it would be easier.
To get straight to the point, the new attempts resulted in new errors.
Apologies, I did not test the code, I made an assumption that it would work like that.
I will try to take some time to try some things out and see how it can be done.
All I did was replace
I did not want you to replace the code. It should be a new entry below the script.
turns out I just missed the one method.
Ruby:
module Damage_Core
  Damage_Font = "Georgia"
  Damage_Size = 22
  Damage_Italic = false
  Damage_Bold = true
  Damage_Color = [Color.new(255,255,255), Color.new(255,0,0), Color.new(0,255,0)]
  Damage_Level = true
  Damage_LString = "Level up!"
end
class Sprite_Damage < Sprite
  attr_accessor :done
  include Damage_Core
  def initialize(target,value,opt=0)
    super(nil)
    @value = value.to_s
    self.bitmap = Bitmap.new(160,20)
    self.bitmap.font.name = Damage_Font
    self.bitmap.font.size = Damage_Size
    self.bitmap.font.bold = Damage_Bold
    self.bitmap.font.italic = Damage_Italic
    self.bitmap.font.color = Damage_Color[opt]
    self.bitmap.draw_text(0,0,160,20,@value,1)
    self.x = target.screen_x
    self.y = target.screen_y
    self.ox = 50
    self.oy = 50
    side = (rand(2) == 0 ? 1 : -1)
    @x_speed = (rand(2)+1)*side
    @y_speed = 6
    @g_force = -0.5
    @erase = false
  end
end
class Game_Map
  def show_text(target,value,opt=0)
    @damage_sprites << Sprite_Damage.new(target,value,opt)
  end
end
then $game_map.show_text($game_player,"30",2) works
or $game_map.show_text($game_map.events[5],"30",2)
I did not want you to replace the code. It should be a new entry below the script.
turns out I just missed the one method.
Ruby:
module Damage_Core
  Damage_Font = "Georgia"
  Damage_Size = 22
  Damage_Italic = false
  Damage_Bold = true
  Damage_Color = [Color.new(255,255,255), Color.new(255,0,0), Color.new(0,255,0)]
  Damage_Level = true
  Damage_LString = "Level up!"
end
class Sprite_Damage < Sprite
  attr_accessor :done
  include Damage_Core
  def initialize(target,value,opt)
    super(nil)
    @value = value.to_s
    self.bitmap = Bitmap.new(160,20)
    self.bitmap.font.name = Damage_Font
    self.bitmap.font.size = Damage_Size
    self.bitmap.font.bold = Damage_Bold
    self.bitmap.font.italic = Damage_Italic
    self.bitmap.font.color = Damage_Color[opt]
    self.bitmap.draw_text(0,0,160,20,@value,1)
    self.x = target.screen_x
    self.y = target.screen_y
    self.ox = 50
    self.oy = 50
    side = (rand(2) == 0 ? 1 : -1)
    @x_speed = (rand(2)+1)*side
    @y_speed = 6
    @g_force = -0.5
    @erase = false
  end
end
class Game_Map
  def show_text(target,value,opt=0)
    @damage_sprites << Sprite_Damage.new(target,value,opt)
  end
end
then $game_map.show_text($game_player,"30",2) works
or $game_map.show_text($game_map.events[5],"30",2)
Ah yes, it wasn't clear to me that I was supposed to make a new insertion.

"$game_map.show_text($game_player,"30",2)" works like a charm!
But "$game_map.show_text($game_map.events[5],"30",2)" doesn't. The error seems to be due to the code "breaking" when it ends up with two lines. That's just my layman's impression.
In the image on the right, see how the layout looks in the command; the code is extensive, which is why it ends up being two lines. I know it's because of some small detail that the maker isn't understanding the code.

Thank you, Roninator!
The error seems to be due to the code "breaking" when it ends up with two lines.
has to be your version of the program. I heard some languages have a slightly different version which causes issues, or your using a cracked copy.
My Khas demo works fine.
Spoiler: images
1764865805035.png

1764865815878.png

long message.png
has to be your version of the program. I heard some languages have a slightly different version which causes issues, or your using a cracked copy.
My Khas demo works fine.
You're right, I tested it on the Steam version and it worked normally. I use the cracked version because it's much lighter than the Steam version.

Thanks for the help! If you think this topic should be placed in the scripts section for Ace, as an "add-on" for Sapphire Action, feel free.

By the way, how can I send you a message? Your profile isn't accessible to me.
By the way, how can I send you a message? Your profile isn't accessible to me.
I think you need to be a member long enough to have a certain number of messages to be able to contact people. It's in the forum rules somewhere
I think you need to be a member long enough to have a certain number of messages to be able to contact people. It's in the forum rules somewhere
Could you contact me by sending a message? It's about a job offer related to this script.

Original thread: https://forums.rpgmakerweb.com/threads/change-the-text-color-in-the-script-call-command.181271/