Pulling Event Names from the Map

I'm trying to make a selectable menu that lists down all the names of the events present on the map, the code is as follows:


class Scene_SVNMenu < Scene_MenuBase
def start
super
@list_window = Window_SVNMenu.new(0, 0, 200)
@list_window.set_handler🙂cancel, method🙂return_scene))
end
end

class Window_SVNMenu < Window_Selectable
def initialize(x, y, width)
super(x, y, width, Graphics.height - y)
data = []
self.index = 0
activate
refresh
end

def item_max
@data ? @data.size : 1
end

def make_item_list
@data = Hash.new
$game_map.events.each do |key, event|
@data[key] =event.name
puts "test #{event.name} "
end
end

def draw_item(index)
if @data
item = @data[index]
if item
rect = item_rect_for_text(index)
draw_text(rect, item)
end
end
end

# def draw_item(index)
# item = @data[index]
# if item
# rect = item_rect_for_text(index)
# draw_text(rect, item.name)
# end
# end

def refresh
make_item_list
create_contents
draw_all_items
end
end


Debug logs return all three names to me, but the window generated always has the first option blank and the last event name unlisted. This is kind of my first time doing this, so I'm a little (very) lost. D:


EDIT


NOPE. Figured it out. Very sorry. Just needed to change @data[key] to @data[key-1] because event IDs start with 1 and not 0.

Original thread: https://forums.rpgmakerweb.com/threads/pulling-event-names-from-the-map.59698/