Skip to content

Instantly share code, notes, and snippets.

@NuriYuri
Created October 11, 2023 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NuriYuri/fdd05a10b49b2bf4f440e20cc85b08ef to your computer and use it in GitHub Desktop.
Save NuriYuri/fdd05a10b49b2bf4f440e20cc85b08ef to your computer and use it in GitHub Desktop.
Extract RMXP Script commands from Events
rgss_main {}
STDOUT.pos = 0 unless STDOUT.tty? # Go back so we don't end up with artifacts
def process_list(list)
list.each_with_index do |command, index|
if command.code == 355
@last_map_pos = @last_pos = nil
puts "#--> Script Command @#{index}"
puts command.parameters[0]
elsif command.code == 655
puts command.parameters[0]
elsif command.code == 209
command.parameters[1].list.each_with_index do |movement, move_index|
if movement.code == 45
@last_map_pos = @last_pos = nil
puts "#--> Move Script Command @#{index}:#{move_index}"
puts movement.parameters[0]
end
end
elsif command.code == 111 && command.parameters[0] == 12
@last_map_pos = @last_pos = nil
puts "#--> Condiction Script @#{index}"
puts command.parameters[1]
end
end
end
Dir['Data/Map*.rxdata'].each do |filename|
next if filename == 'Data/MapInfos.rxdata'
@last_map_pos = STDOUT.pos
puts "#> #{filename}"
map = load_data(filename)
map.events.each_value do |event|
@last_pos = STDOUT.pos
puts format('#>> Event %03d : %s', event.id, event.name)
event.pages.each do |page|
if page.move_route
page.move_route.list.each_with_index do |movement, move_index|
if movement.code == 45
@last_map_pos = @last_pos = nil
puts "#--> Move Script Command @MainRoute:#{move_index}"
puts movement.parameters[0]
end
end
end
process_list(page.list)
end
STDOUT.pos = @last_pos if @last_pos && !STDOUT.tty?
end
STDOUT.pos = @last_map_pos if @last_map_pos && !STDOUT.tty?
end
load_data('Data/CommonEvents.rxdata')[1..].each_with_index do |event, index|
@last_pos = STDOUT.pos
puts format('#>> Common Event %03d : %s', index + 1, event.name)
process_list(event.list)
STDOUT.pos = @last_pos if @last_pos && !STDOUT.tty?
end
unless STDOUT.tty?
if @last_pos
print " " * 256
STDOUT.pos = @last_pos
end
print "# "
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment