Chaos Project

RPG Maker => RPG Maker Scripts => Script Requests => Topic started by: MarkHest on April 10, 2013, 09:52:23 pm

Title: Changing a name in every message box
Post by: MarkHest on April 10, 2013, 09:52:23 pm
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.
Title: Re: Changing a name in every message box
Post by: BetaGod on April 10, 2013, 10:16:19 pm
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
Title: Re: Changing a name in every message box
Post by: Zexion on April 10, 2013, 10:20:35 pm
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.
Title: Re: Changing a name in every message box
Post by: BetaGod on April 10, 2013, 10:25:38 pm
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.
Title: Re: Changing a name in every message box
Post by: KK20 on April 10, 2013, 10:28:31 pm
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
Title: Re: Changing a name in every message box
Post by: MarkHest on April 10, 2013, 10:40:42 pm
@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.
Title: Re: Changing a name in every message box
Post by: BetaGod on April 10, 2013, 10:44:17 pm
Well that works much better!  :D
Title: Re: Changing a name in every message box
Post by: MarkHest on April 10, 2013, 10:51:13 pm
That worked perfectly. Thank you :)