def pbEditMapMetadataIl(map_id)
mapinfos = pbLoadMapInfos
data = []
map_name = mapinfos[map_id].name
metadata = GameData::MapMetadata.try_get(map_id)
metadata = GameData::MapMetadata.new({:id => map_id}) if !metadata
properties = GameData::MapMetadata.editor_properties
properties.each do |property|
val = metadata.get_property_for_PBS(property[0])
val = property[1].defaultValue if val.nil? && property[1].respond_to?(:defaultValue)
data.push(val)
end
# Data order = ID, Name, outdoor, Showarea, Bicycle, Bicycle always, Healingspot ([mapId,x,y]),Weather(Type,chance),mapPosition,divemap,darkmap,safariMap,snapedges,stillReflections,Dungeon,battleback,wildbattlebgm,trainerbattlebgm,wildvictorybgm,trainervictorybgm,wildcaptureme,mapsize,environment,flags
# 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
data[1] = "New Map Name" # This can be a variable or sth similair ofcourse.
# Idk why this work and what it does tbh. But it does transfer the data and writes it down in the pbs, crucially without overwriting old data of different maps.
schema = GameData::MapMetadata.schema
metadata_hash = {}
properties.each_with_index do |prop, i|
case prop[0]
when "ID"
metadata_hash[schema["SectionName"][0]] = data[i]
else
metadata_hash[schema[prop[0]][0]] = data[i]
end
end
metadata_hash[:pbs_file_suffix] = metadata.pbs_file_suffix
# Add map metadata's data to records
GameData::MapMetadata.register(metadata_hash)
GameData::MapMetadata.save
Compiler.write_map_metadata
end