I'm modifying CXJk's Free Movement, but my Ruby experience is very limited. I'm modifying the script to make the player pause when they turn directions, so I can add animations for turning later. The crash happens in this section:
-on the line " if $wait_time <= 30". The crash reads:
This only occurs if the player walks diagonally as the first move of a new game. Any idea why this happens?
Thank you in advance for any help you can give me.
Code:
def interpret_move(step_left = distance_per_frame)
@move_poll = [] if @move_poll.nil?
if @move_poll.size > 0
current_move = @move_poll.shift()
d = current_move[0]
horz = (d - 1) % 3 - 1
vert = 1 - ((d - 1) / 3)
turn_ok = current_move[1]
if $wait_time <= 30
if turn_ok
set_direction(d)
end
end
oldturncheck = $turncheck
puts $turncheck
check_event_trigger_touch_front
processed = false
if (d % 2 == 0 && passable?(@x, @y, d)) || (d % 2 != 0 && diagonal_passable?(@x, @y, horz, vert))
if $wait_time == 0
process_move(horz, vert)
processed = true
end
elsif d % 2 != 0 && !diagonal_passable?(@x, @y, horz, vert)
if passable?(@x, @y, horz + 5)
set_direction(horz + 5) if turn_ok
if $wait_time == 0 then process_move(horz, 0)
processed = true
end
if passable?(@x, @y, 5 - vert * 3)
set_direction(5 - vert * 3) if turn_ok
if $wait_time == 0
process_move(0, vert)
processed = true
end
end
end
if(processed)
pixelstep = CXJ::FREE_MOVEMENT::PIXELS_PER_STEP / 32.0
if(step_left > pixelstep && !@move_poll.empty?)
interpret_move(step_left - pixelstep)
elsif(jumping? && !@move_poll.empty?)
interpret_move(0)
end
else
@move_poll.clear
end
current_move
end
end
end
-on the line " if $wait_time <= 30". The crash reads:
Code:
GaryCXJk's Free Movement:968:in `interpret_move': undefined method `<=' for nil:
NilClass, NoMethodError
from GaryCXJk's Free Movement:1488:in `interpret_move'
from GaryCXJk's Free Movement:934:in `update'
from Vlue's Fine Tuning Script:228:in `update'
from Hime's Flashing Events:136:in `update'
from Game_Player:303:in `update'
from Victor_Engine_Step_Sound:249:in `update'
from Scene_Map:63:in `update'
from Hime's Item Drop Script:415:in `update'
from AMN Combine Item w. Event:278:in `update'
from Scene_Base:14:in `main'
from SceneManager:23:in `run'
from Hime's Debugging Script:10:in `block in <main>'
This only occurs if the player walks diagonally as the first move of a new game. Any idea why this happens?
Thank you in advance for any help you can give me.