
#==============================================================================
# ** Randomizing stuff
#------------------------------------------------------------------------------
# Methods for Enumerable classes (like Array), for creating random entries and
# random iteration. and a destructive shuffle! for class Array.
#==============================================================================
module Enumerable
def shuffle
array = self.entries
return Array.new(self.size){
array.delete_at(rand(array.size))
}
end
def random_each
for obj in self.shuffle
yield obj
end
end
def random_each_with_index
self.shuffle.each_with_index do |obj, i|
yield obj, i
end
end
end
class Array
def shuffle!
array = self.shuffle
result = array == self ? nil : self
clear()
self.concat(array)
return result
end
end
#--------------------------------------------------------------------------
# * Draw Slant Bar (by SephirothSpawn)
#--------------------------------------------------------------------------
def draw_slant_bar(x, y, min, max, width = 152, height = 6,
bar_color = Color.new(150, 0, 0, 255),
end_color = Color.new(255, 255, 60, 255))
# Draw Border
for i in 0..height
self.fill_rect(x+i, y+height-i, width+1, 1, Color.new(50, 50, 50, 255))
end
# Draw Background
for i in 1...(height - 1)
r = 100 * (height - i) / height
g = 100 * (height - i) / height
b = 100 * (height - i) / height
a = 255
self.fill_rect(x + i, y + height - i, width, 1, Color.new(r, b, g, a))
end
# Draws Bar
for i in 1...( (min.to_f / max.to_f) * width - 1).to_i
r = bar_color.red * (width - i) / width + end_color.red * i / width
g = bar_color.green * (width - i) / width + end_color.green * i / width
b = bar_color.blue * (width - i) / width + end_color.blue * i / width
a = bar_color.alpha * (width - i) / width + end_color.alpha * i / width
for j in 1..(height - 1)
r = r * (height - j) / height + (3 * r / 4) * j / height
g = g * (height - j) / height + (3 * g / 4) * j / height
b = b * (height - j) / height + (3 * b / 4) * j / height
self.fill_rect(x + i + j, y + height - j, 1, 1, Color.new(r, g, b, a))
end
end
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
# Set character file name and hue
if @battler != nil
# If Dead
if @battler.dead?
@character_name = ''
@character_hue = 0
return
end
@character_name = @battler.character_name
@character_hue = @battler.character_hue
end
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
# Set character file name and hue
if @battler != nil
# If Dead
if @battler.dead?
@battler_name = ''
@battler_hue = 0
return
end
@character_name = @battler.character_name
@character_hue = @battler.character_hue
end
end
etheon":1rttto2p said:On the first page: http://code.etheon.net/macl/scripts/macl_complete.txt
class Dir
 #-------------------------------------------------------------------------
 # * Name    : Dir.mkdir_rec
 #  Info    : Creates a directory and all its parent directories if they
 #        do not exist.
 #  Author   : Raku
 #  Call Info : path: The path to the directory to create
 #-------------------------------------------------------------------------
 def self.mkdir_rec(path)
  begin
   # Attempt to make the directory
   Dir.mkdir(path)
  rescue Errno::ENOENT
   # Failed, so let's use recursion on the parent directory
   parent_path = File.dirname(path)
   mkdir_rec(parent_path)
Â
   # Make the original directory
   Dir.mkdir(path)
  end
 end
end