module Input
Q = :X
end
class Scene_Map
alias q_press_update update
def update
# Call the original update method
q_press_update
# Check if the Q key is pressed and if the player has the specific item
if Input.trigger?(Input::Q) && $game_party.item_number($data_items[21].id) > 0
# Get the current map ID, player coordinates and direction
map_id = $game_map.map_id
x = $game_player.x
y = $game_player.y
direction = $game_player.direction
# Calculate the target map ID based on the current map ID
if map_id < 40
target_map_id = map_id + 17
else
target_map_id = map_id - 17
end
# Play the teleport SE
$game_system.se_play($data_system.teleport_se)
# Reserve the transfer to the target map
$game_player.reserve_transfer(target_map_id, x, y, direction)
# Clear the scene variable to return to the map scene
$scene = nil
end
end
end