RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
script request

0 Members and 1 Guest are viewing this topic.

**
Rep:
Level 88
That's me in my bee outfit, do I look handsome?
I want to have a Warp magic in my game, im using branches to do so but id doesn't look good, i can only put 4 options and use one to bring another page with new locations, i don't like it at all, i would like to have a script doing it with a window, after you visit a town making possible to warp to that place with the warp magic, I found this script at dubealex site but still i dont like it because it shows the worldmap and an image of the map, i want a simplier form, i just want a menu with the name of the location unlocked only when i call a script to unlock it just like in this script, could anyone modify this script to have only the command menu with the locations please? thx in advance

http://www.dubealex.com/asylum/index.php?showtopic=3953&hl=teleport

Code: [Select]
#================================
#Class Game_Globe
#Written by SephirothSpawn
#Defines your Worlds (@worlds)
#And Your Locations (@locatoins)
#================================
class Game_Globe
  attr_accessor :worlds, :locations
  def initialize
    @worlds = [] ;@locations = []
  end
  #---------------------------------------------------------------
  #Def Add_World (Adds World to your worlds list)
  #---------------------------------------------------------------
  def add_world(name)
    @worlds.push(name) ;@locations.push( [] )
  end
  #---------------------------------------------------------------
  #Def Remove_World (Removes a World)
  #---------------------------------------------------------------
  def remove_world(id)
    @worlds.delete_at(id) ;@locations.delete_at(id)
  end
  #---------------------------------------------------------------
  #Def Add_Location (Adds a locaction to a world)
  #Setup: (map, info)
  #Map = the id in your arrays  Example: @worlds = ["Spira", "Zanarkand"]
  #                                       To add "Besaid" to Spira, map would equal 0
  #Info = information of the Location
  #Info = ["Name of location", x, y, map_id, x2, y2]
  #"Name of Location = the Name of your location that will appear in the scene
  #x and y are the locations relative to the Top-Left corner of your screen
  #  To get x and y, Open Paint and your map. Move the cursor of the area
  #     on the map where your location will appear.
  #  The x & y coordinates will appear on the Bottom-Right Corner
  #map_id is the map id of the map to teleport to
  #x2 & y2 are the locations on the map where you will be teleported to
  #   If you dont want to make a location Teleportable, leave map_id, x2 & y2 = to nil (["Name", x, y])
  #---------------------------------------------------------------
  def add_location(map, info)
    @locations[map].push(info)
  end
  #---------------------------------------------------------------
  #Def Remove_Location (Removes a location from you loactions list)
  #map = World, Id is the location to delete 
  #     Example: @locations = [ [ ["Besaid", 5, 5, 0, 3, 10], ["Luca", 25, 30, 1, 10, 3] ], [World 2 Bios] ]
  #     Say Luca is destroyed by Sin. To remove, use (0, 1); 0 being your first world, 1 being your second location
  #---------------------------------------------------------------
  def remove_location(map, id)
    @locations[map].delete_at(id)
  end
end
#================================
#End of Game_Globe
#Start Scene_Globe
#================================
class Scene_Globe
  #------Sets Up Instance Varaibles------
  def initialize(world_id = 0)
    @world_id = world_id
    @locations = $Game_Globe.locations[world_id]
  end
  #------Sets Up Scene------
  def main
    #------Variable Setup------
    @x =320
    @y = 240
    @anim_curs = 0
    @dir = 1
    @phase = 0
    @temp_phase = 0
    @loc = 0
    @toggle = true
    commands = []
    for i in 0...@locations.size
      commands.push(@locations[i][0])
    end
    if commands.size >= 14
      height = 416
    else
      height = commands.size*32+32
    end
    #------Sprite Setup------
    bitmap = RPG::Cache.picture("Maps/"+$Game_Globe.worlds[@world_id])
    @map1 = Sprite.new
      @map1.bitmap = bitmap
    @map2 = Sprite.new
      @map2.bitmap = bitmap
    @globe = Sprite.new
      @globe.bitmap =  RPG::Cache.picture("Maps/Globe")
      @globe.z =  10
    @border = Window_Base.new(8, 232, 320, 240)
      @border.z = 16
      @border.back_opacity = 0
      @border.visible = false
    @tele_map = Sprite.new
      @tele_map.x = 8
      @tele_map.y = 232
      @tele_map.z = 15
    @cursor = Sprite.new
      @cursor.bitmap = RPG::Cache.picture("Maps/Cursor0")
      @cursor.x = @x - 16
      @cursor.y = @y - 16
      @cursor.z = 5
    #------Window Setup------
    @tele_cmd = Window_Command.new(160, ["Teleport", "Cancel"])
      @tele_cmd.x = 472
      @tele_cmd.y = 376
      @tele_cmd.z = 15
      @tele_cmd.opacity = 150
      @tele_cmd.active = @tele_cmd.visible = false
    @exit_cmd = Window_Command.new(200, ["Return to Menu", "Return to Map", "Cancel"])
      @exit_cmd.x = 432
      @exit_cmd.y = 344
      @exit_cmd.z = 15
      @exit_cmd.opacity = 150
      @exit_cmd.active = @exit_cmd.visible = false
    @list_cmd = Window_Command.new(196, commands)
      @list_cmd.height = height
      @list_cmd.x = 8
      @list_cmd.y = 240 - (height/2)
      @list_cmd.z = 15
      @list_cmd.opacity = 150
      @list_cmd.visible = @list_cmd.active = false
    @title = Window_Help.new
      @title.opacity, = 0
      @title.set_text($Game_Globe.worlds[@world_id], 1)
    @location = Window_Help.new
      @location.y = 416
      @location.opacity = 0
      @location.visible = false
    @controls = Window_Controls.new
      @controls.opacity = 150
      controls = ["Y -> Auto Mode", "Z -> List Mode", "A ->Toggle Control Window", "B -> Exit",
                       "C -> View Location (When Red)", "L & R -> Rotate Globe", "Arrows -> Move Cursor",
                       "Normal Mode"]
      @controls.refresh(controls)
    #------Quick Arrays Setup------
    @dispose = [@map1, @map2, @globe, @border, @tele_map, @cursor, @tele_cmd, @exit_cmd, @list_cmd, @title, @location, @controls]
    @visible_change = [@border, @tele_map, @cursor, @tele_cmd, @exit_cmd, @list_cmd, @location]
    @active_change = [@tele_cmd, @exit_cmd, @list_cmd]
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @dispose.each {|x| x.dispose if !x.disposed?}
  end
  #------Updates Scene------
  def update
    @dispose.each {|x| x.update}
    @cursor.x =@x-16 ;@cursor.y = @y-16
    @anim_curs += @dir ;@dir *= -1  if @anim_curs == 25 or @anim_curs == 0
    @cursor.bitmap = RPG::Cache.picture("Maps/Cursor0")  if @anim_curs ==0
    @cursor.bitmap = RPG::Cache.picture("Maps/Cursor3")  if @anim_curs == 5
    @cursor.bitmap = RPG::Cache.picture("Maps/Cursor1")  if @anim_curs == 10
    @cursor.bitmap = RPG::Cache.picture("Maps/Cursor4")  if @anim_curs == 15
    @cursor.bitmap = RPG::Cache.picture("Maps/Cursor2")  if @anim_curs == 20
    @cursor.bitmap = RPG::Cache.picture("Maps/Cursor5")  if @anim_curs == 25
    @map2.x = (@map1.x - 640) if @map1.x >= 0
    @map2.x = (@map1.x + 640) if @map1.x > 0
    @map1.x=0 if @map1.x==-640 or @map1.x==640
    @visible_change.each {|x| x.visible = false}
    @active_change.each {|x| x.active = false}
    @cursor.visible = true if @phase < 4
    @location.visible = true if @phase < 4
    @controls.visible = false if @phase > 2
    case @phase
     when 0
       normal_mode
     when 1
       midge_mode
     when 2
       @list_cmd.visible = @list_cmd.active = true
       list_mode
     when 3
       @border.visible = @tele_map.visible = true
       @tele_cmd.visible = @tele_cmd.active = true
       tele_mode
     when 4
       @exit_cmd.visible = @exit_cmd.active = true
       exit_mode
    end
  end
  #------Move Cursors over Location------
  def normal_mode
    controls = ["Y -> Auto Mode", "Z -> List Mode", "A ->Toggle Control Window", "B -> Exit",
                     "C -> View Location (When Red)", "L & R -> Rotate Globe", "Arrows -> Move Cursor",
                     "Normal Mode"]
    @controls.refresh(controls)
    @controls.visible = true if @toggle
    @controls.visible = false if !@toggle
    if Input.trigger?(Input::A)
      if @toggle then @toggle = false else @toggle = true end
    end
    if Input.trigger?(Input::B)
      @temp_phase = 0 ;@phase = 4
    end
    if Input.press?(Input::L)
      @map1.x -= 4 ;@map2.x -=4
    end
    if Input.press?(Input::R)
      @map1.x += 4 ;@map2.x +=4
    end
    @x +=2 if Input.press?(Input::RIGHT) and @x < 560
    @x -=2 if Input.press?(Input::LEFT) and @x > 80
    @y +=2 if Input.press?(Input::DOWN) and @y < 480
    @y -=2 if Input.press?(Input::UP) and @y > 0
    @phase = 1  if Input.trigger?(Input::Y)
    @phase = 2  if Input.trigger?(Input::Z)
    x1 = @x - @map1.x
    x2 = @x - @map2.x
    y1 = @y
    for i in 0...@locations.size
      x = @locations[i][1]
      y = @locations[i][2]
      if (x1<=x+16 and x1>=x-16 and y1<=y+16 and y1>=y-16)  or  (x2<=x+16 and x2>=x-16 and y1<=y+16 and y1>=y-16)
        @cursor.tone = Tone.new(255, 0, 0, 255) ;@location.visible = true
        @location.set_text(@locations[i][0], 1)
        if Input.trigger?(Input::C)
          @temp_loc = @locations[i]
          @tele_map.bitmap = RPG::Cache.picture("Maps/"+@locations[i][0])
          @temp_phase = 0 ;@phase = 3
        end
        return
      else
        @cursor.tone = Tone.new(0, 0, 0, 255) ;@location.visible = false
      end
    end
  end
  #------Scrolls Through Locations Automatically------
  # ------Thanks to Makeamidget for Suggestion------
  def midge_mode
    controls = ["X -> Normal Mode", "Z -> List Mode", "A ->Toggle Control Window", "B -> Exit",
                     "C -> View Location (When Red)", "Left or Right -> Next Location", "", "Auto Mode"]
    @controls.refresh(controls)
    @cursor.tone = Tone.new(255, 0, 0, 255)
    @location.set_text(@locations[@loc][0], 1)
    @controls.visible = true if @toggle
    @controls.visible = false if !@toggle
    if Input.trigger?(Input::A)
      if @toggle then @toggle = false else @toggle = true end
    end
    if Input.trigger?(Input::B)
      @temp_phase = 0 ;@phase = 4
    end
    @phase = 0  if Input.trigger?(Input::X)
    @phase = 2  if Input.trigger?(Input::Z)
    if Input.trigger?(Input::RIGHT)
      @loc += 1 if @loc <= @locations.size - 1;@loc = 0 if @loc > @locations.size - 1
    end
    if Input.trigger?(Input::LEFT)
      @loc = @locations.size - 1 if @loc == 0 ;@loc -= 1 if @loc != 0
    end
    @x = 320
    @y = @locations[@loc][2]
    @map1.x = 320 - @locations[@loc][1]
    if Input.trigger?(Input::C)
      @temp_loc = @locations[@loc]
      @tele_map.bitmap = RPG::Cache.picture("Maps/"+@locations[@loc][0])
      @temp_phase = 1 ;@phase = 3
    end
  end
  #------Show Locations in Command Window------
  #   ------Thanks to Viskar for Suggestion------
  def list_mode
    controls = ["X -> Normal Mode", "Y -> Auto Mode", "A ->Toggle Control Window", "B -> Exit",
                     "C -> View Location (When Red)", "Up or Down-> Next Location", "", "List Mode"]
    @controls.refresh(controls)
    @cursor.tone = Tone.new(255, 0, 0, 255)
    @controls.visible = true if @toggle
    @controls.visible = false if !@toggle
    if Input.trigger?(Input::A)
      if @toggle then @toggle = false else @toggle = true end
    end
    if Input.trigger?(Input::B)
      @temp_phase = 0 ;@phase = 4
    end
    @phase = 0  if Input.trigger?(Input::X)
    @phase = 1  if Input.trigger?(Input::Y)
    loc = @list_cmd.index
    @location.set_text(@locations[loc][0], 1)
    @x =320
    @y = @locations[loc][2]
    @map1.x = 320 - @locations[loc][1]
    if Input.trigger?(Input::C)
      @temp_loc = @locations[loc]
      @tele_map.bitmap = RPG::Cache.picture("Maps/"+@locations[loc][0])
      @temp_phase = 1 ;@phase = 3
    end
  end
  #------Teleport to Location------
  def tele_mode
    @phase = @temp_phase  if Input.trigger?(Input::B)
    teleport = true
    if @temp_loc[3] == nil
      teleport = false ;@tele_cmd.disable_item(0)
    end
    if Input.trigger?(Input::C)
      case @tele_cmd.index
        when 0
          if teleport
            $game_map.setup(@temp_loc[3]) ;$game_player.moveto(@temp_loc[4], @temp_loc[5])
            $scene=Scene_Map.new ;$game_map.refresh
          else
            $game_system.se_play($data_system.buzzer_se)
          end
        when 1
          @phase = @temp_phase
      end
    end
  end
  #------Returns to Game------
  def exit_mode
=begin
    @phase = @temp_phase  if Input.trigger?(Input::B)
    if Input.trigger?(Input::C)
      case @exit_cmd.index
        when 0 ;$scene = Scene_Menu.new
        when 1 ;$scene = Scene_Map.new
        when 2 ;@phase = @temp_phase
      end
    end
=end
    $scene = Scene_Map.new
  end
  #---------------------------------------------------------------
end
#================================
#End of Scene_Globe
#Start Of Window_Controls
#================================
class Window_Controls < Window_Base
  #------Window Parameters------
  def initialize
    super(412, 264, 220, 208)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $defaultfonttype
  end
  #------Uses text (array) to Draw Text via .refresh------
  def refresh(text)
    self.contents.clear
    self.contents.font.size = 32 ;self.contents.font.color = normal_color
    self.contents.draw_text(0, 0, 208, 32, "Controls:")
    for i in 0...text.size
      if i < text.size - 1
        self.contents.font.color = normal_color ;x = 6 ;self.contents.font.size = y = 16
      else
        self.contents.font.color = knockout_color ;x = 0 ;self.contents.font.size = 32
      end
      cx = contents.text_size(text[i]).width ;cy = contents.text_size(text[i]).height
      self.contents.draw_text(x, y*i + 32, cx, cy, text[i])
    end
  end
end