19 May 2009

Time/Date Formats

In yesterday's entry, System Time/Date Script, I showed how to use the built-in Time function to display the current (system) time and date.

To change format, the strftime method has a number of options available.

Its basic format is

strftime(format)

where format is the format string to be used, which may be specified with the following:
  • %A - Full day of the week (Sunday, Monday, etc.)
  • %a - Abbreviated day of the week (Sun, Mon, etc.)
  • %B - Full month (January, February, etc.)
  • %b - Abbreviated month (Jan, Feb, etc.)
  • %c - Current Date and Time (system clock format)
  • %d - Day of the month (01-31)
  • %H - Time of day in 24-hour format (00-23)
  • %I - Time of day in 12-hour format (01-12)
  • %j - Day of the year (001-366)
  • %M - Minutes (00-59)
  • %m Numerical month of the year (01-12)
  • %p - Displays AM or PM after the time
  • %S - The number of seconds (00-60, 60 being a "leap second")
  • %U - Week of the year, the first week starting with the first Sunday (00-53)
  • %W - Week of the year, the first week starting with the first Monday (00-53)
  • %w - Day of the week (0-6, 0 denoting Sunday)
  • %X - Displays the Time
  • %x - Displays the Date
  • %Y - Displays the Year as a 4-digit number (2009)
  • %y - Displays the Year as a 2-digit number (00-99)
  • %Z - Displays the default (system) Time Zone
  • %% - Displays a % character
Note that this is case sensitive.

So, as an example, to display the full date, including day, month and year, strftime would be set to:

strftime = ("%A, %d %B, %Y")


The result would be

Tuesday, 20 May, 2009

And that's it!

System Time/Date Script

RMXP and RMVX has a built-in Time function that allows the display of the current date and time (based on the system clock). I found this by accident while sifting through the Help file - actually while searching for Bitmap and Sprite management - and after some experimentation discovered how to place it in windows.

To use it, there are two functions to be aware of:

Time.now

This reads the current time and date from the system clock.

strftime("%I:%M:%S %p")

This converts the time into a string, using the time of day (in 12-hour format), minutes and seconds, as well as showing AM/PM.

So to add the time and date, we can add the following:

t = Time.now
time = t.strftime("%I:%M:%S %p")
date = t.strftime("%a, %d %b, %Y")

What this will do is store the time/date stamp format into variables and convert them to strings so that they can then be "drawn" in a window.

In RMXP, the following script can be used to replace the default. In RMVX, create a new script called Window_PlayTime:
#=================================================================
# ** Window_PlayTime
#-----------------------------------------------------------------
#  This window displays play time on the menu screen.
#=================================================================
class Window_PlayTime < Window_Base
  #---------------------------------------------------------------
  # * Object Initialization
  #---------------------------------------------------------------
  def initialize
    super(0, 0, 160, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  #---------------------------------------------------------------
  # * Refresh
  #---------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.size = 16
    t = Time.now
    time = t.strftime("%I:%M:%S %p")
    date = t.strftime("%a, %d %b, %Y")
    self.contents.font.color = normal_color
    self.contents.draw_text(0, -2, 140, WLH, date, 1)
    self.contents.draw_text(0, 14, 140, WLH, time, 1)
  end
  #---------------------------------------------------------------
  # * Frame Update
  #---------------------------------------------------------------
  def update
    super
    if Graphics.frame_count / Graphics.frame_rate != @total_sec
      refresh
    end
  end
end
RMXP will display the replacement time/date in the default "Play Time" window on the menu status.

To make this work in RMVX, add the following to Scene_Menu:

In the start definition routine, add

@window_playtime = Window_PlayTime.new
@window_playtime.x = X
@window_playtime.y = Y

where X and Y are the x- and y-coordinates for the window placement.

Add the following to the terminate definition routine:

@window_playtime.dispose

This is to ensure that the window doesn't stay onscreen when the status menu has been exited.

And finally, add the following to the update definition routine:

@window_playtime.update

This is to ensure that the time refreshes every second while on the status menu.

The resultant "Play Time" window should now contain the current time and date, thus:

Tue, 19 May, 2009
12:33:22 PM

And that's it, but the strftime element does have a number of different format options, which I'll detail in the next entry.

Miscellaneous Utilities

A number of useful utilities to aid in game-making with RM2K3 have been produced, aside from the Character Creators.

The following utilities are designed for "hacking" resources:

  • ResHack (RM2K/3) - Short for Resource Hack, this great utility allows the hacking of games or RM2K. With it, game icons, text, etc. can be modified to suit individual needs.
  • RM Reck (RM2K/3) - Similar to ResHack (above), it allows game icon, glyphs, and even logo screens to be changed. This is compatible with both RM2K and RM2K3.
  • Animget - This useful utility enables ripping of sprites and other animations, mostly from emulators. Once it's been activated, it runs in the background and saves snapshots every 0.1 seconds for appropriate resource modification later.

Other useful programs that can be used are:

  • RMTool (RM2K/3) - It scans RPG Maker games for missing files and gives instructions on how to fix it. For example, if a MIDI or particular graphics file is missing from the game's Project folder, this tool will tell you which one is missing. Note that it was specifically made for RM2K, but works as well with RM2K3, except for 2K3-specific folders (i.e. System2, BattleChars, CharSets, etc.); they just won't be scanned.
  • Zorn's RM2K Tool (Direct Download) - A solid utility that allows random creation of Game Titles, Hero Names, Item Names, Equipment Names and Skill Names (using an editable external text file). It also has a few tutorials built in. These have been designed for RM2K, but should also work with RM2K3.

Window & Scene Wizard

If you're like me and *hate* making windows and their accompanying scenes - at least when it comes to positioning onscreen - there is a useful utility called the Window & Scene Wizard (WSW). Actually it's compiled using RGSS and runs standalone or from with RMXP itself.

You can find a demo, along with instructions and downloads, at Creation Asylum. Note: The first download site no longer hosts the files, so be sure to use the second download site instead.

The WSW works very well, using the mouse and keyboard fluently to create windows. You can create ordinary windows as well as menus, add text, icons and pictures, as well as parameters and other details.

When your finished product is saved, the Window and Scene scripts will be saved in .TXT format. From there you can copy and paste into RMXP and use them for your newly created windows.

The only problem I have with the WSW, however, is that if you create a blank window (or a set of blank positioned windows), it also contains extra, generic crap you don't really need. It's not difficult to delete it, but if you don't know too much about RGSS, it can mess up and you'll receive a few errors.

Work on the WSW stopped after v1.0, since the final entry in the forum was back in 2006, and nothing else has become of it. It's still a good program/utility nevertheless, for learning more about RGSS if for nothing else.
17 May 2009

System Graphics - Part 2

System 2 is the "Battle Menu Set", used in battles to determine the cursor for targeting enemies and allies. It also displays the ATB bar and the numbers for HP and MP display in gauge type battles (set in the "Battle Layout" options of the Database).

All In Gold
This was the first I ever created (or re-created would be more accurate). The numbers on the gauge aren't really that clear, but I kept it as is for posterity.




System2 Template
This is a "default" template for creating your own System2 designs. The image size is 8x96.





This template shows the component elements of the above template.

1: The three-frame animation sequence for the left arrow.

2: The three-frame animation sequence for the down arrow.

3: The numbers for displaying HP and SP values.

A, B and C are the frames for the HP, SP and ATB bars respectively.

D: This is usually kept blank (although I'm not entirely sure what this is used for).

E: These five blocks are for the gauge colors, displayed when the "Battle Layout" is set to "Gauge".

F: This is the gauge for the ATB, which you'll note has two bars instead of one.

Adding Window Text Effects

Using the built-in RGSS/2 script, we can add some cool effects for enhancing or beautifying text, if used properly. These include a shadow effect and outlined text. Both of these scripts should work in both RMXP and RMVX, although I think there's an added font feature in RMVX for creating shadow effects without script.)

Shadow Effect

Add the following to Window_Base:
#---------------------------------------------------
# * Draw Shadow
#     x    : draw spot x-coordinate
#     y    : draw spot y-coordinate
#     w    : width
#     h    : height
#     text : text to display
#----------------------------------------------------
def draw_shadow(x, y, w, h, text)
  # Display shadow/shadow color
  self.contents.font.color = Color.new(200, 200, 200, 205)
  self.contents.draw_text(x + 4, y + 4, w, h, text, 1)
  # Display normal color text
  self.contents.font.color = system_color
  self.contents.draw_text(x, y, w, h, text, 1)
end
This will set up the "define procedure" to place it in windows. As an example, in Window_Steps, replacing this line:

self.contents.draw_text(4, 0, 120, 32, "Step Count")

with this line:

draw_shadow(4, 0, 120, 32, "Step Count")

will result in "Step Count" having a whitish-grey shadow.


Outline Effect

This routine will give the text an outline, which might be used for main headings.

Add the following to Window_Base:
#--------------------------------------------------
# * Draw Outline
#     x    : draw spot x-coordinate
#     y    : draw spot y-coordinate
#     w    : width
#     h    : height
#     text : text to display
#---------------------------------------------------
def draw_outline(x, y, w, h, text)
  self.contents.draw_text(x + 1, y * 32 + 1, w, h, text, 1)
  self.contents.draw_text(x - 1, y * 32 + 1, w, h, text, 1)
  self.contents.draw_text(x + 1, y * 32 - 1, w, h, text, 1)
  self.contents.draw_text(x - 1, y * 32 - 1, w, h, text, 1)
  self.contents.font.color = Color.new(250, 250, 250, 255)
  self.contents.draw_text(x, y * 32, w, h, text, 1)
end

Then, as an example, in Window_Steps, replace this line:

self.contents.draw_text(4, 0, 120, 32, "Step Count")

with this line:

draw_outline(4, 0, 120, 32, "Step Count")

In the Status Menu, the "Step Count" will now have an outlined effect.

Simple Font Draw

As the title suggests, this is a simple routine for redefining fonts, such as name, size, bold, italic, etc. Although this was written in RMXP, it should also work in RMVX. The default format for manipulating fonts is:

self.contents.font.name = "Font Name"
self.contents.font.size = 22

and so on.

But there is a way to merge the different properties into one procedure by adding the following to Window_Base:
#-------------------------------------------
# * Draw font status
#     bold    : Bold on/off
#     italic  : Italic on/off
#     size    : Font size
#     color   : Font color
#-------------------------------------------
def draw_font(bold, italic, size, color)
  # Check bold on/off
  case bold
  when 0
    self.contents.font.bold = false
  when 1
    self.contents.font.bold = true
  end
  # Check italic on/off
  case italic
  when 0
    self.contents.font.italic = false
  when 1
    self.contents.font.italic = true
  end
  # Change Color
  case color
  when 0
    self.contents.font.color = system_color
  when 1
    self.contents.font.color = normal_color
  when 2
    self.contents.font.color = Color.new(255, 255, 255, 255)
  end
  # Font size
  self.contents.font.size = size
end
Whenever fonts need to be "drawn", something like this would be called in RGSS when the font and its properties are called:

draw_font(1, 0, 22, 1)

This would result in bold 22-size font, set at the default "System Color" (also predefined in the Window_Base).

Other properties can easily be added using the same method. Anything predefined in this way is used as a template for all windows, including the Status and menu screens.

System Set - Tutorial Part 1 (RM2K3)

System graphics, in the System folder, are used for the Main and Battle menus. These are some I created (modified) a while ago. They are free to use for any RM2K3 game.

System Sets


Here are two basic system sets I created using the templates below.

Gold Frame
This system set sports a gold frame on a black background that gives it a royalty feel.




Parchment
This system set has a parchment background to give games an archaic look and feel.




System Templates


Here are some basic templates to enable you to make your own custom system sets.

This is the basic System layout that determines how the messages appears, including text colors. System sets (imported in the System folder) are for the main interface. The image size is 160x80.


Breaking the template down into its component parts, we can have a better understanding about how the components work.

A: Size: 32x32. This is the background color of the window.

B: Size: 32x32. This is the frame around the window and up and down arrows for scrolling through options. The arrows are 8x8 in size.

C: Size: 32x32. These two are the patterns used for the command cursor. If they are two different patterns, the cursor will flash rather than be static if they are both the same.

D: These are the four animated arrows used in shops. Each is 8x8 in size, comprising four frames each. The first row is for stat increases, the second is for unequippable items, the third is for stat decreases, and the fourth is when an item is already equipped.

E: Size: 16x16. This is the background color of the menu, used as "opacity".

F: Size: 16x16. This is the letter shadow color, displayed "behind" the letters to give it a shadow effect.

G: These are the numbers used for timers. There are twelve in total, each one 8x16 in size and comprising a set of two numbers, with the last one a colon (or other separator).

H: Size: 16x16. These are the two shadows for airships, which are displayed on the map whenever an airship is used as a vehicle.


The last two rows are for the twenty basic colors used in the game. Each is 16x16 in size. The first four are the "system" colors, where:

0: The default text color.
1: The stats default color.
2: The color for when stats increase.
3: The color for when stats decrease or when commands are unavailable.
4: The color for when HP or SP decrease.
04 May 2009

RPG Maker XP vs VX

Having experimented with both RMVX and RMXP for a while now, I have to say that ultimately I still prefer RMXP. There are a number of reasons for this and most of these are because many features available in RMXP were omitted in RMVX. This doesn't really detract from the game-making capability of the program, it's more of an annoyance and inconvenience.

Omissions in RMVX


Following is the list of some of the event commands removed from RMVX. Most (if not all) of these can be reproduced via scripts.

  • Change Text Options - This one has been integrated in the Show Text command in RMVX, along with another option, "Batch Entry", which allows multiple text entries. It automatically splits the text into further text boxes if the 4 default line limit is reached.
  • Button Input Processing - This was one of those commands carried over from RM2K/3, which wasn't really necessary since most keypress processing can be done with scripts.
  • Change Windowskin - This useful command was omitted in RMVX. While windowskins can be changed in RGSS2 by changing the "Window" default skin, I found this command useful as part of the options for changing themes. The disadvantage of its removal (without scripting it into the game) is that only the default windowskin can be changed in Window_Base.
  • Change Map Settings - This command enabled controls for the Panorama (Parallax), Fog and Battle Background graphics, all of which have been omitted in RMVX. These commands can still be emulated with scripts, but it's a major inconvenience.
  • Change Fog Color Tone and Change Fog Opacity - These were additional options for manipulating the Fog effects. Again, scripts can be used to emulate these effects, but it's inconvenient.
  • Wait For Move's Completion - In my opinion, this was a useless command, since it's an option in the Set Move Route command.
  • Prepare for Transition and Execute Transition - I never used these commands, but their purpose was to change the way the screen transitioned between battles. Since it has been omitted in RMVX, it only has one default named "BattleStart" in the Graphics/System folder. A new one can be imported and used, provided its name is "BattleStart", which supersedes the default. It can also be changed via script using the Graphics.transition command.
  • Memorize BGM/BGS and Restore BGM/BGS - These were two more commands imported from RM2K/3. Again I never used them in RMXP (but did in RM2K3), but their purpose was to remember certain background musics and sounds and recall them later. There's really no need for them, so omitting them in RMVX isn't necessarily a bad thing.
  • Deal Damage - This command allowed a specific amount of damage to be inflicted on enemies, used particularly in cut scenes. Again, it can be emulated with scripts, but it's annoying nevertheless that it's missing in RMVX.

Some of the other omissions/changes are:
  • Map Tilesets - Map tilesets are fixed in RMVX, divided into Tiles. There are no options to change them or add additional tilesets or autotiles, as there was in RMXP. There are now basically 5 tiles, including TileE, which is kept blank for "user tiles". These default tilesets are very limiting when making maps and don't allow many options. I think I've seen a script somewhere that enables tileset changing, using complete user-created tilesets completely replacing the default ones (they are named the same, i.e. TileA1, TileA2, etc. through TileE), but haven't ever tried it, let alone create my own.
  • Multiple Icons - Instead of having separate icons for each item, RMVX uses a single iconset capable of "storing" 256 icons. While this has its advantages and disadvantages, again the default Iconset is limiting. The main advantage is that a single sheet can be smaller than 256 individual icons and the major drawback is that only the default Iconset must be used (or replaced with a new one named "IconSet"). It is possible to use multiple Iconsets using RGSS2, but I'll have to go into that in a future entry.


Additional Features in RMVX


Not only has the Ruby script (RGSS2) been improved, but there are some additional commands and features lacking in RMXP.
  • Set Vehicle Location and Get on/off Vehicle - This command is an import from RM2K/3 that seems to have been omitted in RMXP, but has returned in RMVX. Vehicles in RMXP were controlled using events instead.
  • Show Balloon Icon - Balloon Icons are animations above characters' heads designed to simulate their emotions. I like this feature, as previously they had to be created manually and used as Battle Animations.
  • Fadeout Screen and Fadein Screen - Useful for effects between cut scenes or map transitions, these commands fade the screen to and from black.
  • Change Vehicle Graphic - This command simply allows the vehicle graphics to be changed into something else, lacking in RMXP except through events using Set Move Route. As an example of its use, a vehicle can be changed if it has been upgraded (think Final Fantasy III where the boat changes to a submarine and airship).
  • Facesets - The reimplementation of Facesets, lacking in RMXP, is a welcome one. Facesets in RMXP were still possible, but using script methods.


In RGSS2, some additional features have been added, such as text shadows, which is quite a useful effect for emphasis or titles. Some of these I'll cover in a future entry.
03 May 2009

Windowskins

While playing around with the Windowskin Generator I mentioned in a previous entry, I've created some cool Windowskins for use in games.

Old Leather Windowskin



Oceanic Windowskin



Grassy Windowskin



To change the default "Window" skin to one of these ones, right-click to save them onto the hard drive. Import them into RMVX and look in Window_Base for the following:
self.windowskin = Cache.system("Window")
It should be on line 21 by default. Simply replace the default file name with one of the others to use the new windowskin.
02 May 2009

Change Parallax Script

One of many features disabled in RMVX is the ability to change the Parallaxes, which was available in RMXP (and RM2K/3 before that) directly from the Event Commands. Parallaxes are graphics (usually of clouds or distant landscapes) that can scroll behind a map. While it is possible to set the parallax graphic in the map settings only, this "one parallax per map" rule is rather annoying.

As I start learning RGSS, the scripting language used by RMXP and RMVX, and familiarize myself with its nuances, being able to find workarounds and tweaks is half the fun.

A simple but effective (and certainly not perfect) method for changing parallaxes is with a small script.

  • Look in the Game_Map section of the scripts for Scroll Setup and Parallax Background Setup.
  • Place the following between these two sections:
    #----------------------------------------------
    # * Parallax Presetup - Change Parallax
    #----------------------------------------------
    def change_parallax(parallax_name)
        case parallax_name
        when 1
          @parallax_name = "BlueSky"
        when 2
          @parallax_name = "CloudySky"
        when 3
          @parallax_name = "Mountains"
        when 4
          @parallax_name = "Ocean"
        when 5
          @parallax_name = "StarlitSky"
        when 6
          @parallax_name = "Sunset"
        end
      end
    Add any other imported Parallax graphics by adding more "when" commands accordingly. Note: New parallax graphics must be first imported into RMVX under Graphics/Parallaxes.
  • To use an event to change the parallax graphic, use the Script function and place the following:
    $game_map.change_parallax(x)
    where x is the number corresponding to the desired parallax.

Note: With this method, if the Loop Coordinates aren't set directly on the map (via the Map Properties), the parallax will remain static. By changing the Horizontal Loop and/or Vertical Loop settings here it will make the parallax graphic scroll in the background.

Windowskin Generator

There haven't been many updates recently because I've been offline for the past three or so weeks. Our ISP decided to double their monthly fees overnight and without telling us, then demanded that we pay around $400 to reconnect. And they would only accept the full amount before reconnecting. (I wanted to pay them direct at their office with an envelope full of leaves, since "money grows on trees" apparently!)

Anyway, moving on...

I found this awesome and very useful utility. It's a Windowskin Generator for RMVX and it works!

The idea behind this is to make Windowskin creation easy by selecting various parts and applying them to the skin. It even has a preview area where you can see what the resultant image will look like! Once you're done, the finished product can be saved and imported into RMVX for use in your games.

Read a mini-review here or download it directly here, then extract it to the RMVX Projects folder (using WinRar or Winzip) and open it up in the RMVX program.

It can be run directly from RMVX or as a standalone program. If used as standalone, the RGSS2002e.dll may be needed. Information on creating and running standalone games (including downloading the appropriate files) can be found on the RPG RPG Revolution forum.
Related Posts with Thumbnails
Template Design "Perfect World" by SkinCorner