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.

" /図鑑登録無効/ " # <--What does this do?

Good day everybody!

I'll keep this short 'n sweet, I have a Bestiary script by....

Code:
#===============================================================================
# â–  Bestiary
#-------------------------------------------------------------------------------
# Created by Momomo
# Modified by coolmariners98
#===============================================================================

I don't know what this line does...

Code:
if $data_system.elements[i] =~ /図鑑登録無効/

Its found in the method Data_MonsterBook.no_add_element

Code:
#===============================================================================
# ** Data_MonsterBook
#-------------------------------------------------------------------------------
#   This class stores all enemy information.
#===============================================================================

class Data_MonsterBook
  #-----------------------------------------------------------------------------
  # * Attribute Readers
  #-----------------------------------------------------------------------------
  attr_reader :id_data
  #-----------------------------------------------------------------------------
  # * Object Initialization
  #-----------------------------------------------------------------------------
  def initialize
    @id_data = enemy_book_id_set
  end
  #-----------------------------------------------------------------------------
  # * No Add Element
  #-----------------------------------------------------------------------------
  def no_add_element
    no_add = 0
    for i in 1...$data_system.elements.size
      if $data_system.elements[i] =~ /図鑑登録無効/
        no_add = i
        break
      end
    end
    return no_add
  end
  #-----------------------------------------------------------------------------
  # * Enemy Book ID Set
  #-----------------------------------------------------------------------------
  def enemy_book_id_set
    data = [0]
    no_add = no_add_element
    for i in 1...$data_enemies.size
      enemy = $data_enemies[i]
      next if enemy.name == ""
      if enemy.element_ranks[no_add] == 1
        next
      end
      data.push(enemy.id)
    end
    return data
  end
end

Does anybody know what it does?
 
I've never used the =~ operator but I think its a complement operator.
After a quick translation, 図鑑登録無効 means Picture book register invalidity.
So my guess here is, if the enemy has an element including 図鑑登録無効 in its name, the enemy won't be displayed in the Monster Book.
 
The =~ operator is used for regexp but in this case it's the same as
Code:
if $data_system.elements[i] == "図鑑登録無効"

But here it wont really do anything becouse I doubt you'll ever name an element "図鑑登録無効". :tongue:

Hope it helps! :thumb:
 
S S Muu":pbtqptqg said:
The =~ operator is used for regexp but in this case it's the same as
Code:
if $data_system.elements[i] == "図鑑登録無効"

But here it wont really do anything becouse I doubt you'll ever name an element "図鑑登録無効". :tongue:

Hope it helps! :thumb:
It is not the same as ==, it would be the same if the regex was /^図鑑登録無効$/
 
in this case, it is.

edit:
No wait, I was thinking about an edited regexp that I usually use, the Ruby one's different.
If the element's string includes "図鑑登録無効" it would return true, so for example if the string is "Fire 図鑑登録無効" it would still return true.
 
That's what I said.
I guess it's also possible to use $data_system.elements.include?("図鑑登録無効") but =~ is a lot shorter! I should use this operator a bit more.
 
Actually I think ".include?" is faster, I haven't tested so I'm not sure but it would make sense.

Oh, and Kain, you should probably change "図鑑登録無効" to something else. (unless you want it that way of course)
 

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