Death10 12 Posted December 19, 2011 (edited) Event Text Display Author: Ãص¹ (RGSS) Edited by Death10 (RGSS3) Introduction -Display text above Actor and Event Features -New nickname line -Can update in map Script Comment in Event Page: [ETDname][NNnickname] #============================================================================== # ** Event Text Display #============================================================================== # Author: Ãص¹ (RGSS) # Edited by Death10 (RGSS3) # http://itbinhdan.com #============================================================================== # Comment: [ETDname][NNnickname] #============================================================================== #============================================================================== # ** Game_Character #============================================================================== class Game_Character #-------------------------------------------------------------------------- # * Defaults # # ~ Default Player Display Options (Non-Case Sensitive): # 'Name', 'Nickname', 'Class', 'Level', 'Hp', 'Sp' #-------------------------------------------------------------------------- ETD_Default_EventText_Color = Color.new(255, 255, 255) ETD_Default_PlayerText_Color = Color.new(255, 255, 255) ETD_Default_EventText_Color2 = Color.new(255, 255, 255) ETD_Default_PlayerText_Color2 = Color.new(255, 255, 255) ETD_Default_PlayerText = 'name' ETD_Default_PlayerText2 = 'nickname' #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_accessor :etd_display_shadow_color attr_accessor :etd_display_color attr_accessor :etd_display_text attr_accessor :etd_display_shadow_color2 attr_accessor :etd_display_color2 attr_accessor :etd_display_text2 #-------------------------------------------------------------------------- # * Alias Listings #-------------------------------------------------------------------------- alias seph_etd_gmchr_init initialize #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize # Sets ETD Options @etd_display_color = self.is_a?(Game_Player) ? ETD_Default_PlayerText_Color : ETD_Default_EventText_Color @etd_display_color2 = self.is_a?(Game_Player) ? ETD_Default_PlayerText_Color2 : ETD_Default_EventText_Color2 # Original Initialization seph_etd_gmchr_init end end #============================================================================== # ** Game_Event #============================================================================== class Game_Event < Game_Character #-------------------------------------------------------------------------- # * Alias Listings #-------------------------------------------------------------------------- alias seph_etd_gmevt_refresh refresh #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh # Original Refresh Method seph_etd_gmevt_refresh # Erase ETD Display Text @etd_display_text = nil @etd_display_text2 = nil # Checks to see if display text unless @list.nil? || @erased for i in 0...@list.size if @list.code == 108 @list.parameters[0].dup.gsub!(/\[[Ee][Tt][Dd](.+?)\]/) do @etd_display_color = ETD_Default_EventText_Color @etd_display_text = $1 end if @list.code == 108 @list.parameters[0].dup.gsub!(/\[[Nn][Nn](.+?)\]/) do @etd_display_color2 = ETD_Default_EventText_Color2 @etd_display_text2 = $1 end end end end end end end #============================================================================== # ** Game_Player #============================================================================== class Game_Player < Game_Character #-------------------------------------------------------------------------- # * Alias Listings #-------------------------------------------------------------------------- alias seph_etd_gmplyr_refresh refresh alias etd_update update #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def etd # Gets First Actor actor = $game_party.members[0] # Determines Text case ETD_Default_PlayerText.dup.downcase when 'name' ; txt = actor.name when 'nickname' ; txt = actor.nickname when 'class' ; txt = actor.class.name when 'level' ; txt = "Level: #{actor.level}" when 'hp' ; txt = "HP: #{actor.hp} / #{actor.mhp}" when 'sp' ; txt = "SP: #{actor.sp} / #{actor.msp}" else ; txt = '' end # Determines Text case ETD_Default_PlayerText2.dup.downcase when 'name' ; txt2 = actor.name when 'nickname' ; txt2 = actor.nickname when 'class' ; txt2 = actor.class.name when 'level' ; txt2 = "Level: #{actor.level}" when 'hp' ; txt2 = "HP: #{actor.hp} / #{actor.mhp}" when 'sp' ; txt2 = "SP: #{actor.sp} / #{actor.msp}" else ; txt2 = '' end # Creates Text Display @etd_display_color = ETD_Default_PlayerText_Color @etd_display_text = txt @etd_display_color2 = ETD_Default_PlayerText_Color2 @etd_display_text2 = txt2 end def refresh seph_etd_gmplyr_refresh etd end def update etd_update etd end end #============================================================================== # ** Sprite_Character #============================================================================== class Sprite_Character < Sprite_Base #-------------------------------------------------------------------------- # * Alias Listings #-------------------------------------------------------------------------- if @seph_etd_spchr.nil? alias seph_etd_spchr_update update alias seph_etd_spchr_dispose dispose @seph_etd_spchr = true end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update # Original update Method seph_etd_spchr_update # Character Display Update Method update_display_text update_display_text2 end #-------------------------------------------------------------------------- # * Dispose #-------------------------------------------------------------------------- def dispose # Original Dispose seph_etd_spchr_dispose # Dispose ETD Sprite dispose_etd_sprite dispose_etd_sprite2 end #-------------------------------------------------------------------------- # * Dispose ETD Sprite #-------------------------------------------------------------------------- def dispose_etd_sprite # Dispose ETD Sprite unless @_etd_text_sprite.nil? @_etd_text_sprite.dispose @_etd_text_sprite = nil end end def dispose_etd_sprite2 # Dispose ETD Sprite unless @_etd_text_sprite2.nil? @_etd_text_sprite2.dispose @_etd_text_sprite2 = nil end end #-------------------------------------------------------------------------- # * Update Display Sprite #-------------------------------------------------------------------------- def update_display_text # If Character Has No ETD if @character.etd_display_text.nil? # Dispose ETD Sprite dispose_etd_sprite return end # If ETD Text Sprite Doesn't Exist if @_etd_text_sprite.nil? # Create ETD Text Sprite create_etd_sprite return end # If ETD Sprite Parameters Don't Match Characters unless @_etd_display_text == @character.etd_display_text && @_etd_display_color == @character.etd_display_color && @_etd_display_shadow_color == @character.etd_display_shadow_color # Dispose Sprite dispose_etd_sprite # Recreate Sprite create_etd_sprite end # Update ETD Sprite Position @_etd_text_sprite.x = self.x @_etd_text_sprite.y = self.y - self.oy / 2 - 41 end def update_display_text2 # If Character Has No ETD if @character.etd_display_text2.nil? # Dispose ETD Sprite dispose_etd_sprite2 return end # If ETD Text Sprite Doesn't Exist if @_etd_text_sprite2.nil? # Create ETD Text Sprite create_etd_sprite2 return end # If ETD Sprite Parameters Don't Match Characters unless @_etd_display_text2 == @character.etd_display_text2 && @_etd_display_color2 == @character.etd_display_color2 && @_etd_display_shadow_color2 == @character.etd_display_shadow_color2 # Dispose Sprite dispose_etd_sprite2 # Recreate Sprite create_etd_sprite2 end # Update ETD Sprite Position @_etd_text_sprite2.x = self.x @_etd_text_sprite2.y = self.y - self.oy / 2 - 24 end #-------------------------------------------------------------------------- # * Create ETD Sprite #-------------------------------------------------------------------------- def create_etd_sprite # Creates Display Bitmap bitmap = Bitmap.new(162, 40) # Draws ETD Display Text bitmap.font.color = @character.etd_display_color bitmap.font.size = 22 bitmap.draw_text(0, 0, 161, 40, @character.etd_display_text, 1) # Creates Display Text Sprite @_etd_text_sprite = Sprite.new(self.viewport) @_etd_text_sprite.bitmap = bitmap @_etd_text_sprite.ox = 80 @_etd_text_sprite.oy = 20 @_etd_text_sprite.x = self.x @_etd_text_sprite.y = self.y - self.oy / 2 - 41 @_etd_text_sprite.z = 3000 @_etd_text_sprite.visible = true # Saves ETD Text @_etd_display_text = @character.etd_display_text @_etd_display_color = @character.etd_display_color @_etd_display_shadow_color = @character.etd_display_shadow_color end def create_etd_sprite2 # Creates Display Bitmap bitmap2 = Bitmap.new(162, 40) # Draws ETD Display Text bitmap2.font.color = @character.etd_display_color2 bitmap2.font.size = 22 bitmap2.draw_text(0, 0, 161, 40, @character.etd_display_text2, 1) # Creates Display Text Sprite @_etd_text_sprite2 = Sprite.new(self.viewport) @_etd_text_sprite2.bitmap = bitmap2 @_etd_text_sprite2.ox = 80 @_etd_text_sprite2.oy = 20 @_etd_text_sprite2.x = self.x @_etd_text_sprite2.y = self.y - self.oy / 2 - 24 @_etd_text_sprite2.z = 3000 @_etd_text_sprite2.visible = true # Saves ETD Text @_etd_display_text2 = @character.etd_display_text2 @_etd_display_color2 = @character.etd_display_color2 @_etd_display_shadow_color2 = @character.etd_display_shadow_color2 end end Screenshot FAQ -Remove the game actor name and nickname: Change ETD_Default_PlayerText = 'name' ETD_Default_PlayerText2 = 'nickname' to ETD_Default_PlayerText = '' ETD_Default_PlayerText2 = '' Edited February 21, 2012 by Death10 4 sanggameboy, ShinGamix, EvilEagles and 1 other reacted to this Share this post Link to post Share on other sites
Fomar0153 121 Posted December 19, 2011 Interesting script, I can certainly see some uses for. Also if you put the script in [ code ][ /code ] tags (without the spaces) then the script will be better formatted. 2 Death10 and Maker Ron reacted to this Share this post Link to post Share on other sites
Jasonicus 62 Posted December 19, 2011 This could be very useful for a world map. Nice script. Share this post Link to post Share on other sites
Rosenblack 79 Posted December 19, 2011 *Added to the Master Script List* Share this post Link to post Share on other sites
Non ya 1 Posted February 8, 2012 nice script... how do u remove the actors name? i just want the events one on Share this post Link to post Share on other sites
ShinGamix 101 Posted February 8, 2012 @Death10 I want to use this just for the names on my map or events. How can I do that with his script? Share this post Link to post Share on other sites
Non ya 1 Posted February 21, 2012 Is there a switch to remove the game actors name on the map? I just want the events name to show on map Share this post Link to post Share on other sites
Death10 12 Posted February 21, 2012 (edited) Change ETD_Default_PlayerText = 'name' ETD_Default_PlayerText2 = 'nickname' to ETD_Default_PlayerText = '' ETD_Default_PlayerText2 = '' Edited February 21, 2012 by Death10 Share this post Link to post Share on other sites
Non ya 1 Posted February 21, 2012 thank you kind death Share this post Link to post Share on other sites
Shadow 6 Posted February 28, 2012 (edited) I want to make and Add-On to this scripts, simply can see variables, explaining myself: if I put [ETD\v[2]] and the \v[2]=4, the the char will show "4" without quotations EDIT: this give me a question... If the variable number 2, change the "4" for "8", the text will change inmediatly? if not, what can I do that? Edited February 28, 2012 by Shadow Share this post Link to post Share on other sites
Rinku 3 Posted April 9, 2012 Can you add the feature to add a border around the text that appears? Or a small window/hud. It'll make it easier for players to read and also improve its attractiveness. (Or can anyone tell me what I have to add to the script to achieve this?) Share this post Link to post Share on other sites
Rinku 3 Posted April 24, 2012 Bump, does anyone have a contact for Death? :@ Share this post Link to post Share on other sites
Lanechology 4 Posted April 24, 2012 (edited) Let me try to contact with Death, may he will respond your question as soon as if he can ~ @ Of course if i can ~_~ Edited April 24, 2012 by Lanechology Share this post Link to post Share on other sites
Death10 12 Posted April 24, 2012 I am too lazy to fix anything ~.~ Just ask someone else to fix it And the window/hud is too ugly for me to add it on (i can not see the map @.@) Sorry :-?? Share this post Link to post Share on other sites
Rinku 3 Posted April 24, 2012 So are you giving permission for someone else to do it? Share this post Link to post Share on other sites
Emerald 42 Posted April 24, 2012 If you can give me permission, I think I'll have a new version up by tomorrow. I've already finished most of it. Share this post Link to post Share on other sites
Death10 12 Posted April 25, 2012 Feel free 1 Maker Ron reacted to this Share this post Link to post Share on other sites
Rinku 3 Posted April 25, 2012 If you can give me permission, I think I'll have a new version up by tomorrow. I've already finished most of it. Is that with shadow's request alone :@ or mines too? Share this post Link to post Share on other sites
Emerald 42 Posted April 25, 2012 As of now, I've made a cleaner version of the original. What will further be included is: Backgrounds for the text Useful codes like \v[x] and \n[x] Support for changing font colors with \c[x] However, due several bug fixes I had to make and things I had already planned for today, the edited version will probably have to wait another day. Share this post Link to post Share on other sites
Rinku 3 Posted April 26, 2012 Alright, cool! I can wait Share this post Link to post Share on other sites
Ice Nick 3 Posted April 27, 2012 Would be cool as well if the event names showed up if the player was near it. For example a town with multiple exits, if you get close to the north exit the text appears reading "The Forest". Or something Share this post Link to post Share on other sites
Emerald 42 Posted April 27, 2012 (edited) VERSION 2 WITH A FEW BUGFIXES #============================================================================== # ** Event Text Display v2 #============================================================================== # Author: Ãص¹ (RGSS) # Edited by Death10 (RGSS3) # Edited by Emerald (v2) # # http://itbinhdan.com #------------------------------------------------------------------------------ # Instructions #------------------------------------------------------------------------------ # Create a new comment in an event with one of the following tags: # <ETD> - Upper line of text. # <NN> - Lower line of text. # <ETDB> - Background file. # Note that EVERYTHING in the comment is used for the text/filename if one of # the tags is present. # # Instructions for module ETD are above every constant. # In the text, the following stuff have a function: # # \\ - Becomes a singe '\'. # \V[x] - Becomes the value of variable with ID x. # \N[x] - Becomes the name of actor x. # \P[x] - Becomes the name of party member x. # \G - Displays current amount of gold. # \C[x] - Changes the font color to color x. Use -1 for STANDARD_COLOR. # # Actors and followers only: # \HP - Becomes own HP. # \MHP - Becomes own Max HP. # \MP - Becomes own MP. # \MMP - Becomes own max MP. # \L - Becomes own Level. #============================================================================ # # CONFIGURATION # #============================================================================ module ETD # An array containing fonts. If one the left one doesn't exist, the one to the # right will be used instead. Leave nil for the system fonts. STANDARD_FONT = nil # Red, Blue, Green, Opacity. Use \c[-1] for standard color. STANDARD_COLOR = Color.new(255,255,255,255) # Standard max distance for the name box to appear. Doesn't apply for the player # and followers. VIEW_DISTANCE = 3 # Text to display above actors. # actor_id => ["line_1", "line_2", "background filename"] # actor_id 0 is used for actors which IDs aren't present in the list. # If it's not the last entry to the list, add a comma after the ']'. ACTOR_TEXT = { 0 => ["", "", "Test Background"] } # Text to display above actors. # actor_id => ["line_1", "line_2", "background filename"] # actor_id 0 is used for actors which IDs aren't present in the list. # If it's not the last entry to the list, add a comma after the ']'. FOLLOWER_TEXT = { 0 => ["I'm a followah!", "", ""] } # Text to display above actors. # vehicle_type => ["line_1", "line_2", "background filename"] # vehicle type :all is used for vehicles which types aren't in the list. # If it's not the last entry to the list, add a comma after the ']'. VEHICLE_TEXT = { :all => ["", "", ""], :boat => ["", "", ""], :ship => ["", "", ""], :airship => ["", "", ""] } end #============================================================================== # Game_Vehicle #============================================================================== class Game_Vehicle attr_reader :type end #============================================================================== # Sprite_Character #============================================================================== class Sprite_Character < Sprite_Base alias eme_etd_init initialize def initialize(viewport, character = nil) @display_box = false @etd_max_distance = ETD::VIEW_DISTANCE eme_etd_init(viewport, character) end alias eme_etd_dispose dispose def dispose eme_etd_dispose @etd_text.dispose if @etd_text != nil @etd_background.dispose if @etd_background != nil end def init_etd_sprite @etd_text = Sprite.new @etd_text.bitmap = Bitmap.new(544, 32) @etd_text.bitmap.font.size = 16 @etd_text.z = 301 @etd_background = Sprite.new @etd_background.bitmap = Bitmap.new(1, 1) @etd_background.z = 300 end def init_etd_text @etd_text_1 = "" @etd_text_2 = "" @etd_text_back = "" @etd_max_distance = ETD::VIEW_DISTANCE if character.is_a?(Game_Event) for a in 0...character.list.size if character.list[a].code == 108 copy = character.list[a].parameters[0].upcase if copy.include?("<ETD>") @etd_text_1 = character.list[a].parameters[0].gsub(/<[Ee][Tt][Dd]>/) {""} elsif copy.include?("<NN>") @etd_text_2 = character.list[a].parameters[0].gsub(/<[Nn][Nn]>/) {""} elsif copy.include?("<ETDB>") @etd_text_back = character.list[a].parameters[0].gsub(/<[Ee][Tt][Dd][bb]>/) {""} end end end elsif character.is_a?(Game_Vehicle) if ETD::VEHICLE_TEXT.has_key?(character.type) @etd_text_1 = ETD::VEHICLE_TEXT[character.type][0] @etd_text_2 = ETD::VEHICLE_TEXT[character.type][1] @etd_text_back = ETD::VEHICLE_TEXT[character.type][2] else @etd_text_1 = ETD::VEHICLE_TEXT[:all][0] @etd_text_2 = ETD::VEHICLE_TEXT[:all][1] @etd_text_back = ETD::VEHICLE_TEXT[:all][2] end elsif character.is_a?(Game_Player) if ETD::ACTOR_TEXT.has_key?(character.actor.id) @etd_text_1 = ETD::ACTOR_TEXT[character.actor.id][0] @etd_text_2 = ETD::ACTOR_TEXT[character.actor.id][1] @etd_text_back = ETD::ACTOR_TEXT[character.actor.id][2] else @etd_text_1 = ETD::ACTOR_TEXT[0][0] @etd_text_2 = ETD::ACTOR_TEXT[0][1] @etd_text_back = ETD::ACTOR_TEXT[0][2] end elsif character.is_a?(Game_Follower) and character.actor != nil if ETD::FOLLOWER_TEXT.has_key?(character.actor.id) @etd_text_1 = ETD::FOLLOWER_TEXT[character.actor.id][0] @etd_text_2 = ETD::FOLLOWER_TEXT[character.actor.id][1] @etd_text_back = ETD::FOLLOWER_TEXT[character.actor.id][2] else @etd_text_1 = ETD::FOLLOWER_TEXT[0][0] @etd_text_2 = ETD::FOLLOWER_TEXT[0][1] @etd_text_back = ETD::FOLLOWER_TEXT[0][2] end end end def refresh_etd_sprite @etd_text.bitmap.clear create_etd_background etd_display_text(@etd_text_1, 0) etd_display_text(@etd_text_2, 14) end def create_etd_text init_etd_sprite if @etd_text == nil temporare_1, temporare_2, temporare_3 = @etd_text_1, @etd_text_2, @etd_text_back init_etd_text refresh_etd_sprite if temporare_1 != @etd_text_1 or temporare_2 != @etd_text_2 or temporare_3 != @etd_text_back @etd_text.x = self.x - 272 @etd_text.y = self.y - self.height - 32 @etd_background.x = @etd_text.x + @etd_text.width / 2 - @etd_background.width / 2 @etd_background.y = @etd_text.y + @etd_text.height / 2 - @etd_background.height / 2 end def create_etd_background @etd_background.bitmap.clear @etd_background.bitmap = Cache.system(@etd_text_back) end def etd_display_text(string, y) init_etd_sprite if @etd_text == nil string = convert_escape_characters(string) string = extra_convert(string) if character.is_a?(Game_Player) or character.is_a?(Game_Follower) temporare = string.to_s.clone temporare.gsub!(/\eC\[(\d+)\]/i) { "" } @x_pos = 272 - @etd_text.bitmap.text_size(temporare).width / 2 @etd_text.bitmap.font.color.set(ETD::STANDARD_COLOR) @etd_text.bitmap.font.name = ETD::STANDARD_FONT if ETD::STANDARD_FONT != nil process_character(string.slice!(0, 1), string, y) until string.empty? end def text_color(n) return ETD::STANDARD_COLOR if n == -1 Cache.system("Window").get_pixel(64 + (n % 8) * 8, 96 + (n / 8) * 8) end def convert_escape_characters(text) result = text.to_s.clone result.gsub!(/\\/) { "\e" } result.gsub!(/\e\e/) { "\\" } result.gsub!(/\eV\[(\d+)\]/i) { $game_variables[$1.to_i] } result.gsub!(/\eN\[(\d+)\]/i) { actor_name($1.to_i) } result.gsub!(/\eP\[(\d+)\]/i) { party_member_name($1.to_i) } result.gsub!(/\eG/i) { Vocab::currency_unit } result end def extra_convert(text) result = text.to_s.clone result.gsub!(/\eH\eP/i) { character.actor.hp } result.gsub!(/\eM\eH\eP/i) { character.actor.maxhp } result.gsub!(/\eM\eP/i) { character.actor.mp } result.gsub!(/\eM\eM\eP/i) { character.actor.maxmp } result.gsub!(/\eL/i) { character.actor.level } result end def process_character(c, text, y) case c when "\e" code = text.slice!(/^[\$\.\|\^!><\{\}\\]|^[A-Z]+/i) case code.upcase when 'C' param = text.slice!(/^\[\d+\]/)[/\d+/].to_i rescue -1 @etd_text.bitmap.font.color.set(text_color(param)) end else process_normal_character(c, y) end end def process_normal_character(c, y) text_width = @etd_text.bitmap.text_size(c) .width @etd_text.bitmap.draw_text(@x_pos, y, text_width * 2, 16, c, 1) @x_pos += text_width end alias eme_etd_update update def update eme_etd_update create_etd_text if @display_box create_etd_text unless character.is_a?(Game_Event) or character.is_a?(Game_Vehicle) distance_check if character.is_a?(Game_Event) or character.is_a?(Game_Vehicle) end def distance_check player_x = $game_player.x; own_x = self.x / 32 + 1; dif_x = own_x - player_x dif_x *= -1 if dif_x < 0 if dif_x > @etd_max_distance etd_hide_box else player_y = $game_player.y; own_y = self.y / 32 + 1; dif_y = own_y - player_y dif_y *= -1 if dif_y < 0 if dif_y > @etd_max_distance etd_hide_box else if !@display_box and @etd_text != nil @etd_text.opacity = 255 if @etd_text != nil @etd_background.opacity = 255 if @etd_background != nil $game_variables[1] = @etd_text_back if character.id == 2 end @display_box = true end end end def etd_hide_box if @display_box @etd_text.opacity = 0 if @etd_text != nil @etd_background.opacity = 0 if @etd_background != nil @display_box = false end end end All requests included. Script works slightly different than the previous one. Edited April 29, 2012 by Emerald 3 Death10, Fallun and Lanechology reacted to this Share this post Link to post Share on other sites
Rinku 3 Posted April 27, 2012 Hmm, syntax error on line 73 Unexpected tSYMBEG, expecting '}' :boat => ["", "", ""] (I tried putting words within the quotes, then replacing them with nil and then removing the boat vehicle's starting position I had on another map; same error) Share this post Link to post Share on other sites