When using this script by Kain Nobel:
I get this error: Script "Jump" line 201: NameError occurred
undefined local variable or method 'move_direction' for #<Game_Player:0x70b2230>
Help?
Code:
#===============================================================================
# ** Jump
#===============================================================================
module Jump
################################################################################
# ~** CUSTOMIZABLE CONSTANTS - BEGIN **~ #
################################################################################
#-----------------------------------------------------------------------------
# * IDs of Maps which you aren't allowed to jump
#-----------------------------------------------------------------------------
Xclude_Maps = []
#-----------------------------------------------------------------------------
# * Distance (in tiles) that you regularly jump
#-----------------------------------------------------------------------------
Distance = 3
#-----------------------------------------------------------------------------
# * Are you able to jump over objects with Counter tags on them?
#-----------------------------------------------------------------------------
Counter_Pass = false
#-----------------------------------------------------------------------------
# * Jump Bonus gained from running (If using Run Script)
#-----------------------------------------------------------------------------
Run_Modifier = 1
#-----------------------------------------------------------------------------
# * Audiofile to be played when you jump
#-----------------------------------------------------------------------------
SE_Jump = RPG::AudioFile.new("015-Jump01", 80, 90)
#-----------------------------------------------------------------------------
# * Audofile to be played when you land
#-----------------------------------------------------------------------------
SE_Land = RPG::AudioFile.new("016-Jump02", 80, 90)
#-----------------------------------------------------------------------------
# * Input/Key to be used to trigger the player to jump
#-----------------------------------------------------------------------------
Button = Input::A
#-----------------------------------------------------------------------------
# * Does jumping repeat when you hold the Button?
#-----------------------------------------------------------------------------
Repeat = false
################################################################################
# ~** CUSTOMIZABLE CONSTANTS - END **~ #
################################################################################
#-----------------------------------------------------------------------------
# * Jump.play_audiofile
#-----------------------------------------------------------------------------
def self.play_audiofile(se)
case se.class.to_s
when "RPG::AudioFile"
unless se.name.include?("Audio/SE/")
se.name = "Audio/SE/" + se.name
end
Audio.se_play(se.name, se.volume, se.pitch)
when "String"
unless se.include?("Audio/SE/")
se = "Audio/SE/" + se
end
Audio.se_play(se, 100, 100)
when "Array"
n = se.size > 0 ? se[0] : ""
v = se.size > 1 ? se[1] : 100
p = se.size > 2 ? se[2] : 100
unless n.include?("Audio/SE/")
n = "Audio/SE/" + n
end
Audio.se_play(n, v, p)
end
end
#-----------------------------------------------------------------------------
# * Jump.se_jump
#-----------------------------------------------------------------------------
def self.se_jump
return play_audiofile(SE_Jump)
end
#-----------------------------------------------------------------------------
# * Jump.se_land
#-----------------------------------------------------------------------------
def self.se_land
return play_audiofile(SE_Land)
end
#-----------------------------------------------------------------------------
# * Jump.xclude_map?
#-----------------------------------------------------------------------------
def self.xclude_map?
xclude = Xclude_Maps.is_a?(Array) ? Xclude_Maps : []
return xclude.include?($game_map.map_id)
end
#-----------------------------------------------------------------------------
# * Jump.run_modifier
#-----------------------------------------------------------------------------
def self.run_modifier
return Run_Modifier.is_a?(Numeric) ? Run_Modifier : 0
end
end
#===============================================================================
# ** Game_Map
#===============================================================================
class Game_Map
#-----------------------------------------------------------------------------
# * Tile Blank?
#-----------------------------------------------------------------------------
def no_tile?(x, y)
[2, 1, 0].each do |i|
return true if data[x, y, i].nil?
end
return data[x, y, 2].zero? && data[x, y, 1].zero? && data[x, y, 0].zero?
end
#-----------------------------------------------------------------------------
# * Disable Dash?
#-----------------------------------------------------------------------------
def disable_jump?
return Jump::XcludeMaps.include?(@map_id)
end
end
#===============================================================================
# ** Game_Character
#===============================================================================
class Game_Character
#-----------------------------------------------------------------------------
# * Alias Listings
#-----------------------------------------------------------------------------
alias_method :character_jump, :jump
alias_method :character_update_jump, :update_jump
alias_method :no_tile_passable?, :passable?
#-----------------------------------------------------------------------------
# * Jump
#-----------------------------------------------------------------------------
def jump(x_plus, y_plus)
Jump.se_jump
character_jump(x_plus, y_plus)
end
#-----------------------------------------------------------------------------
# * Update Jump
#-----------------------------------------------------------------------------
def update_jump
character_update_jump
if @jump_count.zero?
Jump.se_land
end
end
#-----------------------------------------------------------------------------
# * Passable?
#-----------------------------------------------------------------------------
def passable?(x, y, d)
new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
return $game_map.no_tile?(new_x, new_y) ? false : no_tile_passable?(x, y, d)
end
end
#===============================================================================
# ** Game_Player
#===============================================================================
class Game_Player < Game_Character
#-----------------------------------------------------------------------------
# * Alias Listings
#-----------------------------------------------------------------------------
alias_method :jump_player_update, :update
#-----------------------------------------------------------------------------
# * Update
#-----------------------------------------------------------------------------
def update
jump_player_update
unless Jump.xclude_map? || jumping? || !jump_valid?
if Jump::Repeat ? Input.press?(Jump::Button) : Input.trigger?(Jump::Button)
case @direction
when 2 # Jump Down / Down-Left || Down-Right
if attempt_lower_left? ; jump(-(jump_dist-1), (jump_dist-1))
elsif attempt_lower_right? ; jump((jump_dist-1), (jump_dist-1))
else ; jump(0, jump_dist)
end
when 4 # Jump Left / Up-Left / Down-Left
if attempt_upper_left? ; jump(-(jump_dist-1), -(jump_dist-1))
elsif attempt_lower_left? ; jump(-(jump_dist-1), (jump_dist-1))
else ; jump(-jump_dist, 0)
end
when 6 # Jump Right / Up-Right / Down-Right
if attempt_upper_right? ; jump((jump_dist-1), -(jump_dist-1))
elsif attempt_lower_right? ; jump((jump_dist-1), (jump_dist-1))
else ; jump(jump_dist, 0)
end
when 8 # Jump Up / Up-Left / Up-Right
if attempt_upper_left? ; jump(-(jump_dist-1), -(jump_dist-1))
elsif attempt_upper_right? ; jump((jump_dist-1), -(jump_dist-1))
else ; jump(0, -jump_dist)
end
end
end
end
end
#-----------------------------------------------------------------------------
# * Jump Valid ?
#-----------------------------------------------------------------------------
def jump_valid?
return $DEBUG if Input.press?(Input::CTRL)
case move_direction
when 1
return false if self.y > $game_map.height - Jump::Distance
return false if self.x < Jump::Distance
when 3
return false if self.y > $game_map.height - Jump::Distance
return false if self.x > $game_map.width - Jump::Distance
when 7
return false if self.y < Jump::Distance
return false if self.x > $game_map.width - Jump::Distance
when 9
return false if self.y < Jump::Distance
return false if self.x < Jump::Distance
end
case @direction
when 2 ; return false if self.y > $game_map.height - Jump::Distance
when 4 ; return false if self.x < Jump::Distance
when 6 ; return false if self.x > $game_map.width - Jump::Distance
when 8 ; return false if self.y < Jump::Distance
end
unless Jump::Counter_Pass == true
0.upto(Jump::Distance) do |i|
case move_direction
when 1 ; return false if $game_map.counter?(self.x-i, self.y+i)
when 3 ; return false if $game_map.counter?(self.x+i, self.y+i)
when 7 ; return false if $game_map.counter?(self.x-i, self.y-i)
when 9 ; return false if $game_map.counter?(self.x+i, self.y-i)
end
case @direction
when 2 ; return false if $game_map.counter?(self.x, self.y+i)
when 4 ; return false if $game_map.counter?(self.x-i, self.y)
when 6 ; return false if $game_map.counter?(self.x+i, self.y)
when 8 ; return false if $game_map.counter?(self.x, self.y-i)
end
end
end
return true
end
#-----------------------------------------------------------------------------
# * Jump Dist
#-----------------------------------------------------------------------------
def jump_dist
spaces = Array.new
(Jump::Distance).downto(0) do |i|
if SDK.enabled?('Player.Run') && Object.const_defined?(:Run)
i += Jump.run_modifier if $game_player.running?
end
i -= 1 if attempt_diagonal? || moving_diagonal?
j = i + 1
case move_direction
when 1 ; spaces.push(j) if passable?(self.x-i, self.y+i, 0)
when 3 ; spaces.push(j) if passable?(self.x+i, self.y+i, 0)
when 7 ; spaces.push(j) if passable?(self.x-i, self.y-i, 0)
when 9 ; spaces.push(j) if passable?(self.x+i, self.y-i, 0)
end
case @direction
when 2 ; spaces.push(j) if passable?(self.x, self.y+i, @direction)
when 4 ; spaces.push(j) if passable?(self.x-i, self.y, @direction)
when 6 ; spaces.push(j) if passable?(self.x+i, self.y, @direction)
when 8 ; spaces.push(j) if passable?(self.x, self.y-i, @direction)
end
end
return spaces.empty? ? 0 : spaces.first
end
end
undefined local variable or method 'move_direction' for #<Game_Player:0x70b2230>
Help?