Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[Resolved] the mother folder

Status
Not open for further replies.
I think he's talking about making a map joining all the maps with their child maps. Surprisingly enough, RMXP actually keeps track of this in code you can call.

Code:
module RPG
  class MapInfo
    def initialize
      @name = ""
      @parent_id = 0
      @order = 0
      @expanded = false
      @scroll_x = 0
      @scroll_y = 0
    end
    attr_accessor :name
    attr_accessor :parent_id
    attr_accessor :order
    attr_accessor :expanded
    attr_accessor :scroll_x
    attr_accessor :scroll_y
  end
end

The variable parent_id contains an integer value, relating to the id of the map that it joins to. If this is any help.

Loading the MapInfos data can be done like so:

Code:
map_info = load_data("Data/MapInfos.rxdata")

which should return an Hash of RPG::MapInfos objects, with the map id as the key. You could then use that, and some looping arrays, to determine what maps are child maps of your current map.

Code:
class Game_Map
  def child_maps?(id)
    map_infos = load_data("Data/MapInfos.rxdata")
    maps = []
    for key in map_infos.keys
      next unless map_infos[key].parent_id == id
      maps[key] = map_infos[key].parent_id
    end
    return maps
  end
end

You could then simply add a method to Game_Map:

Code:
class Game_Map
  def parent_id?(id)
    map_infos = load_data("Data/MapInfos.rxdata")
    for key in map_infos.keys
      return map_infos[key].parent_id if key == id
    end
  end
end

Or you could do it the easy way, and add this code to the $data_* initialization of Scene_Title:

Code:
$data_mapinfo = load_data("Data/MapInfos.rxdata")

And then you can easily just do $data_mapinfo[MapID].parent_id to return the parent ID.
 

Aran

Member

@Selwyn: Yeah, it was kinda hard to word out in a quick 2 minutes. I'm even surprised that rex caught it, ^^

@Prexus: That sounds perfect. What I want to do is make it so if the mother map is a dungeon then so are all its children. Prex, i love you (no homo tho...)
 
Status
Not open for further replies.

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top