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

Here I am and I went to all the trouble to update from 2.1 to 2.3 and I find that it's not working entirely.  Don't think about it too much if it doesn't seem simple (because I've made a lot of modifications to the project that you can't predict).  With fotz!'s pixel movement script, the front player in the party does not display properly and the pathfinding is not initializing properly.  And for some reason it made all text in the game shadowed.
 
The Pathfinding probably needs a little tweeking. With fotz!'s system, there might be a method name mixup. If you can make a demo, I can take a look. And the font is shadowed because of the settings right below the heading. All those constants are settings you can adjust. Just look for Default_Font_Shadow or something and set it to false. I merely turned it on because I think it looks a little better. lol
 
Wow, I'm really surprised to find very little for the < Window_Base classes, especially these methods... feel free to add them, I use them in all of my window scene scripts, it makes even the most boring Window scene 100x better.

...At least I didn't see these in the MACL, so many lines I could've easily scrolled past it @_@

Code:
#===============================================================================
# ** Window_Base
#-------------------------------------------------------------------------------
# * Additional Methods
#   o move_to()
#   o x_move_to()
#   o y_move_to()
#   o fade_opacity()
#   o upgrade_color
#   o downgrade_color
#===============================================================================
class Window_Base < Window
  #-----------------------------------------------------------------------------
  # * Move To (X, Y, Speed, Opacity)
  #-----------------------------------------------------------------------------
  # o Written by  : Kain Nobel
  # o Description : Moves this window to designated X and Y Coordinates.
  # o Call Info   : x coordinate, y coordinate
  # o Optional    : speed (1..100), opacity (0...255)
  #-----------------------------------------------------------------------------
  def move_to(new_x, new_y, speed = 10, opacity = nil)
    unless self.x == new_x
      self.x -= ((self.x - new_x + 9) / speed).abs if self.x > new_x
      self.x += ((self.x - new_x + 0) / speed).abs if self.x < new_x
    end
    unless self.y == new_y
      self.y -= ((self.y - new_y + 9) / speed).abs if self.y > new_y
      self.y += ((self.y - new_y + 0) / speed).abs if self.y < new_y
    end
    fade_opacity(opacity, speed) unless opacity.nil?
  end
  #-----------------------------------------------------------------------------
  # * X Move To (Destination, Speed, Opacity)
  #-----------------------------------------------------------------------------
  # o Written by  : Kain Nobel
  # o Description : Moves this window to designated X Coordinate.
  # o Call Info   : x coordinate
  # o Optional    : speed (1..100), opacity (0...255)
  #-----------------------------------------------------------------------------
  def x_move_to(n = 0, speed = 10, opacity = nil)
    unless self.x == n
      self.x -= ((self.x - n + 9) / speed).abs if self.x > n
      self.x += ((self.x - n + 0) / speed).abs if self.x < n
    end
    fade_opacity(opacity, speed) unless opacity.nil?
  end
  #-----------------------------------------------------------------------------
  # * Y Move To (Destination, Speed, Opacity)
  #-----------------------------------------------------------------------------
  # o Written by  : Kain Nobel
  # o Description : Moves this window to designated X Coordinate.
  # o Call Info   : x coordinate
  # o Optional    : speed (1..100), opacity (0...255)
  #-----------------------------------------------------------------------------
  def y_move_to(n = 0, speed = 10, opacity = nil)
    unless self.y == n
      self.y -= ((self.y - n + 9) / speed).abs if self.y > n
      self.y += ((self.y - n + 0) / speed).abs if self.y < n
    end
    fade_opacity(opacity, speed) unless opacity.nil?
  end
  #-----------------------------------------------------------------------------
  # * Fade Opacity
  #-----------------------------------------------------------------------------
  # o Written by  : Kain Nobel
  # o Description : Fades this windows opacity in a certain ammount of frames.
  # o Optional    : n (Integer), speed (Integer)
  #-----------------------------------------------------------------------------
  def fade_opacity(n = nil, speed = 10)
    unless self.opacity == n or n.nil?
      self.opacity -= ((self.opacity - n) / speed).abs if self.opacity > n
      self.opacity += ((self.opacity - n) / speed).abs if self.opacity < n
    end
  end
  #-----------------------------------------------------------------------------
  # * Get Upgrade Text Color
  #-----------------------------------------------------------------------------
  # o Written by  : Kain Nobel
  # o Description : Common CMS method, defines equipment "upgrade color"
  #-----------------------------------------------------------------------------
  def upgrade_color
    return Color.new(0, 255, 0, 255)
  end
  #-----------------------------------------------------------------------------
  # * Get Downgrade Text Color
  #-----------------------------------------------------------------------------
  # o Written by  : Kain Nobel
  # o Description : Common CMS method, defines equipment "downgrade color"
  #-----------------------------------------------------------------------------
  def downgrade_color
    return Color.new(255, 0, 0, 255)
  end
end

Also, just a small addition to the initialize method in Window_Command. You call it like so...

@window_command = Window_Command.new(160, commands, 5) meaning that the window will show a max of 5 commands then scroll the rest.

Don't call the last arg and it'll just call it normally.

Code:
#===============================================================================
# ** Window_Command
#-------------------------------------------------------------------------------
#   This window deals with general command choices. This class's initialize
# method has been replaced to make command windows scrollable and default size
# to be set to a specified set of showable commands.
#===============================================================================
class Window_Command < Window_Selectable
  #-----------------------------------------------------------------------------
  # * Object Initialization
  #     width    : window width
  #     commands : command text string array
  #     size     : how many commands to be shown at a time (optional)
  #-----------------------------------------------------------------------------
  def initialize(width, commands, size = 1)
    # If Size isn't equal to 1, then use specified size to determine Command
    # Height, else return the commands size X 32
    height = size != 1 ? 32 + size * 32 : 32 + commands.size * 32
    # Compute window height from command quantity
    super(0, 0, width, height)
    @item_max = commands.size
    @commands = commands
    self.contents = Bitmap.new(width - 32, @item_max * 32)
    refresh
    self.index = 0
  end
end
 
The move_to method is actually managed in Trickster's Movable module. As for the window command addition... its rather pointless. I mean, you can just alter the windows height to show how many commands pretty easily. Not to cut it off, I just don't see anyone using.
 
SephirothSpawn":szkpkk8o said:
As for the window command addition... its rather pointless. I mean, you can just alter the windows height to show how many commands pretty easily. Not to cut it off, I just don't see anyone using.

It's just a lazy way to do it, incase anybody doesn't want to measure heigth :P

I use it all the time and it doesn't cut-off the command window, it just scrolls the commands. Other than that, it probably is better left out of the MACL.
 
I don't understand how the move_to function would even work right.  It doesn't seem to be tied to def update at all.  So, do you have to call move_to every frame from within the scene?

The modification on Window_Command seems good, to me, except that instead of setting size to 1 by default it should be non numeric, like nil, in case somebody wanted a command window that was really only 1 command high.  But it probably is redundant otherwise, like the almighty said.
 
how to use flip_horizontaly thing on my window bitmap class?

and i had this error on my first attempt "Could not confert My_Windows to bitmap"
 
Without your code an description of what you are doing, I have no clue. And make a topic in the RGSS Support Forums. This topic is for development discussion, installation support, etc.
 
oh thanks, i'am figuring out my self on my second attempts
i'll cut this from your flip_horizontally! def
here's the code
Code:
def iqbal_animated_faces(actor, x, y)
    face = RPG::Cache.battler(actor.battler_name, actor.battler_hue)
    fw = face.width
    fh = face.height
    src_rect = Rect.new(0, 0, fw, fh)
    if actor.direction != 1
      self.contents.blt(x - fw / 23, y - fh, face, src_rect)
    else
      width.times do |i|
        src_rect.x = width - 1 - i
        self.contents.blt(i - fw / 23, y - fh, face, src_rect)
      end
    end
  end 
unfortunately the x position of that face is also modified ... hmm i wonder

I'am sorry if i post this to this board but i really want to know about flip_horizontally example syntax inside your MACL
 
Ok. You just use this:

Code:
  def iqbal_animated_faces(actor, x, y)
    face = RPG::Cache.battler(actor.battler_name, actor.battler_hue)
    face.flip_horizontal! if actor.direction == 1
    self.contents.blt(x, y, face, face.rect)
  end

Much of that code was unneeded. You will probably need to modify your x and y positions, it all depends on your scripts.
 
Somehow I get the feeling he should have been credited already for authoring MACL, along with all the other contributors?  But that's not why I'm here...

I was just thinking about splitting up MACL into its many parts.  If it's a scripting tool, and most people get scripts by downloading demos and taking the scripts out of them, surely the authors of scripts must be capable of installing only the parts they need, putting them in the demo, and instructing their users to copy all of the scripts in the demo including the specific parts of MACL that they included?  Maybe this has been discussed or thought about before, and decided against because it apparently didn't work too well for the SDK, but the MACL is just so much damn bigger than SDK.
 
I am actually working on a tool for this. I may include it in next month's update if I finish it.

Basically, you put each script you have in your project into a txt file when your game is done. Then it reads through your scripts, checks method and class names. Whatever isn't used is deleted, and after running a module method, it creates a new MACL.txt file that you can replace with your MACL script.

I am still working out some kinks on it, but if all goes well, it'll be in the next edition. :)
 
When I noticed we had 16,000 lines and it took a little while longer than normal to load because of it (might just be my slow computer), I knew I had to do something.
 
mewsterus":33cpldiv said:
Somehow I get the feeling he should have been credited already for authoring MACL, along with all the other contributors?  But that's not why I'm here...
No, i'am not used a whole script it depend on users use it or no,t i'am including tricster method (Flip_Horizontal). i know i'am not good speaking english lol, but i know the rules of crediting and i'am crediting seph and tricks for their efforts
 
I've got the whole MACL and 45 of my own scripts in my project and don't suffer from too much lag, except sometimes during $scene changes (although there is one compatibility error I haven't hunted down yet). However, dividing it up into its own library and calling sections with a require would probably be alot nicer.

I've added some methods to my copy of the MACL, you might want to add these in for everybody. They're simple little methods, but they do make life a little easier. I've got 4 simple additions, enjoy :thumb:

MACL Section : RGSS.Map

Code:
  #-----------------------------------------------------------------------------
  # * Name      : This Event
  #   Info      : Simply returns event on, or event directly in front of you
  #   Author    : Kain Nobel
  #   Call Info : None
  #-----------------------------------------------------------------------------
  def this_event
    x, y, d = $game_player.x, $game_player.y, $game_player.direction
    new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
    new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
    for event in @events.values
      return event.id if event.x == x     && event.y == y
      return event.id if event.x == new_x && event.y == new_y
    end
  end

Code:
  #-------------------------------------------------------------------------
  # * Name      : Last event
  #   Info      : Simply returns the last event in $game_map.events array
  #   Author    : Kain Nobel
  #   Call Info : None
  #-------------------------------------------------------------------------
  def last_event
    return @events[-1].id unless @events.empty?
  end

Code:
  #-------------------------------------------------------------------------
  # * Name      : Event Count
  #   Info      : Simply counts how many events are on the $game_map
  #   Author    : Kain Nobel
  #   Call Info : None
  #-------------------------------------------------------------------------
  def event_count
    return @events.empty? ? 0 : @events.size
  end

MACL Section : Event_Spawner

And for the event spawner, I made a quick shortcut command to do call scripts. Instead of typing in...

Code:
add_event_command(355, [''])

You just type...

Code:
call_script([''], indent) # Again, indent is default 0

Code:
  #--------------------------------------------------------------------------
  # * Add Call Script
  #--------------------------------------------------------------------------
  def self.call_script(parameters = [], indent = 0)
    # Creates New Event Command
    event_command = RPG::EventCommand.new
    # Sets code, Parameters & Indent
    event_command.code = 355
    event_command.parameters = parameters
    event_command.indent = indent
    # Adds Call Script to page list
    self.get_current_page.list.insert(-2, event_command)
  end

As silly as it sounds, I want you to create an MInterpreter.call_script() for me, I really do need it for a user-defined module in my Vehicle system. I don't know how the Interpreter handles call script strings and converts them into actual code and evaluates them and all that, so I figured I'd just ask you to do it.
 
Ha. I beat ya to the this_event function a few days ago. But Instead I have
tile_front
tile_right
tile_left
tile_behind
event_front
event_right
event_left
event_behind

Great minds think alike I guess.

Your last_event methods is flawed. @events is a Hash, not an array. Not only that, it is going to return the same thing as your event_count. I'll put the event_count function in there though.

Ok. I guess I can go with both of your call_script suggestions.
 
I just noticed something...in the Screenshot module, it references a need for Screenshot.dll.  Since it doesn't seem to be named as a Windows registered library, I assume it's something I need to download, but there isn't a demo and I can't seem to find the file.

EDIT: Something I just thought of that would be interesting is a sort of checksum for save files and data files to assure they aren't hacked.  The files themselves would store a set of indeces (or a certain external checksum file would hold indeces for all the data files) that aren't in themselves checksums.  They would index a table of possible checksums, the values distributed randomly, like a random number table.  Each one would take certain specific bits from the file to compile a checksum instead of the entire file.  There are probably better ways to do it, as I've never put together any sort of data integrity algorithms before, but this is just my idea for the time being...stop me if somebody's already written something for this purpose...

EDIT2: And I figured out why my player sprite was not displaying correctly.  It had nothing to do with pixel movement.  It was because some modifications I've been making to Game_Battler have resulted in the player erroneously being .dead? and the recent Game_Character modifications in MACL used that to remove the player sprite.  This was all going wrong not because the player was actually dead, but because I used a '=' accidentally instead of a '==' 0_0
 
Today I got the idea of shortcuts for the command window. I don't know if there is anything like that already in the MACL.
Basically you can set two commands to be the shortcuts when you press the LEFT and RIGHT key (you usually have only one column, so they are unused). Here is how i implemented this. Feel free to revise the code if necessary and include it if you like the idea.

The class is Window_Command.
Changes to existing code:
Code:
  def initialize(width, commands)
    ...
    @left_shortcut=-1
    @right_shortcut=-1
  end
New methods:
Code:
  #-----------------------------------------------------------------------------
  # * Name      : Set Left Shortcut
  #   Info         : Sets the command to be the left shortcut
  #   Author     : Charlie Lee
  #   Call Info   : String s representing the command
  #-----------------------------------------------------------------------------
  def set_left_shortcut(s)
    for i in 0...@item_max
      if @commands[i]==s
        @left_shortcut=i
      end
    end
  end
  
  #-----------------------------------------------------------------------------
  # * Name      : Set Right Shortcut
  #   Info         : Sets the command to be the right shortcut
  #   Author     : Charlie Lee
  #   Call Info   : String s representing the command
  #-----------------------------------------------------------------------------
  def set_right_shortcut(s)
    for i in 0...@item_max
      if @commands[i]==s
        @right_shortcut=i
      end
    end
  end

  #-----------------------------------------------------------------------------
  # * Name      : Update
  #   Info         : Updates the selected command when a shortcut key is pressed
  #   Author     : Charlie Lee
  #   Call Info   : No Arguments
  #-----------------------------------------------------------------------------
  def update
    # If cursor is movable
    if self.active and @item_max > 0 and @index >= 0
      # If the right directional button was pressed
      if Input.repeat?(Input::RIGHT)
        # If the right shortcut is set
        if @right_shortcut >= 0
          $game_system.se_play($data_system.cursor_se) unless @index == @right_shortcut
          @index = @right_shortcut
        end
      end
      if Input.repeat?(Input::LEFT)
        # If the left shortcut is set
        if @left_shortcut >= 0
          $game_system.se_play($data_system.cursor_se) unless @index == @left_shortcut
          @index = @left_shortcut
        end
      end
    end
    super
  end
 

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