Script to transfer notetag data to variables and switches

I did only a few tests on this, but it should come fairly close to what you want:

Spoiler
module TAGS CLASSES = { RPG::BaseItem => lambda { instance_variable_get🙂@note) }, Game_Event => lambda { comments = []; in_comment = false instance_variable_get🙂@page).list.each do |command| case command.code when 108 comments << command.parameters[0] in_comment = true when 408 comments << command.parameters[0] if in_comment else in_comment = false end end comments.join("\r\n") }, Game_Map => lambda { instance_variable_get🙂@map).note } } endclass Game_Interpreter def notetag_present?(object, tag) !object.get_notes.index?(tag).nil? rescue false end def notetag_value(object, regex) (object.get_notes.match(regex) || [])[1] rescue nil end endTAGS::CLASSES.each{|cls, cmd| cls.send🙂define_method, :get_notes, cmd)}
The CLASSES hash defines a way to get the notebox for our supported classes. In the case of events, we have to first find all comments and join the together.

Afterwards, every defined class defines a method called "get_notes", that returns its notebox. The actual name of the method should probably be longer to make sure it's unique.

notetag_present? calls get_notes and sees if the given string appears in the returned value. If an error occurs (because the class doesn't define get_notes, an event doesn't have active page or Game_map has no map loaded), we return false.

notetag_value takes a regex, applies it to get_notes and returns the first captured group in the first match. If an error occurs (because of reasons above), we return nil.
Thanks

I don't have time to test it immediatly, but if I find any issues I'll ask again.

Original thread: https://forums.rpgmakerweb.com/threads/script-to-transfer-notetag-data-to-variables-and-switches.40620/