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.

Zelda Map Scroll Script Rewrite

Hi! I've been working really hard for the last couple of days, trying to fix the following script so that it will work in my project. The problem, it seems, is that the script is too volatile. My project base is the Zelda Starter Kit found here. I am trying to get it to work, and, as far as I can tell, the problem is that it is incompatable with any sort of pixel movement system. I'm also trying to get the script to only activate when a specific switch is on (let's just say switch 0001 for convenience). Anyway, the errors it gives me indicate function symbols "+", "-", "*", "/", "[]", "=", ">=", "<=", "==", or "!=" in apparently random locations in apparently random scripts as "undefined method "n" for nil:NilClass" (where "n" is one of the aforementioned functions or symbols).

Anyway, if someone could please edit this script so that it
1. Does not give the aforementioned errors.
2. Requires switch 0001 to be on to become active
3. Works with pixelmovement scripts.

And the whole point of the script is to create movement within a larger map as though it were formed of smaller maps that scroll between each other when you , like in dungeons in The Legend of Zelda.

#============================================================================
# ** Zelda Map Scroll
#----------------------------------------------------------------------------
# Yeyinde
# 1.1.0
# 05/26/07
# SDK Version : (2.2) - Parts: I, II
# Notes:
# Try and get your maps a nice even multiple size of 20x15. It makes the
# scrolling a tad bit better.
#============================================================================

#-----------------------------------------------------------------------------
# SDK Auto-installer
#-----------------------------------------------------------------------------
unless Object.const_defined?:)SDK)
begin
require 'SDK'
rescue LoadError
print 'This script (Zelda Map Scroll) requires the SDK to run.'
exit 1
end
end

#-----------------------------------------------------------------------------
# SDK Log
#-----------------------------------------------------------------------------
SDK.log('Zelda Map Scroll', 'Yeyinde', '1.10', '05/26/07')

#-----------------------------------------------------------------------------
# SDK Check Requirements
#-----------------------------------------------------------------------------
SDK.check_requirements(2.2, [1, 2])

#-----------------------------------------------------------------------------
# SDK Enabled Check
#-----------------------------------------------------------------------------
if SDK.enabled?('Zelda Map Scroll')

#==============================================================================
# ** Zelda_Map_Scroll
#------------------------------------------------------------------------------
# Customization module
#------------------------------------------------------------------------------
module Zelda_Map_Scroll
# How fast the screen will scroll (1 being the slowest, 7 being the fastest)
SCROLL_SPEED = 6
# If the player will wait for the scrolling to finish before moving again
SCROLL_WAIT = true
# How long the player will wait during each scroll (In frames)
SCROLL_WAIT_PERIOD_Y = 10
SCROLL_WAIT_PERIOD_X = 16
end

#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
# This class handles the player. Its functions include event starting
# determinants and map scrolling. Refer to "$game_player" for the one
# instance of this class.
#==============================================================================

class Game_Player
#---------------------------------------------------------------------------
# * Overwrite methods
#---------------------------------------------------------------------------
SDK.log_overwrite('Game_Player', 'center')
SDK.log_overwrite('Game_Player', 'update_scroll_down')
SDK.log_overwrite('Game_Player', 'update_scroll_left')
SDK.log_overwrite('Game_Player', 'update_scroll_right')
SDK.log_overwrite('Game_Player', 'update_scroll_up')
#---------------------------------------------------------------------------
# * Object Initialization
#---------------------------------------------------------------------------
def initialize
# Call superclass' initialize
super
# Make the wait while scrolling variable (Y)
@scroll_wait_y = RPG::MoveRoute.new
# Make it so it does not repeat
@scroll_wait_y.repeat = false
# Make the wait command
@scroll_wait_y.list[0].code = 15
@scroll_wait_y.list[0].parameters = [Zelda_Map_Scroll::SCROLL_WAIT_PERIOD_Y]
# Add a blank move command to signify the end
@scroll_wait_y.list << RPG::MoveCommand.new
# Make the wait while scrolling variable (X)
@scroll_wait_x = RPG::MoveRoute.new
# Make it so it does not repeat
@scroll_wait_x.repeat = false
# Make the wait command
@scroll_wait_x.list[0].code = 15
@scroll_wait_x.list[0].parameters = [Zelda_Map_Scroll::SCROLL_WAIT_PERIOD_X]
# Add a blank move command to signify the end
@scroll_wait_x.list << RPG::MoveCommand.new
end
#---------------------------------------------------------------------------
# * Set Map Display Position to Center of Screen
#---------------------------------------------------------------------------
def center(x, y)
# Get the maximum distance from the top-left corner
max_x = ($game_map.width - 20) * 128
max_y = ($game_map.height - 15) * 128
# Get the minimum distance to make
min_x = (x - x % 20) * 128
min_y = (y - y % 15) * 128
$game_map.display_x = [0, [min_x, max_x].min].max
$game_map.display_y = [0, [min_y, max_y].min].max
end
#--------------------------------------------------------------------------
# * Frame Update : Scroll Down
#--------------------------------------------------------------------------
def update_scroll_down(last_real_y)
# If character moves down off the display area
if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y * 2
# Scroll map down
$game_map.start_scroll(2, 15, Zelda_Map_Scroll::SCROLL_SPEED)
# Wait for scrolling to finish
force_move_route(@scroll_wait_y) if Zelda_Map_Scroll::SCROLL_WAIT
end
end
#--------------------------------------------------------------------------
# * Scroll Left
#--------------------------------------------------------------------------
def update_scroll_left(last_real_x)
# If character moves left off the display area
if @real_x < last_real_x and @real_x < $game_map.display_x
# Scroll map left
$game_map.start_scroll(4, 20, Zelda_Map_Scroll::SCROLL_SPEED)
# Wait for scrolling to finish
force_move_route(@scroll_wait_x) if Zelda_Map_Scroll::SCROLL_WAIT
end
end
#--------------------------------------------------------------------------
# * Scroll Right
#--------------------------------------------------------------------------
def update_scroll_right(last_real_x)
# If character moves right off the display area
if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X * 2
# Scroll map right
$game_map.start_scroll(6, 20, Zelda_Map_Scroll::SCROLL_SPEED)
# Wait for scrolling to finish
force_move_route(@scroll_wait_x) if Zelda_Map_Scroll::SCROLL_WAIT
end
end
#--------------------------------------------------------------------------
# * Scroll Up
#--------------------------------------------------------------------------
def update_scroll_up(last_real_y)
# If character moves up off the display area
if @real_y < last_real_y and @real_y < $game_map.display_y
# Scroll map up
$game_map.start_scroll(8, 15, Zelda_Map_Scroll::SCROLL_SPEED)
# Wait for scrolling to finish
force_move_route(@scroll_wait_y) if Zelda_Map_Scroll::SCROLL_WAIT
end
end
end

end
#-----------------------------------------------------------------------------
# End SDK Enabled Check
#-----------------------------------------------------------------------------
 

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