Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #═╦═════════════════════════════════════════════════════════════════════════════
- # ║ § SES Core (v1.2) by Solistra and Enelvon [License: CC BY-SA 3.0]
- # ║ <RMVX Ace>
- #═╬═════════════════════════════════════════════════════════════════════════════
- # ║ § Change Log
- #─╫─────────────────────────────────────────────────────────────────────────────
- # ║ v1.0 (December ???, 2012) - Initial release
- # ║ v1.1 (February 26th, 2013) - Enelvon fixed an issue with scanning comments,
- # ║ but took forever to remember to upload it
- # ║ v1.2 (March 15, 2013) - Ditto the above
- # ║
- #═╬═════════════════════════════════════════════════════════════════════════════
- # ║ § Summary
- #─╫─────────────────────────────────────────────────────────────────────────────
- # ║ This serves as a base script required by some SES scripts released by both
- # ║ Solistra and Enelvon. It contains some utility methods and methods to help
- # ║ facilitate the use of tags in note boxes and event comments.
- # ║
- #═╬═════════════════════════════════════════════════════════════════════════════
- # ║ § Installation
- #─╫─────────────────────────────────────────────────────────────────────────────
- # ║ For best compatibility, place this script below Materials, but above all
- # ║ other custom scripts (especially SES scripts).
- # ║
- #═╬═════════════════════════════════════════════════════════════════════════════
- # ║ § New Methods
- #─╫─────────────────────────────────────────────────────────────────────────────
- # ║ ● Game_Event
- # ║ comments
- # ║ ● Game_Interpreter
- # ║ this
- # ║ event
- # ║ comments
- # ║
- #═╬═════════════════════════════════════════════════════════════════════════════
- # ║ ▼ module SES
- #═╩═════════════════════════════════════════════════════════════════════════════
- module SES
- # Includes SES in the data structures used by RMVX Ace by default.
- def self.insert
- RPG.constants.each do |s|
- (s = RPG.const_get(s)).send(:include, self)
- s.constants.each{|c| s.const_get(c).send(:include, self)}
- end
- end
- # Used in Game_Event and Game_Interpreter to collect comments.
- def self.comment_proc
- Proc.new do
- @list.select{|c| c.code == 108 || c.code == 408}.map{|c|c.parameters[0]}
- end
- end
- # An extended version of Kernel.rand. Also takes ranges, arrays, or hashes.
- def self.rand(arg = nil)
- if arg.is_a?(Range) then Kernel.rand(1 + arg.max - arg.min) + arg.min
- elsif arg.kind_of?(Array) then arg[Kernel.rand(arg.size)]
- elsif arg.is_a?(Hash) then self.rand(arg.values)
- else Kernel.rand(arg) end
- end
- # Note tag scanning method.
- def scan_ses_notes(tags = {})
- return unless defined?(self.note)
- self.note.split(/[\r\n+]/).each do |line|
- tags.each{|regex, code| eval(code) if line =~ regex}
- end
- end
- # Allows scan_ses_comments to work.
- def comments
- com = []
- if self.is_a?(RPG::Event::Page) || self.is_a?(RPG::CommonEvent)
- @list.each{|c|com.push(c.parameters[0]) if c.code == 108 || c.code == 408}
- end
- com
- end
- # Event comment scanning method. May be used in common events as well.
- def scan_ses_comments(tags = {})
- self.comments.each do |comment|
- tags.each{|regex, code| eval(code) if comment =~ regex}
- end
- end
- # Method definitions are complete; include SES in the RPG data structures.
- self.insert
- end
- #═╦═════════════════════════════════════════════════════════════════════════════
- # ║ ▲ module SES
- #═╩═════════════════════════════════════════════════════════════════════════════
- ($imported ||= {})["SES - Core"] = 1.1
- #═╦═════════════════════════════════════════════════════════════════════════════
- # ║ ▼ class Game_Event
- #═╩═════════════════════════════════════════════════════════════════════════════
- class Game_Event < Game_Character
- def comments() self.instance_eval(&SES.comment_proc) end
- end
- #═╦═════════════════════════════════════════════════════════════════════════════
- # ║ ▲ class Game_Event
- #─╫─────────────────────────────────────────────────────────────────────────────
- # ║ ▼ class Game_Interpreter
- #═╩═════════════════════════════════════════════════════════════════════════════
- class Game_Interpreter
- def event(id) $game_map.events[id] end
- def this() @event_id > 0 ? $game_map.events[@event_id] : self end
- def comments() this.page ? self.instance_eval(&SES.comment_proc) : [] end
- end
- #═╦═════════════════════════════════════════════════════════════════════════════
- # ║ ▲ class Game_Interpreter
- #═╩═════════════════════════════════════════════════════════════════════════════
Advertisement
Add Comment
Please, Sign In to add comment