Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # Simple Teleport
- # Author: Nicke
- # Created: 17/12/2011
- # Edited: 23/12/2011
- # Version: 1.1
- #==============================================================================
- # Instructions
- # -----------------------------------------------------------------------------
- # To install this script, open up your script editor and copy/paste this script
- # to an open slot below ? Materials but above ? Main. Remember to save.
- #
- # To use this script simply use the script command in a event to add a
- # teleport id.
- #
- # To call this scene in a menu or on the map simply use the following code:
- # $scene = Scene_Teleport.new
- #
- # Note: It will show a text instead if no teleport id(s) is found.
- #
- # Examples:
- # tp_add(1)
- # tp_add(2)
- # tp_del(1)
- #
- # To get the player to be teleported to a specific x and y coordinates use an
- # event and inside it create a comment for it with the same text as TEXT_SPAWN.
- # This will make the event the place to be teleported to within the map.
- #
- # If no such event exists on the map it will use the previous x and y position of
- # the player when teleporting on to the new map.
- #
- # You should always have a spawn event so you know where the player will be
- # teleported to. (Don't add more then one spawn event on each teleport maps.)
- #
- #==============================================================================
- ($imported ||= {})["NICKE-SIMPLE-TELEPORT"] = true
- module NICKE
- module TELEPORT
- #--------------------------------------------------------------------------#
- # * Settings
- #--------------------------------------------------------------------------#
- # Teleport Window [ Columns, x, y, z, opacity ]
- WINDOW = [3, 0, 0, 200, 255]
- # Should a animation be used when teleporting to a new map.
- # Set it to nil to disable it.
- ANIM_ID = 88
- # Texts.
- TEXT_SPAWN = "TeleporterSpawn"
- TEXT_NO_TELEPORTS = "You haven't found a location to teleport to."
- # Use a image as background instead.
- # Set to nil to disable.
- BACK = nil
- # Transition when opening the scene.
- # Set to nil to use default.
- # TRANSITION [ SPEED, TRANSITION, OPACITY ]
- # TRANSITION = [40, "Graphics/Transitions/1", 50]
- TRANSITION = nil
- # Fade out time when teleporting to a new map.
- FADE_TIME = 80
- # Return scene
- # Set to nil to return to map instead.
- # RETURN_SCENE = Index to return to in the menu.
- RETURN_SCENE = 5
- # TELEPORT_LIST [ MAP_ID, Teleport name ]
- TELEPORT_LIST = [] # Don't remove!
- TELEPORT_LIST[0] = [4, 'Fine Village']
- TELEPORT_LIST[1] = [18, 'A Town']
- TELEPORT_LIST[2] = [13, 'Townhold']
- TELEPORT_LIST[3] = [17, 'Cave']
- end
- end
- # *** Don't edit below unless you know what you are doing. ***
- #==============================================================================#
- # ** Game_Map
- #------------------------------------------------------------------------------
- # Method for getting the teleport spawn.
- #==============================================================================#
- class Game_Map
- def teleport_spawn
- for event in @events.values
- next if event.nil?
- next if event.list.nil?
- for e in event.list
- # // Check every event to see if the teleport spawn text exist in a event.
- if e.code == 108 && e.parameters[0].include?(NICKE::TELEPORT::TEXT_SPAWN)
- # // Move the player to the spawn event.
- $game_player.moveto(event.x, event.y)
- else
- # // If none found use the player's x/y position instead.
- # // * Not recommended to use. *
- $game_player.moveto($game_player.x, $game_player.y)
- end
- end
- end
- end
- end
- #==============================================================================#
- # ** Game_System
- #------------------------------------------------------------------------------
- # Method for checking the teleport list.
- #==============================================================================#
- class Game_System
- attr_accessor :teleport_list
- alias nicke_teleport_sys_initialize initialize unless $@
- def initialize(*args, &block)
- nicke_teleport_sys_initialize(*args, &block)
- @teleport_list = []
- end
- end
- #==============================================================================#
- # ** Game_Interpreter
- #------------------------------------------------------------------------------
- # Method for adding and deleting a teleport.
- #==============================================================================#
- class Game_Interpreter
- def tp_add(id)
- # // Method to add a teleport from the list.
- unless $game_system.teleport_list.include?(NICKE::TELEPORT::TELEPORT_LIST[id])
- $game_system.teleport_list.push(NICKE::TELEPORT::TELEPORT_LIST[id])
- end unless NICKE::TELEPORT::TELEPORT_LIST[id].nil?
- end
- def tp_del(id)
- # // Method to delete a teleport from the list.
- unless NICKE::TELEPORT::TELEPORT_LIST[id].nil?
- $game_system.teleport_list.delete(NICKE::TELEPORT::TELEPORT_LIST[id])
- end
- end
- end
- #==============================================================================#
- # ** Scene_Teleport
- #------------------------------------------------------------------------------
- # New Scene :: Scene_Teleport
- #==============================================================================#
- class Scene_Teleport < Scene_Base
- def initialize(index = 0)
- @teleport_index = index
- end
- def start
- super
- create_menu_background
- create_command_window
- end
- def create_command_window
- teleport_menu = []
- @teleport_list = $game_system.teleport_list
- @message_window = Window_Message.new
- if @teleport_list.empty?
- Sound.play_buzzer
- $game_message.texts << NICKE::TELEPORT::TEXT_NO_TELEPORTS
- $scene = Scene_Map.new
- else
- for i in @teleport_list
- teleport_menu << i[1]
- end
- @teleport_window = Window_Command.new(Graphics.width, teleport_menu, NICKE::TELEPORT::WINDOW[0])
- @teleport_window.x = NICKE::TELEPORT::WINDOW[1]
- @teleport_window.y = NICKE::TELEPORT::WINDOW[2]
- @teleport_window.z = NICKE::TELEPORT::WINDOW[3]
- @teleport_window.opacity = NICKE::TELEPORT::WINDOW[4]
- @teleport_window.open
- end
- end
- def teleport_player(index)
- # // Method for teleporting the player to the spawn event. (if exists)
- $game_map.setup(@teleport_list[index][0])
- $game_map.teleport_spawn
- Graphics.fadeout(NICKE::TELEPORT::FADE_TIME)
- $game_map.autoplay
- $game_map.refresh
- $game_player.animation_id = NICKE::TELEPORT::ANIM_ID unless NICKE::TELEPORT::ANIM_ID.nil?
- $scene = Scene_Map.new
- end
- def update
- super
- @message_window.update
- unless @teleport_list.empty?
- @teleport_window.update
- if Input.trigger?(Input::B)
- Sound.play_cancel
- return_scene
- elsif Input.trigger?(Input::C)
- case @teleport_window.index
- when 0...@teleport_list.size
- Sound.play_decision
- teleport_player(@teleport_window.index)
- end
- end
- end
- end
- def create_menu_background
- @menuback_sprite = Sprite.new
- if NICKE::TELEPORT::BACK.nil?
- @menuback_sprite.bitmap = $game_temp.background_bitmap
- @menuback_sprite.color.set(16, 16, 16, 128)
- else
- @menuback_sprite.bitmap = Cache.picture(NICKE::TELEPORT::BACK)
- end
- update_menu_background
- end
- def dispose_menu_background
- @menuback_sprite.dispose unless @menuback_sprite.nil?
- @menuback_sprite = nil
- end
- def dispose_teleport
- dispose_menu_background
- unless @teleport_list.empty?
- @teleport_window.dispose unless @teleport_window.nil?
- @teleport_window = nil
- end
- @message_window.dispose unless @message_window.nil?
- @message_window = nil
- end
- alias nicke_teleport_terminate terminate unless $@
- def terminate(*args,&block)
- nicke_teleport_terminate(*args,&block)
- dispose_teleport
- end
- def perform_transition
- if NICKE::TELEPORT::TRANSITION.nil?
- Graphics.transition(30)
- else
- Graphics.transition(NICKE::TELEPORT::TRANSITION[0],NICKE::TELEPORT::TRANSITION[1],NICKE::TELEPORT::TRANSITION[2]) unless @teleport_list.empty?
- end
- end
- def return_scene
- if NICKE::TELEPORT::RETURN_SCENE.nil?
- $scene = Scene_Map.new
- else
- $scene = Scene_Menu.new(NICKE::TELEPORT::RETURN_SCENE)
- end
- end
- end # END OF FILE
- #=*==========================================================================*=#
- # ** END OF FILE
- #=*==========================================================================*=#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement