Azrith's Mouse Map system problem

I'm having a problem with Azrith's mouse map system (here: viewtopic.php?f=11&t=76642). I want to add a new location to the map after the location has been visited. Simply visiting the location isn't making any changes to the world map.

Here's the script for reference:

  1.  
  2.  
  3.  
  4. module LMAP
  5.  
  6.   #Map Graphic Name
  7.   Map_Name = "Map/map"
  8.  
  9.   #Cursor Info
  10.   Cursor_Name = "Map/selection"
  11.   #Max Number of frames in an animation
  12.   Frame_Count = 4
  13.   #Glowing Selection?(will fade in and out)
  14.   Glowing_Selection = true
  15.  
  16.   Locations = []
  17.   # Location.push([map_id, tele_x, tele_y, visited?, map_x, Map_y, Map_icon])
  18.   Locations.push([38, 19, 79, true, 150, 180, "move_01"])
  19.   Locations.push([30, 42, 6, false, 145, 280, "move_05"])
  20.   Locations.push([33, 00, 35, false, 290, 360, "move_01"])
  21.  
  22.  
  23.   Map_Info = {}
  24.   #Map_Info[map_id] = "Description"
  25.   # adding a \n will cause the text to break to the next line
  26.   # This includes The Location Description
  27.   Map_Info[38] = ""
  28.   Map_Info[30] = ""
  29.   Map_Info[33] = ""
  30.  
  31.  
  32. end
  33. #==============================================================================
  34. # ** Scene_ViewMap
  35. #------------------------------------------------------------------------------
  36. #  This class performs game end screen processing.
  37. #==============================================================================
  38.  
  39. class Scene_ViewMap
  40.   #--------------------------------------------------------------------------
  41.   # * Main Processing
  42.   #--------------------------------------------------------------------------
  43.   def main
  44.    
  45.     @speed = 4
  46.    
  47.     @back = Sprite.new
  48.     @back.bitmap = RPG::Cache.picture(LMAP::Map_Name)
  49.    
  50.    
  51.     # Make command window
  52.     @command_window = Window_Help.new
  53.     @command_window.x = 0
  54.     @command_window.y = 480-@command_window.height
  55.     @command_window.opacity = 0
  56.    
  57.     @map_help = Sprite.new
  58.     @map_help.bitmap = RPG::Cache.picture("Map/map_help")
  59.     @map_help.y = 98
  60.    
  61.     @map_description = Sprite.new
  62.     @map_description.bitmap = RPG::Cache.picture("Map/map_info")
  63.     @map_description.opacity = 0
  64.    
  65.     @map_desc = Window_Map_Description.new
  66.     @map_desc.opacity = 0
  67.     @map_desc.visible = false
  68.     @map_desc.z = 150
  69.    
  70.     @map_description.z = @map_desc.z - 1
  71.    
  72.     @viewport1 = Viewport.new(0, 0, 640, 480)
  73.     @cursor = Map_Cursor.new(@viewport1)
  74.    
  75.    
  76.     @ico = []
  77.    
  78.     for i in 0...$game_system.locations.size
  79.     if $game_system.unlocked?(i) == true
  80.       @ico[i] = Sprite.new
  81.       @ico[i].bitmap = RPG::Cache.icon("#{$game_system.loc_icon(i)}")
  82.       @ico[i].x = $game_system.cord(i, 0)
  83.       @ico[i].y = $game_system.cord(i, 1)
  84.       if $game_map.get_map == $game_system.map_id(i)
  85.         @cursor.x = @ico[i].x-8
  86.         @cursor.y = @ico[i].y+4
  87.         @cl = Sprite.new
  88.         @cl.bitmap = RPG::Cache.picture("Map/current_location")
  89.         @cl.x = @ico[i].x
  90.         @cl.y = @ico[i].y-24
  91.       end
  92.     end
  93.     end
  94.    
  95.     @index = 0
  96.     @snap = false
  97.     @float = false
  98.     @wait = 0
  99.     @ani_index = 0
  100.     # Execute transition
  101.     Graphics.transition
  102.     # Main loop
  103.     loop do
  104.       # Update game screen
  105.       Graphics.update
  106.       # Update input information
  107.       Input.update
  108.       # Frame Update
  109.       update
  110.       # Abort loop if screen is changed
  111.       if $scene != self
  112.         break
  113.       end
  114.     end
  115.     # Prepare for transition
  116.     Graphics.freeze
  117.     # Dispose of window
  118.     @command_window.dispose
  119.     @cursor.dispose
  120.     @map_help.dispose
  121.     @back.dispose
  122.     @map_desc.dispose
  123.     @cl.dispose if @cl != nil
  124.     @map_description.dispose
  125.     for ico in @ico
  126.       ico.dispose
  127.     end
  128.     # If switching to title screen
  129.     if $scene.is_a?(Scene_Title)
  130.       # Fade out screen
  131.       Graphics.transition
  132.       Graphics.freeze
  133.     end
  134.   end
  135.   #--------------------------------------------------------------------------
  136.   # * Frame Update
  137.   #--------------------------------------------------------------------------
  138.   def update
  139.     # Update command window
  140.     @command_window.update
  141.     @map_desc.update
  142.     @cursor.update
  143.     @cl.update if @cl != nil
  144.     @map_help.update
  145.     @map_description.update
  146.    
  147.  
  148.  
  149.     for i in [email hidden]
  150.       if @cursor.x.between?(@ico[i].x-(@cursor.width/2), @ico[i].x+(@cursor.width/2)) and @cursor.y.between?(@ico[i].y-(@cursor.height/2), @ico[i].y+(@cursor.height/2))
  151.         @command_window.set_text("#{$game_map.list_name($game_system.map_id(i))}", 1)
  152.         if @snap == true
  153.           @index = i
  154.           @cursor.x = @ico[i].x-8
  155.           @cursor.y = @ico[i].y+4
  156.           @map_help.opacity += 20
  157.           @map_desc.visible = true
  158.           @map_description.opacity += 20
  159.           @map_desc.x = @cursor.x - @map_desc.width
  160.           @map_desc.set_text("#{LMAP::Map_Info[$game_system.map_id(i)]}")
  161.           if @cursor.y >= 240
  162.           if @map_desc.y <= 480-@map_desc.height
  163.           @map_desc.y = @cursor.y - @map_desc.height/2
  164.           elsif @map_desc.y > 480-@map_desc.height
  165.           @map_desc.y = 480-@map_desc.height
  166.           end
  167.         else
  168.           if @map_desc.y >= 0
  169.           @map_desc.y = @cursor.y - @map_desc.height/2
  170.           elsif @map_desc.y > 480-@map_desc.height
  171.           @map_desc.y = 0
  172.           end
  173.         end
  174.         @map_description.x = @map_desc.x+4
  175.         @map_description.y = @map_desc.y-32
  176.        
  177.         end
  178.       end
  179.     end
  180.    
  181.     if @wait < 5
  182.     @wait += 1
  183.   else
  184.     @float = !@float
  185.     @wait = 0
  186.   end
  187.    
  188.     if @float == true
  189.       @cl.y += 1 if @cl != nil
  190.     else
  191.       @cl.y -= 1 if @cl != nil
  192.     end
  193.    
  194.    
  195.  
  196.   if @cursor.y >= 240
  197.     @command_window.y = 0
  198.     @map_help.y = 98-415
  199.   elsif @cursor.y < 240
  200.     @command_window.y = 480-@command_window.height
  201.     @map_help.y = 98
  202.   end
  203.  
  204.   if @snap == false
  205.     @command_window.set_text("", 1)
  206.     @map_desc.visible = false
  207.   end
  208.  
  209.   if @map_desc.visible == false
  210.     @map_help.opacity -= 20
  211.     @map_description.opacity -= 20
  212.   end
  213.    
  214.  
  215.   if Input.press?(Input::UP) or Input.press?(Input::DOWN) or Input.press?(Input::LEFT) or Input.press?(Input::RIGHT)
  216.     @snap = false
  217.      else
  218.     @snap = true
  219.   end
  220.  
  221.   if Input.press?(Input::UP)
  222.     if @cursor.y >= 0
  223.       @cursor.y -= @speed
  224.     else
  225.       @cursor.y += 1
  226.     end
  227.    end
  228.    
  229.   if Input.press?(Input::DOWN)
  230.     if @cursor.y <= [email hidden]
  231.       @cursor.y += @speed
  232.     else
  233.       @cursor.y -= 1
  234.     end
  235.    end
  236.    
  237.   if Input.press?(Input::LEFT)
  238.     if @cursor.x >= 0
  239.       @cursor.x -= @speed
  240.     else
  241.       @cursor.x += 1
  242.     end
  243.    end
  244.  
  245.   if Input.press?(Input::RIGHT)
  246.     if @cursor.x <= [email hidden]
  247.       @cursor.x += @speed
  248.     else
  249.       @cursor.x -= 1
  250.     end
  251.    end
  252.    
  253.     # If B button was pressed
  254.     if Input.trigger?(Input::B)
  255.       # Play cancel SE
  256.       $game_system.se_play($data_system.cancel_se)
  257.       # Switch to menu screen
  258.       $scene = Scene_Menu.new(5)
  259.       return
  260.     end
  261.    
  262.     # If C button was pressed
  263.     if Input.trigger?(Input::C)
  264.      
  265.        if $game_system.unlocked?(@index) == true
  266.         $game_system.se_play($data_system.escape_se)
  267.         $game_temp.player_new_map_id = $game_system.map_id(@index)
  268.         $game_temp.player_new_x = $game_system.tele_cords(@index)[0]
  269.         $game_temp.player_new_y = $game_system.tele_cords(@index)[1]
  270.         $game_temp.player_new_direction = 2
  271.         $game_temp.player_transferring = true
  272.         $game_map.setup($game_temp.player_new_map_id)
  273.         # Set up player position
  274.         $game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)
  275.         # Set player direction
  276.         case $game_temp.player_new_direction
  277.         when 2  # down
  278.           $game_player.turn_down
  279.         when 4  # left
  280.           $game_player.turn_left
  281.         when 6  # right
  282.           $game_player.turn_right
  283.         when 8  # up
  284.           $game_player.turn_up
  285.         end
  286.         # Straighten player position
  287.         $game_player.straighten
  288.         $scene = Scene_Map.new
  289.         end
  290.      
  291.       return
  292.     end
  293.    
  294.   end
  295. end
  296.  
  297.  
  298. #==============================================================================
  299. # ** Game_System_EDIT
  300. #------------------------------------------------------------------------------
  301. #  This class handles data surrounding the system. Backround music, etc.
  302. #  is managed here as well. Refer to "$game_system" for the instance of
  303. #  this class.
  304. #==============================================================================
  305.  
  306. class Game_System
  307.   #--------------------------------------------------------------------------
  308.   # * Public Instance Variables
  309.   #--------------------------------------------------------------------------
  310.   attr_accessor :locations
  311.   alias map_ini_sys initialize
  312.   #--------------------------------------------------------------------------
  313.   # * Object Initialization
  314.   #--------------------------------------------------------------------------
  315.   def initialize
  316.     map_ini_sys
  317.     @locations = []
  318.     for i in 0...LMAP::Locations.size
  319.       @locations.push(LMAP::Locations[i])
  320.     end
  321.   end
  322.  
  323.   def map_id(n)
  324.     return @locations[n][0]
  325.   end
  326.  
  327.   def add_location(n)
  328.     return @locations[n][3] = true
  329.   end
  330.  
  331.   def remove_location(n)
  332.     return @locations[n][3] = false
  333.   end
  334.  
  335.   def cord(n, v)
  336.     return @locations[n][4+v]
  337.   end
  338.  
  339.   def tele_cords(n)
  340.     return [@locations[n][1], @locations[n][2]]
  341.   end
  342.  
  343.   def loc_icon(n)
  344.     return @locations[n][6]
  345.   end
  346.  
  347.   def unlocked?(n)
  348.     if @locations[n][3] == true
  349.       return true
  350.     elsif @locations[n][3] == false
  351.       return false
  352.     end
  353.   end
  354.  
  355. end
  356.  
  357. #===================================================
  358. # Game Map Edit
  359. #===================================================
  360. class Game_Map
  361.  def name
  362.    $map_infos[@map_id]
  363.  end
  364.  
  365.  def get_map
  366.    return @map_id
  367. end
  368.  
  369.  def list_name(n)
  370.    $map_infos[n]
  371.  end
  372. end
  373.  
  374. class Scene_Title
  375.    $map_infos = load_data("Data/MapInfos.rxdata")
  376.    for key in $map_infos.keys
  377.      $map_infos[key] = $map_infos[key].name
  378.    end
  379. end
  380.  
  381.  
  382. #==============================================================================
  383. # ** Map_Cursor
  384. #------------------------------------------------------------------------------
  385. #  This sprite is used to display the cursor for the world map.
  386. #==============================================================================
  387.  
  388. class Map_Cursor < RPG::Sprite
  389.   #--------------------------------------------------------------------------
  390.   # * Public Instance Variables
  391.   #--------------------------------------------------------------------------
  392.   #--------------------------------------------------------------------------
  393.   # * Object Initialization
  394.   #     viewport  : viewport
  395.   #     character : character (Game_Character)
  396.   #--------------------------------------------------------------------------
  397.   def initialize(viewport)
  398.     super(viewport)
  399.    
  400.     @frame = 0
  401.     @wait = 0
  402.     @frame_count = LMAP::Frame_Count
  403.     @glow = false
  404.     update
  405.   end
  406.  
  407.   def height
  408.     return @ch
  409.   end
  410.  
  411.   def width
  412.     return @cw
  413.   end
  414.  
  415.   #--------------------------------------------------------------------------
  416.   # * Frame Update
  417.   #--------------------------------------------------------------------------
  418.   def update
  419.     super
  420.    
  421.     if @wait < 2
  422.       @wait += 1
  423.     else
  424.       @wait = 0
  425.       @frame += 1 if @frame < @frame_count
  426.       @frame = 0 if @frame >= @frame_count
  427.     end
  428.    
  429.     if LMAP::Glowing_Selection == true
  430.       if @glow == false
  431.         self.opacity -= 5 if self.opacity > 120
  432.         @glow = true if self.opacity <= 120
  433.       else
  434.         self.opacity += 5
  435.         @glow = false if self.opacity >= 255
  436.       end      
  437.     end
  438.    
  439.     # Remember tile ID, file name, and hue
  440.     self.bitmap = RPG::Cache.picture(LMAP::Cursor_Name)
  441.     @cw = bitmap.width / @frame_count
  442.     @ch = bitmap.height
  443.     self.ox = 0
  444.     self.oy = 0
  445.     self.src_rect.set(0+@cw*@frame, 0, @cw, @ch)
  446.     # Set visible situation
  447.     self.visible = true
  448.     # Set sprite coordinates
  449.     self.z = 120
  450.     # Set opacity level, blend method, and bush depth
  451.     self.blend_type = 0
  452.     self.bush_depth = 0
  453.   end
  454. end
  455.  
  456. #==============================================================================
  457. # ** Window_Map_Description
  458. #------------------------------------------------------------------------------
  459. #  This window shows skill and item explanations along with actor status.
  460. #==============================================================================
  461.  
  462. class Window_Map_Description < Window_Base
  463.   #--------------------------------------------------------------------------
  464.   # * Object Initialization
  465.   #--------------------------------------------------------------------------
  466.   def initialize
  467.     super(0, 0, 200, 200)
  468.     self.contents = Bitmap.new(width-32, height - 32)
  469.   end
  470.   #--------------------------------------------------------------------------
  471.   # * Set Text
  472.   #  text  : text string displayed in window
  473.   #  align : alignment (0..flush left, 1..center, 2..flush right)
  474.   #--------------------------------------------------------------------------
  475.   def set_text(text, align = 0, color = normal_color)
  476.     # If at least one part of text and alignment differ from last time
  477.     if text != @text or align != @align
  478.       # Redraw text
  479.      
  480.      
  481.     self.contents.clear
  482.     self.contents.font.color = color
  483.     self.contents.font.size = 15
  484.     x = y = 0
  485.     @cursor_width = 0
  486.     # Indent if choice
  487.     if $game_temp.choice_start == 0
  488.       x = 8
  489.     end
  490.       # Control text processing
  491.  
  492.       # Get 1 text character in c (loop until unable to get text)
  493.       while ((c = text.slice!(/./m)) != nil)
  494.         # If \\
  495.         if c == "\000"
  496.           # Return to original text
  497.           c = "\\"
  498.         end
  499.         # If new line text
  500.         if c == "\n"
  501.           # Update cursor width if choice
  502.           if y >= $game_temp.choice_start
  503.             @cursor_width = [@cursor_width, x].max
  504.           end
  505.           # Add 1 to y
  506.           y += 1
  507.           x = 0
  508.           # Indent if choice
  509.           if y >= $game_temp.choice_start
  510.             x = 8
  511.           end
  512.           # go to next text
  513.           next
  514.         end
  515.         # Draw text
  516.         self.contents.draw_text(4 + x, self.contents.font.size * y, 40, self.contents.font.size, c)
  517.         # Add x to drawn text width
  518.         x += self.contents.text_size(c).width
  519.       end
  520.       @text = text
  521.       @align = align
  522.     end
  523.     self.visible = true
  524.   end
  525. end
  526.  
Expand to see the code.


I figured there would be some type of script call or switch I could use once I visit the map, but can't seem to find any D:
I'll re-visit the script tonight when i get home from work. I'll make it auto add locations you visit (able to turn on and off) also there should be a line you can use in the events to make it show the location.

  1.  
  2. $game_system.add_location( location id )
  3.  
  4. # to remove:
  5.  
  6. $game_system.remove_location( location id )
  7.  
Expand to see the code.


I'll add in the auto checks when i get a chance :D
hey thanks man! also, whenever i use that script call I get a NoMethodError on line 328: undefined method '[]=' for nil:NilClass
Ahhh I forgot XD That the old one Uses Modules instead of a class :3 my bad I'll get the new one asap

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=77016