Changing a name in every message box

Started by MarkHest, April 10, 2013, 09:52:23 pm

Previous topic - Next topic

MarkHest

April 10, 2013, 09:52:23 pm Last Edit: April 10, 2013, 10:14:32 pm by MarkHest
I know it's possible since F0 have done it for me before. What I need is a script that looks through every message box that I've made and change the name/word Elna to Alyssa.
Note that Elna is often written as Elna: I hope that's not a problem.
   

BetaGod

Uhmmm... I would use any message system that allows you to call a characters's name into a text box. Then i'll just create a new character named Alysa and use that function. The character per se will not be used, as him/her is just a dummy variable.

Something like this:

TEXT BOX SAMPLE:
Quote"¡Hey /n[2]! How are you today?"


Where 2 is the actor number of that brand new dummy character. As the game passes by, lets say you need that word ("Alysa") replaced with, for example, the word "Mike". Then i would use the Change Actor Name function and change the character 2 name with the desired name. This will replace the name in every text box that you ever created as long as it contains the "/[2]" function.

This is rough and quite lame, but i just share it in case of nobody else replies  :D
I am a god in BETA status and therefore, i may contain bugs and such.

Zexion

I think mark means replacing it without editing all the existing text boxes. Seeing as how his game is probably 50+ maps it would be tedious to have to look through each event for text boxes.

BetaGod

Then my option, although lame, is still usefull.

I think i did not explained myself in the right way.

Lets say you create a text box in MAP001 with the following text:

Quote"Hello there, /n[2]"


35 maps later, you need that word to be changed with X. Then you use the Change Actor Name command in any event with the desired word.

The "/n[2]" in the text box placed in MAP001 will change accordingly since it is a dynamic variable.

We are asuming, of course, that he will use a custom message system that allows him to use the "/n[]" function to display the name of actor number 2.
I am a god in BETA status and therefore, i may contain bugs and such.

KK20

April 10, 2013, 10:28:31 pm #4 Last Edit: April 10, 2013, 10:42:08 pm by KK20
Zexion is right. I remember seeing that post before so I will search for it.

EDIT: Found it. And editted.

# Define the input and output strings.
INPUT = "Elna"
OUTPUT = "Alyssa"

#===============================================================================
count = 0
Dir.entries('Data').each {|filename|
  if filename =~ /Map[\d]+\.rxdata/
    changed = false
    map = load_data("Data/#{filename}")
    map.events.each_key {|key|
      event = map.events[key]
      event.pages.each_index {|i|
        page = event.pages[i]
        page.list.each_index {|j|
          cmd = page.list[j]
          next unless [101, 401].include?(cmd.code)
          if event.pages[i].list[j].parameters[0].include?(INPUT)
            count += 1
            event.pages[i].list[j].parameters[0].gsub!(INPUT) { OUTPUT }
            map.events[key] = event
            changed = true
          end
        }
      }
      if changed
        File.open("Data/#{filename}", 'wb') {|file| Marshal.dump(map, file) }
      end
    }
  end
}
if count == 0
  print "No event script calls found with matching string."
else
  print "Found and replaced #{count} occurences of input string.\n" +
    "Make sure to close and reload your project in order for the effects " +
    "take place. DO NOT SAVE THE GAME when closing or nothing will change."
end
exit

Changes went from this:
QuoteElna. elna Elna: belna bElna BELNA

to
QuoteAlyssa. elna Alyssa: belna bAlyssa BELNA

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

MarkHest

@BetaGod: Uhm. I have over 150Maps and Elna is one of my main characters so going through every map and change every text box to /n[2] would be pretty darn exhausting. Plus I prefer to use the "name" instead of actor number so I can easily keep track of what's actually happening in the text boxes. Just adding numbers instead of names would confuse the hell out of me.
   

BetaGod

I am a god in BETA status and therefore, i may contain bugs and such.

MarkHest