Interpreting Comments in Events

Hello.

I am trying to edit a script that interprets an event's name. I would like to change it so that it interprets an event page's

comment instead.

Here is a part of the script: (Schala battle system at www.atelier-rgss.com)

def battler_recheck

      return if @battler != nil

      return if @page == nil

      @enemy_id = 0

      if self.name =~ /<Enemy(\d+)>/i                       <----------------------- This line.

         @enemy_id = $1.to_i    

         return if @enemy_id <= 0

         @battler = Game_Enemy.new(1, @enemy_id)

         self.force_update = true if self.battler.sensor_range >= 15         

         set_original_name

      end  

  end

 

The current method is ineffective because an event is forced to be an enemy at all times, no matter the current event page.

How do you interpret an event's comment in Ruby?
I've moved this thread to script support. Please be sure to post your threads in the correct forum next time. Thank you.
You need to go through the list of event commands, finding which ones are comments, and put them together. Comment codes are 108 and 408. You can access the list by self.list (since it already has the event). The list is an array, so you want to do something along the lines of

i = 0comment = ""while self.list.code == 108 || self.list.code == 408 comment += self.list.parameters[0]endyou'll probably need to change it to work for what you need, since that will only work for a comment on the first line, and any comments that DIRECTLY follow it.
I'm sorry, but I don't really know what I am doing. I changed it to this, but I know it's stupid because it just freezes the game.

def battler_recheck

      return if @battler != nil

      return if @page == nil

      @enemy_id = 0

      i = 0

comment = ""

while self.list.code == 108 || self.list.code == 408

  comment += self.list.parameters[0]

           comment =~ /<Enemy(\d+)>/i

 

I find it strange that it doesn't return as an error though.

If you think this makes sense I can search for more references to self.name and change them.

Original thread: https://forums.rpgmakerweb.com/threads/interpreting-comments-in-events.17062/