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.

[Resoleved] an agent in the name

Status
Not open for further replies.

Aran

Member

Okay, I want to classify a dungeon by having something in its map name like an asterick(*) or something.

example:
Map Name: MAP001*

Code:
map [COLOR=blue]=[/COLOR] load_data[COLOR=blue]([/COLOR][COLOR=darkorchid]"Data/Maps.rxdata"[/COLOR][COLOR=blue]) [/COLOR][/COLOR][COLOR=green]#whatever, I'm just throwing out 'play' code :P[/COLOR]
[COLOR=black][COLOR=blue]if[/COLOR] map[COLOR=blue].[/COLOR]name[COLOR=blue].[/COLOR]include[COLOR=blue]?[/COLOR][COLOR=blue]([/COLOR][/COLOR][COLOR=darkorchid]"*"[/COLOR][COLOR=blue])[/COLOR]
[COLOR=#000000]map[COLOR=blue].[/COLOR]is_a[COLOR=blue]([/COLOR]Dungeon[COLOR=blue])[/COLOR] [/COLOR][COLOR=blue]= true[/COLOR]
[COLOR=blue]end[/COLOR]
[COLOR=#000000]

It's not real code, but you catch my drift? yes? maybe?

 
I am guessing you are wanting to do something like this...

Code:
class RPG::Map
  attr_accessor :dungeon
end

class Scene_Title
    # ...
    $data_system        = load_data("Data/System.rxdata")
    # NEW
    load_data("Data/MapInfos.rxdata").each do |map_id, map_info|
      $data_maps[map_id].dungeon = map_info.name.include?('*')
    end
    # ...
end

I haven't tested it, but I am sure that's what you are trying to do.

I DON'T recommend using things like the database to add attributes to objects. * Points at tutorial in Tutorials on how to add attributes *

I recommend making a constant to hold an array of maps that are dungeons. For simplicity, Game_Map would be a good spot.

Code:
class Game_Map
  Dungeons = [map_id, ...]
  def is_a_dungeon?(map_id = @map_id
    return Dungeons.include?(map_id)
  end
end

Now, you can use $game_map.is_a_dungeon?(map_id) to test any map in your game, by just filling the Dungeons array. If you are testing the current map, you don't even need to define the map_id. Horray simplicity!
 

Aran

Member

Oh sorry! I figured it out already! It's a bit more code, but this is what I was planning to do:

Code:
map = load_data("Data/MapInfos.rxdata")
parent = map[$game_map.map_id].parent_id
if map[parent].name.include?"*"
map = Dungeon #or something like that...
end

then, I can do:
Code:
if map.is_a?(Dungeon) == true
#blah blah blah
end
I think... if not, correct me, please.
 

Mac

Member

I thought it would be like this to be honest, if that doesn't work out for you then try using this.

Code:
  alias dungeon_setup setup
  def setup(map_id)
    # Set Up Map ID
    dungeon_setup(map_id)
    # Load map info data from Data Folder
    $data_mapinfos = load_data("Data/MapInfos.rxdata") if $data_mapinfos.nil?
    map_name = $data_mapinfos[@map_id].name
    # Get dungeon map end ID
    @dungeon_end_map = get_dungeon_end_map(@map_id)
    # If dungeon map it must include •
    $game_system.in_dungeon= map_name.include?("•")
  end
end
 
I still think my way probably has the best. Mac's way works, but has to load the MapInfos.rxdata file every time. The constants is honestly your best bet. Max compatabiltiy, and extremely simple.

Aran, what you are doing... um... is just a mess. The is_a? test objects and their parent class. The parent class testing is just... bad.
 

Aran

Member

How is it a mess? Okay, I messed up on the is_a? part, but that was it. The rest works and its simple.

Excuse my frustration, but everytime I seem to try and script somebody tells me that it's messy. But now, even when it works, it's still "messy".
 
No. It is messy. You didn't proper indent. The syntax makes me cringe. I don't know how you got it to "work", but you must do magic or something. The extreme fatal flaw is the "map = Dungeon". I showed you how to add an attribute dungeon to the RPG::Map data, and test for that there. If you wanted to do it another way fine, but what you came up with makes me cry. :(

I don't mean to sound rude, but you have been going at it for months now, and the simple syntax is wrong. You just piece together a code segment from some script you saw and say you came up with it, without really knowing what it is.

I guess I am just a butt though...
 

Aran

Member

that code up there is not real code, so its not really indented cuz i was coding off the top of my head. and the "fatal flaw" you speak of (map = Dungeon) was the second part i was going to ask about.

so if all that sickens you is the map = Dungeon, I'm fine, b/c I wasn't sure if that was even real in the first place. *phew* so, I'm doing good... with a few extra adjustments to make :D.

Seph, I love you.
 
I know you are trying which is good, but it seems like you just are breaking the barriers. I figured that that wasn't your true code, but I just expected after over 100+ help topics, you ought to be able to throw something up that made a little more sense.
 
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