Do you know when you are extracting text for your game, and you get every single text from every event on every map.
Well, I thought it would be useful to do it for scripts as well!
With this script I wrote the other day, it allows you to obtain every single script from every map.
This can be useful if you want to check if you have implemented a definition somewhere, and don't want to go trawling through all the events it could be on.
Enjoy, and please give credit to Swdfm!
As far as I know, his works on every version after v16 (incl. v18!)
Well, I thought it would be useful to do it for scripts as well!
With this script I wrote the other day, it allows you to obtain every single script from every map.
This can be useful if you want to check if you have implemented a definition somewhere, and don't want to go trawling through all the events it could be on.
Enjoy, and please give credit to Swdfm!
As far as I know, his works on every version after v16 (incl. v18!)
Code:
#===============================================================================
# * Event Script Extractor - by Swdfm (Credits will be appreciated)
#===============================================================================
# A cool script that allows you to see your Event scripts all in one document.
# Place above Main
#===============================================================================
# Call with pbExtractEventScripts
#===============================================================================
# Roughly how many events you think the map with the most events has.
MAXEVENTCHECKER = 200
# The largest map ID number in your game.
AMOUNTOFMAPS = 600
# Name of the .txt document that the scripts are output to.
OUTPUTTEXTFILE = "outfile.txt"
# Whether you want to declare the map number
WRITEMAPNUMBERS = true
# Whether you want to declare the event number
WRITEEVENTNUMBERS = true
# Whether you want to declare the event page
WRITEPAGENUMBERS = true
# Whether you want the headings to be written for event pages with no scripts in.
# Only relevant if one of above three is true
INCLUDEEMPTIES = false
# Whether you want Conditional Branch Scripts to be declared here.
WRITECONDITIONAL = true
# Text placed in front of Conditional Branch Scripts to show difference.
# Only relevant if above is true.
CONDITIONALTEXT = "[CB] "
#===============================================================================
def pbExtractEventScripts
refreshrate = [[40,(8000/MAXEVENTCHECKER).floor].min,1].max
writeanything = WRITEMAPNUMBERS || WRITEEVENTNUMBERS || WRITEPAGENUMBERS
File.open(OUTPUTTEXTFILE,"wb"){|f|
f.write("================= Event Scripts ==================\r\n")
}
for mapid in 1..AMOUNTOFMAPS
if pbRgssExists?(sprintf("Data/Map%03d.rxdata",mapid.to_i))
realmap=$MapFactory.getMapNoAdd(mapid.to_i)
map = load_data(sprintf("Data/Map%03d.rxdata", realmap.map_id))
if WRITEMAPNUMBERS
File.open(OUTPUTTEXTFILE,"ab"){|f|
f.write("==================================================\r\n")
}
end
for i in 1...MAXEVENTCHECKER
for event in map.events.values
if event.id == i
count = 1
for page in event.pages
if writeanything && INCLUDEEMPTIES
File.open(OUTPUTTEXTFILE,"ab"){|f|
f.write("========= ")
f.write("[Map "+realmap.map_id.to_s+"]") if WRITEMAPNUMBERS
f.write(" [Event "+i.to_s+"]") if WRITEEVENTNUMBERS
f.write(" [Page "+count.to_s+"]") if WRITEPAGENUMBERS
f.write(" =========")
f.write("\r\n")
}
end
empty = true
for thing in page.list
if thing.code == 355 || thing.code == 655
string = thing.parameters[0]
if !INCLUDEEMPTIES && empty && writeanything
File.open(OUTPUTTEXTFILE,"ab"){|f|
f.write("========= ")
f.write("[Map "+realmap.map_id.to_s+"]") if WRITEMAPNUMBERS
f.write(" [Event "+i.to_s+"]") if WRITEEVENTNUMBERS
f.write(" [Page "+count.to_s+"]") if WRITEPAGENUMBERS
f.write(" =========")
f.write("\r\n")
}
empty = false
end
File.open(OUTPUTTEXTFILE,"ab"){|f|
f.write(string)
f.write("\r\n")
}
elsif thing.code == 111 && WRITECONDITIONAL
if thing.parameters[0] == 12
string = thing.parameters[1]
if !INCLUDEEMPTIES && empty && writeanything
File.open(OUTPUTTEXTFILE,"ab"){|f|
f.write("========= ")
f.write("[Map "+realmap.map_id.to_s+"]") if WRITEMAPNUMBERS
f.write(" [Event "+i.to_s+"]") if WRITEEVENTNUMBERS
f.write(" [Page "+count.to_s+"]") if WRITEPAGENUMBERS
f.write(" =========")
f.write("\r\n")
}
empty = false
end
File.open(OUTPUTTEXTFILE,"ab"){|f|
f.write(CONDITIONALTEXT+string)
f.write("\r\n")
}
end
end
end
count += 1
end
end
end
end
end
# Necessary to avoid potential script hanging/taking too long.
Kernel.pbMessage(_INTL("{1}\\WTNP[0]",mapid)) if mapid%refreshrate == 0
end
Kernel.pbMessage(_INTL("Done!"))
end