检测未释放的对象
# @taroxd metadata 1.0
# @require taroxd_core
# @id check_object_dispose
# @display 检测未释放的对象
class Viewport
  def_before(:dispose) { @__dispose__ = true }
  def disposed?; @__dispose__; end
end

need_dispose = [Bitmap, Sprite, Window, Plane, Tilemap, Viewport]
callers = {}
callers.compare_by_identity
not_disposed = []

need_dispose.each do |klass|
  klass.class_eval do
    def_after(:initialize) { |*| callers[self] = caller }
  end
end

Scene_Base.class_eval do
  def_after :terminate do
    need_dispose.each do |klass|
      ObjectSpace.each_object(klass) do |obj|
        not_disposed.push(obj) unless obj.disposed?
      end
    end
  end

  def_after :update do
    return unless Input.trigger?(:ALT)
    puts not_disposed.delete_if(&:disposed?)
    puts callers[
      not_disposed.shuffle.find do |obj|
        callers[obj] && callers[obj].none? { |s| s.start_with?('{0004}') }
      end
    ]
  end
end
检查控制台是否打开
# @taroxd metadata 1.0
# @display 检查控制台是否打开
# @id check_console
if $TEST && Win32API.new('Kernel32.dll', 'GetConsoleWindow', '', 'L').call == 0
  msgbox "Warning: Console window is not displayed"
end
位图功能扩展
# @taroxd metadata 1.0
# @display 位图功能扩展
# @id bitmap_ext
# @help 需要将 rgssdll.dll 放入 System 文件夹下。
module Taroxd
  module BitmapExt
    DLL_FILE = 'System/rgssdll'
    XOR = Win32API.new(DLL_FILE, 'bitmap_xor', 'LL', 'L')
    OR  = Win32API.new(DLL_FILE, 'bitmap_or',  'LL', 'L')
    AND = Win32API.new(DLL_FILE, 'bitmap_and', 'LL', 'L')
  end
end

class Bitmap

  include Taroxd::BitmapExt

  # 对位图的每个像素做 xor 运算。
  # color: 0xaarrggbb
  def xor!(color)
    XOR.call(__id__, color)
  end

  # 对位图的每个像素做 or 运算。
  # color: 0xaarrggbb
  def or!(color)
    OR.call(__id__, color)
  end

  # 对位图的每个像素做 and 运算。
  # color: 0xaarrggbb
  def and!(color)
    AND.call(__id__, color)
  end
end