Changing Message Box Messages

Started by MarkHest, October 28, 2014, 04:20:24 pm

Previous topic - Next topic

MarkHest

October 28, 2014, 04:20:24 pm Last Edit: October 28, 2014, 04:22:18 pm by MarkHest
I was given this script a while ago to change the word specified in the script to another word of EVERY message box in the editor.
Here is the script:


# 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



I want to request a similar script or maybe just an edit that changes every ":" sign letter to ":\b" and also puts "\b" in the start of the message box.

So this message box:
Quote
Eilzie: This is a random message box.


should change to:
Quote
\bEilzie:\b This is a random message box.


It'll look like this in game:
Quote
Eilzie: This is a random message box.
   

Wecoc

October 29, 2014, 07:43:40 pm #1 Last Edit: October 29, 2014, 07:45:20 pm by Wecoc
Save a copy of your game before using this.
This kind of codes can be highly destructive.


#===============================================================================
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 cmd.code == 101
         count += 1
         event.pages[i].list[j].parameters[0].insert(0, "\\b")
         if event.pages[i].list[j].parameters[0].include?(":")
           event.pages[i].list[j].parameters[0].gsub!(":") { ":\\b" }
           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

MarkHest

November 05, 2014, 07:59:13 pm #2 Last Edit: November 07, 2014, 04:11:02 am by MarkHest
Oh thank you! :) I'll try it out later when I can
   

MarkHest

I tried it out but I can't figure out how to make it work. It always states the script is hangning.
   

G_G

Try this mark, it's because theres way too many maps/events. If the game doesn't get a graphics update every so often, it'll assume a script is hanging.
#===============================================================================
count = 0
Dir.entries('Data').each {|filename|
  Graphics.update
  if filename =~ /Map[\d]+\.rxdata/
    changed = false
    map = load_data("Data/#{filename}")
    map.events.each_key {|key|
  Graphics.update
      event = map.events[key]
      event.pages.each_index {|i|
    Graphics.update
        page = event.pages[i]
        page.list.each_index {|j|
          cmd = page.list[j]
          next unless cmd.code == 101
          count += 1
          event.pages[i].list[j].parameters[0].insert(0, "\\b")
          if event.pages[i].list[j].parameters[0].include?(":")
            event.pages[i].list[j].parameters[0].gsub!(":") { ":\\b" }
            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

MarkHest

November 07, 2014, 02:07:38 pm #5 Last Edit: November 07, 2014, 02:08:47 pm by MarkHest
@GG: It only gives me a black box :(
(the game acts as if frozen)
   

KK20

How long did you let it run for? It's definitely working for sure though, on a new project with one event.

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

November 07, 2014, 02:30:00 pm #7 Last Edit: November 07, 2014, 02:42:23 pm by MarkHest
You're right. I tested it in a new project and it worked. I guess it's just because the script has a lot of things to work with. Almost every single message box has ":" in it.
I'll just let it work for a while more and report if something happens, but nothing seems to happen for now.




EDIT: Yes, the script was working. It replaced 15074 lines :xD:
Thanks so much for the help :)