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.

MACL - Method and Class Library 2.3

fill_rect is faster as set_pixel (for some reason)

ps: name your method negative! (because it change self)
and make a that dup a copy
 
Something random, doing randomizing things.
Code:
#==============================================================================
# ** 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
 
Shouldn't each be in the Array class, or at least each_with_index?  It behaves differently between different Enumerable classes (in Hash, each must yield two values, and each_with_index doesn't exist)

EDIT: I feel like sharing my personal modifications to Bitmap.draw_slant_bar. This gives the bar a pleasing gradient:

Code:
  #--------------------------------------------------------------------------
  # * 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
 
Hello all,

Sorry for being away so long. So many changes in my life just keep me from being as active as I once was.

I have noticed it is extremely hard to keep track of everything and submitting sections, classes, modules and methods can be kinda hard, and a pain for me to update. Therefore, I created a wiki just for the MACL. I must approve members before they can add and modify the wiki, but once you register (please register with your name here so I know who you are) and I will approve you. This way, I can check modifications of the last month in the wiki and update everything much easier. I have learned php/mySQL so I am also working on a system that will allow this to be done with a php script and allow updates to be all taken care of online, but it'll probably be another month before I complete it.

I am working on going through everything again and updating the MACL to 3.0 this week (as long as nothing comes up). I am going to be revamping a lot of things to try to make updates easier. Any suggestions would be great. I have went through the topic and added everything I have seen. I will probably modify some of the codes, but original authors will receive credit.
 
I have a little fix to the MACL, in RGSS Actor and party info part, arround the line 104, in the Game_Character refresh method puts:

Code:
 

  #--------------------------------------------------------------------------

  # * 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

And refer to the original method, and the Logical display, must be:

Code:
  #--------------------------------------------------------------------------

  # * 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

So, in the original method, when the actors are all dead, there are no graphic for the character.

Well, that.
 
I was looking through the thread and I saw myself write something about a Data module. Well, I wrote it better, using Dir:

[rgss]class Data
  # Load normal database
  Dir.entries("Data").each do |filename|
    if filename.include?(".rxdata")
      name = filename.chomp(".rxdata")
      eval(name + ' = load_data("Data/" + filename)')
    end
  end
  if $BTEST
    # Load battle test database
    Dir.entries("Data").each do |filename|
      if filename.include?("BT_")
        name = filename.sub("BT_", '').chomp(".rxdata")
        eval(name + ' = load_data("Data/" + filename)')
      end
    end
  end
end
[/rgss]

It would have been half as long if it weren't for $BTEST. It works though. You'll have, say, Data::System, Data::MapInfos, Data::Actors, Data::Scripts, Data::Map001, etc. All centralized. Not sure if having Scripts initialized is a good idea, but it's in there so it is. Another benefit of this is that if another "rxdata" file is added to the Data directory, it's automatically loaded.
 

Zeriab

Sponsor

It is an idea you have meustrus, but I don't like it since you load all of the map data into the memory. It can be a significant amount of data and you don't need it all at the same time. Note that it will not with encrypted projects since Dir for obvious reasons won't be able to give the filenames.
I like the idea of Data::System, Data::MapInfos and etc.
It doesn't really matter whether you have Data::Scripts or not since you have $RGSS_SCRIPTS. $RGSS_SCRIPTS contains both the compressed scripts and the raw scripts where as Data::Scripts will only have the compressed data.

*hugs*
- Zeriab
 
Hey I apologize if this is asking too much, but can someone put a mirror up for the MACL scripts?

The links on the wiki as well as this thread don't seem to work.

Thank you kindly!
 

e

Sponsor

It's my site, but it may have been? My host has bouts from time to time. I don't know...I'll check and see if anything went wrong.
 
I don't know what's up with Seph right now, but etheon.net is down again. I was going to mirror the MACL, but I can't get a good cached copy (Google has one but it gets cut off) and I've broken my copy up/deleted some things already (I'm actually looking for the Random class, if anybody's got it). I would speculate that the website goes down because of bad PHP or Javascript that taxes the server until the server suspends the account (at least, that's what seemed to happen to me).
 
http://rapidshare.com/files/215652725/macl_tree.rar << the macl tree

edit:

[rgss]class Data
# Load normal database
 Dir.entries("Data").each do |filename|
  if filename.include?(".rxdata")
   name = filename.chomp(".rxdata")
   self.const_set(name,load_data("Data/" + filename))
  end
 end
 if $BTEST
 # Load battle test database
  Dir.entries("Data").each do |filename|
   if filename.include?("BT_")
    name = filename.sub("BT_", '').chomp(".rxdata")
    self.const_set(name,load_data("Data/" + filename))
   end
  end
 end
end
[/rgss]

this is better and has no Evial
 

Raku

Member

A simple method for the Dir class to recursively perform mkdir if any parent directories do not exist.

Ruby:
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
 
Does the Macl script have a licence ?
Can we use it in the games we want ? (crediting the authors)

Can we use it in commercial projects ? (crediting the authors too)
 
If this edits properly, I can't submit everything (roughly 1800 lines or so) so I posted it at pastebin and in a txt at mediafire since pastebin choked on it too o.O?

TONS of new stuff for...

Array
Game_Actor
Game_Actors
Game_Battler
Game_Enemy
Game_Party
Game_Troop
Game_Map
RPG::Cache
RPG::Item
RPG::Armor
RPG::Weapon
RPG::Skill

Enjoy :thumb:

I just read that you made a wiki for this. As soon as you approve me I'll be adding alot more stuff to the MACL.
 

e

Sponsor

I just switched hosts to a new VPS (which is still being set up), so the MACL docs are down right; if anyone wants to host them go ahead.
 

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