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.

Get Comments in Event (within Common Events)

Hi again everyone,
I have this little snippit of code from the Mouse Script by Cybersam
It reads the event commands and changes the mouse's icon accordingly
Code:
  def comment_include(*args)

    list = *args[0].list

    trigger = *args[1]

    return nil if list == nil

    return nil unless list.is_a?(Array)

    for item in list

      next if item.code != 108

      par = item.parameters[0].split(' | ')

      return item.parameters[0] if par[0] == trigger

    end

    return nil

  end

 

Pretty much, make a comment that goes like
Comment: IMS | Start | NPC
it will read for the comment in the event.
It doesn't read through Common Events however.
Is there a way to make it read through the common event on that event?
I have a Crafting Workshop in multiple towns, and it would be helpful for this and many other cases if it could read through the common event as well
Like:
--
Call Common Event: Crafting System
--

That is the whole event there. (Action Button)
Within that Common Event, i have
--
Comment: IMS | Start | NPC
Script Call: $scene = Scene_Craft.new
--

Thats the event. I used a simpler one there, but hopefully you get the idea! :)
So yeah, a method of reading through the Common Event commands as well as the Event itself is needed.
It would help me out a lot if you could figure out how to do this!
Thanks guys!
 
Try changing to this:
Code:
  def comment_include(*args)

    list = *args[0].list

    trigger = *args[1]

    return nil if list == nil

    return nil unless list.is_a?(Array)

    for item in list

      next if item.code != 108 or item.code != 117

      if item.code == 117

        common_event = $data_common_events[@parameters[0]]

        for item in common_event.list

          next if item.code != 108

          par = item.parameters[0].split(' | ')

          return item.parameters[0] if par[0] == trigger

        end

      else

        par = item.parameters[0].split(' | ')

        return item.parameters[0] if par[0] == trigger

      end

    end

    return nil

  end

Untested and possibly bugridden, so let me know if it doesn't work.
 
No, it doesnt. But it looks a lot like what i would've done :grin:
I'm not sure where you get the @parameters[0] from, as that's nowhere in this class . . . only in the interpreter.
yeah, so it doesnt work. thankyou for your time though! :biggrin:

EDIT: I fixed it. Only a small few errors were there.
Code:
 def comment_include(*args)

    list = *args[0].list

    trigger = *args[1]

    return nil if list == nil

    return nil unless list.is_a?(Array)

    for item in list

      next if item.code != 108 and item.code != 117

      if item.code == 117

        common_event = $data_common_events[item.parameters[0]]

        for item in common_event.list

          next if item.code != 108

          par = item.parameters[0].split(' | ')

          return item.parameters[0] if par[0] == trigger

        end

      else

        par = item.parameters[0].split(' | ')

        return item.parameters[0] if par[0] == trigger

      end

    end

    return nil

  end

 
 
hehe, oops. I copy-pasted that from the Interpreter and forgot to change "@parameters[0]" to "item.parameter[0]".

Glad it worked out! It's not the cleanest code (and it won't let you call a common event from a common event :P) but it works.
 

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