I am getting the "script 'game_interpreter' no method error.
undefined method 'region_transfer' for :MapMetadataArrays:symbol
<Region : 5> in map note
this is my first attempt at my own ruby script, so any and all recommendations, criticism, "You should do '...' this way", etc... is appreciated.
region_transfer i feel i can trim down quite a bit, more safety's than necessary or could be simplified at least... currently learning
I am building the arrays more complicated than need be, likely to only use the region# array, but trying it this way for future flexibility. eg the commented examples to remember later. And this is currently just core to get functional, missing conditions like storing world map coords for return.
? Perhaps i should put the region_transfer as 'class Game_Interpreter' ?
many things have crossed my mind, but as of yet none of my changes have made any improvement so I returned to this base script and decided to ask for help.
I have this functional written as a common event which is why such an aggressive attempt at my first script.... i have a small concept of it.
THX
undefined method 'region_transfer' for :MapMetadataArrays:symbol
module MapMetadataArrays # Define which tags to look for // strings or integers TAGS = { "Region" => :integer, #"RegionType" => :string, #"Difficulty" => :integer } #Default starting coords Dest_X = 11 Dest_Y = 11 MAPS_BY_REGION = Hash.new { |h, k| h[k] = [] } #MAPS_BY_REGIONTYPE = Hash.new { |h, k| h[k] = [] } #MAPS_BY_DIFFICULTY = Hash.new { |h, k| h[k] = [] } #--------------------------------------------------------------------------- # Build Arrays #--------------------------------------------------------------------------- def self.build_arrays # Load all maps from Data/MapXXX.rvdata2 Dir.glob("Data/Map*.rvdata2").each do |file| map_id = file[/Map(\d+)\.rvdata2/, 1].to_i next if map_id == 0 map_data = load_data(file) note = map_data.note TAGS.each do |tag, type| if note =~ /<#{tag}\s*:\s*(.+?)>/i value = $1.strip value = value.to_i if type == :integer const_name = "MAPS_BY_#{tag.upcase}" if MapMetadataArrays.const_defined?(const_name) MapMetadataArrays.const_get(const_name)[value] << map_id end end end end end def self.region_transfer build_arrays if MAPS_BY_REGION.empty? region_id = $game_map.region_id($game_player.x, $game_player.y) targ_region = MAPS_BY_REGION[region_id] return unless targ_region && MAPS_BY_REGION[targ_region] && !MAPS_BY_REGION[targ_region].empty? possible_maps = MAPS_BY_REGION[targ_region] - [$game_map.map_id] return if possible_maps.empty? target_map = possible_maps.sample#conditional branch here for recording start position#Define return location for world (set mapId, x, y as game variables // stored for reload game $game_player.reserve_tranfer(target_map, Dest_X, Dest_Y) $game_temp.fade_type = 0 end end# Build arrays at game startMapMetadataArrays.build_arrayscall:MapMetadataArrays.region_transfer in a common event<Region : 5> in map note
this is my first attempt at my own ruby script, so any and all recommendations, criticism, "You should do '...' this way", etc... is appreciated.
region_transfer i feel i can trim down quite a bit, more safety's than necessary or could be simplified at least... currently learning
I am building the arrays more complicated than need be, likely to only use the region# array, but trying it this way for future flexibility. eg the commented examples to remember later. And this is currently just core to get functional, missing conditions like storing world map coords for return.
? Perhaps i should put the region_transfer as 'class Game_Interpreter' ?
many things have crossed my mind, but as of yet none of my changes have made any improvement so I returned to this base script and decided to ask for help.
I have this functional written as a common event which is why such an aggressive attempt at my first script.... i have a small concept of it.
THX