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.

4 Comments So Far:

arekpowalan said...

This helps me a lot. Thank you very much.

Companion Wulf said...

You're welcome. Glad you found it useful. :)

Companion Wulf said...

Hello, Tried to use your script, but I got this error:

Script: game interpreter line 1411 argument error occurred.

wrong number of arguments (1 for 5)

Copy of 1411
end
#--------------------------------------------------------------------------
# * Script
#--------------------------------------------------------------------------
def command_355
script = @list[@index].parameters[0] + "\n"
while next_event_code == 655
@index += 1
script += @list[@index].parameters[0] + "\n"
end
eval(script)
end
end

Companion Wulf said...

I tested this and it works fine, so it would appear that another script is conflicting. Line 1411 (according to RMVX) is "Change EXP".

The above "command_355" doesn't appear to be correct. Search for other references from other scripts that may directly modify this command.

This is directly from RMVX:

def command_355
script = @list[@index].parameters[0] + "\n"

loop do
if @list[@index+1].code == 655

script += @list[@index+1].parameters[0] + "\n

2

else

break

end

@index += 1

end

eval(script)

return true

end

Post a Comment

Related Posts with Thumbnails
Template Design "Perfect World" by SkinCorner