Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Post: #1little Edit of the cursor world map system of azrit

Hello folks. Since nobody is helping me in other forums Im in need to ask you... :( Im using the world map system of azrith007
http://www.mediafire.com/?tvbn3pjhvq4pdzb here you can download it
Its a system for selecting places in a world map.

I need a little edit on the cursor map system of azrith. (demo is above)
The script can only use a picture of 640x480. But I want someone to edit the script so that it is possible to use a picture of 1500x1500. Of course not every part of the picture should be seen on the screen. I also should be able to go beyond the screen borders, which is not possible in demo. For example if I usa a picture of 1500x1500 it is not possible ot go beyond the borders of the screen which should be.

I'll of course credit you
 
It was easy enough to make the background and icon move when the cursor was at the edge of the map. The map will always be at 0,0 when you open it. So I engineered a way to have the current selection centered.

*Also fixed a problem with the description display when it's too close to the top of the screen.
*added some notes to explain how to set locations as unlocked since that doesn't appear to be a functional.
otherwise set all the locations as 'true' and you shouldn't have any problems.

The only thing you need to input besides setting the locations is the map scrolling limitation. In the section with the up, down, left, right inputs (after line 50) I left a note next to a number to prevents the user from scrolling the map past a certain coordinate and off into infinity. I can only guess the scrolling down and right limitations for you map might be.
i.e you can scroll up until the top edge of the map (the map background's y coordinate) hits 240 (the center of the screen). You can change that to 0 if you don't want the top edge to leave the top of the screen, however this won't stop the centering mechanism from showing the map edges if the selected location is too close .

Code:
 

 

 

module LMAP

  

  #Map Graphic Name

  Map_Name = "Map/map"

  

  #Cursor Info

  Cursor_Name = "Map/selection"

  #Max Number of frames in an animation

  Frame_Count = 4

  #Glowing Selection?(will fade in and out)

  Glowing_Selection = true

  

  Locations = []

  # Location.push([map_id, tele_x, tele_y, unlocked?, map_x, Map_y, Map_icon])

  Locations.push([3, 5, 5, true, 360, 230, "move_05"])

  Locations.push([2, 5, 5, true, 220, 340, "move_06"])

  Locations.push([4, 5, 5, true, 320, 160, "move_07"])

  Locations.push([1, 5, 5, true, 480, 160, "move_04"])

  Locations.push([5, 5, 5, false, -20, 0, "move_03"])

  Locations.push([1, 5, 5, false, 280, 200, "move_02"])

  #To set a location as unlocked use the event command script and enter:

  #     LMAP::Locations[*][3] = true

  #     * is the Location's postion in the location array (the list above) 

  # Arrays start with 0. So to change the last location in this list to true

  # you would enter: LMAP::Locations[5][3] = true

  #

  #If the player is on a map that isn't a listed location then the map cursor 

  #will appear in the the corner of the map. 

  #If the player is on a map that isn't unlocked then the icon will be invisible

  #and not selectable but it will still be marked with the current location icon. 

  #

  #If 2 locations share the same map id then the Current Location Icon will 

  #mark the last of the 2. Above there are two locations using map_id 1. 

  #There is currently no way for there to be 2 current location icons. 

  

  Map_Info = {}

  #Map_Info[map_id] = "Description"

  # adding a \n will cause the text to break to the next line

  # This includes The Location Description

  Map_Info[1] = "This is a Castle"

  Map_Info[2] = "This is an Oasis"

  Map_Info[3] = "A rich forest, filled with herbs, \nand minerals alike. \nAs well as beasts."

  Map_Info[4] = "Map 004 lol"

  Map_Info[5] = "Tower"

  

  

end

#==============================================================================

# ** Scene_ViewMap

#------------------------------------------------------------------------------

#  This class performs game end screen processing.

#==============================================================================

 

class Scene_ViewMap

  #--------------------------------------------------------------------------

  # * Main Processing

  #--------------------------------------------------------------------------

  def main

    

    @speed = 8

    

    @back = Sprite.new

    @back.bitmap = RPG::Cache.picture(LMAP::Map_Name)

    

    

    # Make command window

    @command_window = Window_Help.new

    @command_window.x = 0

    @command_window.y = 480-@command_window.height

    @command_window.opacity = 0

    

    @map_help = Sprite.new

    @map_help.bitmap = RPG::Cache.picture("Map/map_help")

    @map_help.y = 98

    

    @map_description = Sprite.new

    @map_description.bitmap = RPG::Cache.picture("Map/map_info")

    @map_description.opacity = 0

    

    @map_desc = Window_Map_Description.new

    @map_desc.opacity = 0

    @map_desc.visible = false

    @map_desc.z = 150

    @map_description.z = @map_desc.z - 1

    

    @viewport1 = Viewport.new(0, 0, 640, 480)

    @cursor = Map_Cursor.new(@viewport1)

    

    

    @ico = []

    

    for i in 0...$game_system.locations.size

    #if $game_system.unlocked?(i) == true

      @ico[i] = Sprite.new

      @ico[i].bitmap = RPG::Cache.icon("#{$game_system.loc_icon(i)}")

      @ico[i].x = $game_system.cord(i, 0)

      @ico[i].y = $game_system.cord(i, 1)

      if $game_system.unlocked?(i) == false

        @ico[i].visible = false

      end

      if $game_map.get_map == $game_system.map_id(i)

        @cursor.x = @ico[i].x-8

        @cursor.y = @ico[i].y+4

        @cl = Sprite.new

        @cl.bitmap = RPG::Cache.picture("Map/current_location")

        @cl.x = @ico[i].x

        @cl.y = @ico[i].y-24

      end

    #end

  end

    center_cursor_A

    @index = 0

    @snap = false

    @float = false

    @wait = 0

    @ani_index = 0

    # Execute transition

    Graphics.transition

    # Main loop

    loop do

      # Update game screen

      Graphics.update

      # Update input information

      Input.update

      # Frame Update

      update

      # Abort loop if screen is changed

      if $scene != self

        break

      end

    end

    # Prepare for transition

    Graphics.freeze

    # Dispose of window

    @command_window.dispose

    @cursor.dispose

    @map_help.dispose

    @back.dispose

    @map_desc.dispose

    @cl.dispose if @cl != nil

    @map_description.dispose

    for i in @ico

      if i != nil

      i.dispose 

      end

    end

    # If switching to title screen

    if $scene.is_a?(Scene_Title)

      # Fade out screen

      Graphics.transition

      Graphics.freeze

    end

  end

  

  def center_cursor_A #Current location is centered on Open

    xdist = 320 - @cursor.x 

    ydist = 240 - @cursor.y  

    @cursor.x += xdist

    @cursor.y += ydist

    @back.x += xdist

    @back.y += ydist

    if @cl != nil

      @cl.x += xdist

      @cl.y += ydist

    end

    for i in [email=0...@ico.size]0...@ico.size[/email]

      if $game_system.unlocked?(i) == true

        @ico[i].x += xdist 

        @ico[i].y += ydist

      end

    end

  end

  def center_cursor_B #Scrolls map to snapped location

    xdist = 320 - @cursor.x 

    ydist = 240 - @cursor.y 

    easing = 40 

    @cursor.x += xdist/easing

    @cursor.y += ydist/easing

    @back.x += xdist/easing

    @back.y += ydist/easing

    if @cl != nil

      @cl.x += xdist/easing

      @cl.y += ydist/easing

    end

    for i in [email=0...@ico.size]0...@ico.size[/email]

      if $game_system.unlocked?(i) == true

        @ico[i].x += xdist/easing

        @ico[i].y += ydist/easing

      end

    end

  end

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    # Update command window

    @command_window.update

    @map_desc.update

    @cursor.update

    @cl.update if @cl != nil

    @map_help.update

    @map_description.update

    

    for i in [email=0...@ico.size]0...@ico.size[/email]

     if $game_system.unlocked?(i) == true 

      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))

        @command_window.set_text("#{$game_map.list_name($game_system.map_id(i))}", 1)

        if @snap == true

          @index = i

          @cursor.x = @ico[i].x-8

          @cursor.y = @ico[i].y+4

          center_cursor_B #eases cursor to center of screen

          @map_help.opacity += 20

          @map_desc.visible = true

          @map_description.opacity += 20

          @map_desc.x = @cursor.x - @map_desc.width

          @map_desc.set_text("#{LMAP::Map_Info[$game_system.map_id(i)]}")

          if @cursor.y >= 240

            if @map_desc.y <= 480-@map_desc.height

            @map_desc.y = @cursor.y - @map_desc.height/2

            elsif @map_desc.y > 480-@map_desc.height

            @map_desc.y = 480-@map_desc.height

            end

          else

            if @map_desc.y >= 0

            #@map_desc.y = @cursor.y - @map_desc.height/2

            @map_desc.y = @map_desc.height/2 #fixed display

            elsif @map_desc.y > 480-@map_desc.height

            @map_desc.y = 0

            end

          end

        @map_description.x = @map_desc.x+4

        @map_description.y = @map_desc.y-32

        

        end

      end

     end 

    end

    

    if @wait < 5

    @wait += 1

  else

    @float = !@float

    @wait = 0

  end

    

    if @float == true

      @cl.y += 1 if @cl != nil

    else

      @cl.y -= 1 if @cl != nil

    end

    

    

  

  if @cursor.y >= 240

    @command_window.y = 0

    @map_help.y = 98-415

  elsif @cursor.y < 240

    @command_window.y = 480-@command_window.height

    @map_help.y = 98

  end

  

  if @snap == false

    @command_window.set_text("", 1)

    @map_desc.visible = false

  end

  

  if @map_desc.visible == false

    @map_help.opacity -= 20

    @map_description.opacity -= 20

  end

    

  

  if Input.press?(Input::UP) or Input.press?(Input::DOWN) or Input.press?(Input::LEFT) or Input.press?(Input::RIGHT)

    @snap = false

     else

    @snap = true

  end

  

  if Input.press?(Input::UP) 

    if @cursor.y >= 0

      @cursor.y -= @speed

    elsif @back.y <= 240  #top edge won't scroll past

      @cursor.y += 1

      @back.y += @speed

      @cl.y += @speed if @cl != nil

      for i in [email=0...@ico.size]0...@ico.size[/email]

        if $game_system.unlocked?(i) == true

        @ico[i].y += @speed

        end

      end

    else

      @cursor.y += 1

    end

   end 

   

  if Input.press?(Input::DOWN)

    if @cursor.y <= [email=480-@cursor.height]480-@cursor.height[/email]

      @cursor.y += @speed

    elsif @back.y >= -1500 #Top edge won't scroll past 

      @cursor.y -= 1

      @back.y -= @speed

      @cl.y -= @speed if @cl != nil

      for i in [email=0...@ico.size]0...@ico.size[/email]

        if $game_system.unlocked?(i) == true

        @ico[i].y -= @speed

        end

      end

    else 

      @cursor.y -= 1

    end

   end 

    

  if Input.press?(Input::LEFT)

    if @cursor.x >= 0

      @cursor.x -= @speed

    elsif @back.x <= 320 #Left edge won't scroll past 

      @cursor.x += 1

      @back.x += @speed 

      @cl.x += @speed if @cl != nil

      for i in [email=0...@ico.size]0...@ico.size[/email]

        if $game_system.unlocked?(i) == true

        @ico[i].x += @speed

        end

      end

    else

      @cursor.x += 1

    end

   end 

  

  if Input.press?(Input::RIGHT) 

    if @cursor.x <= [email=640-@cursor.width]640-@cursor.width[/email]

      @cursor.x += @speed

    elsif @back.x >= -1500 #Left edge won't scroll past 

      @cursor.x -= 1

      @back.x -= @speed

      @cl.x -= @speed if @cl != nil

      for i in [email=0...@ico.size]0...@ico.size[/email]

        if $game_system.unlocked?(i) == true

        @ico[i].x -= @speed

        end

      end

      @cursor.x -= 1      

    end

   end 

   

    # If B button was pressed

    if Input.trigger?(Input::B)

      # Play cancel SE

      $game_system.se_play($data_system.cancel_se)

      # Switch to menu screen

      $scene = Scene_Menu.new(5)

      return

    end

    

    # If C button was pressed

    if Input.trigger?(Input::C)

     

       if $game_system.unlocked?(@index) == true

        $game_system.se_play($data_system.escape_se)

        $game_temp.player_new_map_id = $game_system.map_id(@index)

        $game_temp.player_new_x = $game_system.tele_cords(@index)[0]

        $game_temp.player_new_y = $game_system.tele_cords(@index)[1]

        $game_temp.player_new_direction = 2

        $game_temp.player_transferring = true

        $game_map.setup($game_temp.player_new_map_id)

        # Set up player position

        $game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)

        # Set player direction

        case $game_temp.player_new_direction

        when 2  # down

          $game_player.turn_down

        when 4  # left

          $game_player.turn_left

        when 6  # right

          $game_player.turn_right

        when 8  # up

          $game_player.turn_up

        end

        # Straighten player position

        $game_player.straighten

        $scene = Scene_Map.new

        end

      

      return

    end

    

  end

end

 

 

#==============================================================================

# ** Game_System_EDIT

#------------------------------------------------------------------------------

#  This class handles data surrounding the system. Backround music, etc.

#  is managed here as well. Refer to "$game_system" for the instance of 

#  this class.

#==============================================================================

 

class Game_System

  #--------------------------------------------------------------------------

  # * Public Instance Variables

  #--------------------------------------------------------------------------

  attr_accessor :locations

  alias map_ini_sys initialize

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  def initialize

    map_ini_sys

    @locations = []

    for i in 0...LMAP::Locations.size

      @locations.push(LMAP::Locations[i])

    end

  end

  

  def map_id(n)

    return @locations[n][0]

  end

  

  def add_location(n)

    return @locations[n][3] = true

  end

  

  def remove_location(n)

    return @locations[n][3] = false

  end

  

  def cord(n, v)

    return @locations[n][4+v]

  end

  

  def tele_cords(n)

    return [@locations[n][1], @locations[n][2]]

  end

  

  def loc_icon(n)

    return @locations[n][6]

  end

  

  def unlocked?(n)

    if @locations[n][3] == true

      return true

    elsif @locations[n][3] == false

      return false

    end

  end

  

end

 

#===================================================

# Game Map Edit

#===================================================

class Game_Map

 def name

   $map_infos[@map_id]

 end

 

 def get_map

   return @map_id

end

 

 def list_name(n)

   $map_infos[n]

 end

end

 

class Scene_Title

   $map_infos = load_data("Data/MapInfos.rxdata")

   for key in $map_infos.keys

     $map_infos[key] = $map_infos[key].name

   end

end

 

 

#==============================================================================

# ** Map_Cursor

#------------------------------------------------------------------------------

#  This sprite is used to display the cursor for the world map.

#==============================================================================

 

class Map_Cursor < RPG::Sprite

  #--------------------------------------------------------------------------

  # * Public Instance Variables

  #--------------------------------------------------------------------------

  #--------------------------------------------------------------------------

  # * Object Initialization

  #     viewport  : viewport

  #     character : character (Game_Character)

  #--------------------------------------------------------------------------

  def initialize(viewport)

    super(viewport)

    

    @frame = 0

    @wait = 0

    @frame_count = LMAP::Frame_Count

    @glow = false

    update

  end

  

  def height

    return @ch

  end

  

  def width

    return @cw

  end

  

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    super

    

    if @wait < 2

      @wait += 1

    else

      @wait = 0

      @frame += 1 if @frame < @frame_count

      @frame = 0 if @frame >= @frame_count

    end

    

    if LMAP::Glowing_Selection == true

      if @glow == false

        self.opacity -= 5 if self.opacity > 120

        @glow = true if self.opacity <= 120

      else

        self.opacity += 5

        @glow = false if self.opacity >= 255

      end      

    end

    

    # Remember tile ID, file name, and hue

    self.bitmap = RPG::Cache.picture(LMAP::Cursor_Name)

    @cw = bitmap.width / @frame_count

    @ch = bitmap.height

    self.ox = 0

    self.oy = 0

    self.src_rect.set(0+@cw*@frame, 0, @cw, @ch)

    # Set visible situation

    self.visible = true

    # Set sprite coordinates

    self.z = 120

    # Set opacity level, blend method, and bush depth

    self.blend_type = 0

    self.bush_depth = 0

  end

end

 

#==============================================================================

# ** Window_Map_Description

#------------------------------------------------------------------------------

#  This window shows skill and item explanations along with actor status.

#==============================================================================

 

class Window_Map_Description < Window_Base

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  def initialize

    super(0, 0, 200, 200)

    self.contents = Bitmap.new(width-32, height - 32)

  end

  #--------------------------------------------------------------------------

  # * Set Text

  #  text  : text string displayed in window

  #  align : alignment (0..flush left, 1..center, 2..flush right)

  #--------------------------------------------------------------------------

  def set_text(text, align = 0, color = normal_color)

    # If at least one part of text and alignment differ from last time

    if text != @text or align != @align

      # Redraw text

      

      

    self.contents.clear

    self.contents.font.color = color

    self.contents.font.size = 15

    x = y = 0

    @cursor_width = 0

    # Indent if choice

    if $game_temp.choice_start == 0

      x = 8

    end

      # Control text processing

 

      # Get 1 text character in c (loop until unable to get text)

      while ((c = text.slice!(/./m)) != nil)

        # If \\

        if c == "\000"

          # Return to original text

          c = "\\"

        end

        # If new line text

        if c == "\n"

          # Update cursor width if choice

          if y >= $game_temp.choice_start

            @cursor_width = [@cursor_width, x].max

          end

          # Add 1 to y

          y += 1

          x = 0

          # Indent if choice

          if y >= $game_temp.choice_start

            x = 8

          end

          # go to next text

          next

        end

        # Draw text

        self.contents.draw_text(4 + x, self.contents.font.size * y, 40, self.contents.font.size, c)

        # Add x to drawn text width

        x += self.contents.text_size(c).width

      end

      @text = text

      @align = align

    end

    self.visible = true

  end

end

 
 
First of all let me thank you for your great work.


I have two problems left yet.

1. If I open the scene map you can still see the black background but I only want to see the map itself not also the black background. You can even go beyond the map which should not be possible.
Pictures:
Or:
http://www.directupload.net/file/d/3725 ... ke_png.htm

2. I really didint understood the unlock location command.
Can you explain me what does the
Code:
LMAP::Locations[5][3] = true
5 and the 3 in this code stands for? Especially the 3 because you didint do so in your instructions. I'd like to know that.
But thank you really much so far and in advance.
keep it up!
 
1. Right, you'll have to set a limit. Something like scroll if @back.x >= -(1500 - 640). But you'll need a margin of error because it's moving at a variable rate. So you can stop it from moving after a certain point but it's possible it'll already be a few pixels too far when it stops. And like I said I've added an automatic centering, so keep locations away from the boarders. Or add a stylish trim if you can't help it.
edit: I suppose I could have it rebound if it goes past it's borders but this was only suppose to be a simple edit.

2.The locations are pushed into an array: Locations = [A,B,C,D]. And each one is it's own array of data so A represents [ID,X,Y,false,blah, blah]
So if you wanted to set A as unlocked you'd need to refer to it's location index in the array, and then the position index of the item inside that that you want to change. This would be a lot easier to explain if it was a hash instead of an array but I didn't create it.
So basically it would look like this
[ [#,#,#,false,#], [#,#,#,false,#], [#,#,#,false,#] ]
LMAP::Locations[0][3] = true
Or talk it backwards "Set true index 3 of index 0 in locations "
 
Okay I understood the unlock method now. Thanks so far :))

But let me return to the black borders. Im reallya newbie on script and I dont trust myself to edit a script on my own...
Can't you just edit the script like you did before and post it? If I edit the script I'll ruin it anyway.

EDIT:

I managed to edit it on my own:

do you think this is right? And will it have a effect on the location system??

Code:
if Input.press?(Input::UP)

    if @cursor.y >= 0

      @cursor.y -= @speed

    elsif @back.y <= -1  #top edge won't scroll past

      @cursor.y += 1

      @back.y += @speed

      @cl.y += @speed if @cl != nil

      for i in [email=0...@ico.size]0...@ico.size[/email]

        if $game_system.unlocked?(i) == true

        @ico[i].y += @speed

        end

      end

    else

      @cursor.y += 1

    end

   end

   

  if Input.press?(Input::DOWN)

    if @cursor.y <= [email=480-@cursor.height]480-@cursor.height[/email]

      @cursor.y += @speed

    elsif @back.y >= -1010 #Top edge won't scroll past

      @cursor.y -= 1

      @back.y -= @speed

      @cl.y -= @speed if @cl != nil

      for i in [email=0...@ico.size]0...@ico.size[/email]

        if $game_system.unlocked?(i) == true

        @ico[i].y -= @speed

        end

      end

    else

      @cursor.y -= 1

    end

   end

   

  if Input.press?(Input::LEFT)

    if @cursor.x >= 0

      @cursor.x -= @speed

    elsif @back.x <= -5 #Left edge won't scroll past

      @cursor.x += 1

      @back.x += @speed

      @cl.x += @speed if @cl != nil

      for i in [email=0...@ico.size]0...@ico.size[/email]

        if $game_system.unlocked?(i) == true

        @ico[i].x += @speed

        end

      end

    else

      @cursor.x += 1

    end

   end

 

  if Input.press?(Input::RIGHT)

    if @cursor.x <= [email=640-@cursor.width]640-@cursor.width[/email]

      @cursor.x += @speed

    elsif @back.x >= -855 #Left edge won't scroll past

      @cursor.x -= 1

      @back.x -= @speed

      @cl.x -= @speed if @cl != nil

      for i in [email=0...@ico.size]0...@ico.size[/email]

        if $game_system.unlocked?(i) == true

        @ico[i].x -= @speed

        end

      end

      @cursor.x -= 1      

    end

   end
 
After line 286 is where the arrow inputs are.
There are conditions that will stop the map from scrolling past a certain point.
pressing "up" moves everything down; increasing the Y coordinate
elsif @back.y <= 240 #top edge won't scroll past
Try replacing 240 with 0

pressed down moves everything up on screen. Decreasing the Y coordinate into a negative range.
elsif @back.y >= -1010 #Top edge won't scroll past
Try using -1120 (thats -1600 would put it off screen so add the screen height 480)

pressing left moves everything right. X coordiants
elsif @back.x <= -5 #Left edge won't scroll past
try 0

pressing right moves everything left into the negative X range
elsif @back.x >= -855 #Left edge won't scroll past
try -960 (thats -1600 + the screen width 640)

edit: But other then that. No, I don't think you'll need to change anything. It'll draw the whole picture regardless of it's size.
 
Sorry to disturb you once again but I found a bug which makes me not able to use this script like it should be.

After a game is loaded new locations won't show up even if they are added withhin the script call after the loading....
LMAP::Locations[1][3] = true

The Game only shows new locations if they are added within a normal game. But when I load a game which I saved before and I add locations these won't show up.

Any Ideas to fix that?
 
I'm not sure I understand. Are you specifying the correct location number?
Code:
  Locations = []

  # Location.push([map_id, tele_x, tele_y, unlocked?, map_x, Map_y, Map_icon])

  Locations.push([3, 5, 5, true, 360, 230, "move_05"])

  Locations.push([2, 5, 5, true, 220, 340, "move_06"])

  Locations.push([4, 5, 5, true, 320, 160, "move_07"])

  Locations.push([1, 5, 5, true, 480, 160, "move_04"])

  Locations.push([5, 5, 5, false, -20, 0, "move_03"])

  Locations.push([1, 5, 5, false, 280, 200, "move_02"])

remember the locations are set in an array, so they are numbered starting at 0.
5 and 6 in this list are locked. So the line
LMAP::Locations[6][3] = true
LMAP::Locations[7][3] = true
would unlock them. It stays unlocked after you save and will stay that way unless you locked it "= false". But it sounds like you want a location to be unlocked across all save files. That doesn't make sense. That'd be like finding an end-game item, saving, then loading an earlier save at the beginning of the game and expecting it to still be in your inventory. It doesn't work like that, save files are separate.
 
ok. ok. I think I see what you're saying now.
You created more locations in the script. But you're old save file doesn't know that. It's just like if the player was Fighter01, you saved. Then you went into the database and changed the sprite to Figher02. It'll still be using Fighter01 when you load the game again.

This is why you should regularly start fresh with a new save. You're going miss all sorts of bugs if you keep playing with the same old save file. Haha, trust me. I've worked with guys who don't realize how broken their game is because they used the same save file for like a year.
 
I also thought about that but it cannot be true because I started a new game and saved it.
After I loaded it I used add more locations thru the call script I mean not the main scripts. But they didint show up in the world map.
It seems like loaded games cant add another locations which makes it not useable :((

ps. You can try it in your own: Make a new game and save it. Afterwards Load the file and try to unlock some locations with a callscript. They won't show up. They only show up when the game is started regular without loading a file. But WHEN you load a file and try to unlock locations it won't work. Thats my problem.

Edit: I've prepared a demo for you.
first talk to basil and look at the map. Don't talk to the guy next to him because hes the who who can unlock locations. Then save it and close it. Now load it and talk to the other guy. Normally he would unlock a location but due the fact that you loaded the file the new locations won't show up...

Now start the game normal and talk to the other guy and now to basil and the location will be unlocked. Unlocking locations doesnt work once you loaded a game. thats my problem.

demo link with your edited script
Azrith cursor map coyotecraft.rar
 
I figured it out. There are 2 location lists. Locations and @locations. @locations being the list the game works with.
I didn't see this before, but there was a method to unlock/lock a location.

The script call you should be using is. $game_system.add_location(n)
n being the location number. You can hide it using $game_system.remove_location(n)

^It basically does the same thing I had you doing before except it targets the other location list.
You should correct the instructions I wrote. In case you forget or pass it on to someone else.
 
Thank you very much I've some question left so far:

1. So basicly both do the same thing? Do I need to use both commands in order to unlock a location or only the last command?
2. So if I want to unlock this location here: LMAP::Locations[1][3] = true
I would need to use $game_system.add_location(1) right?
 
Just use
$game_system.add_location(n)

But remember, if there were 8 locations when you saved. And you create 2 more while editing you'll have to make a new save file. That old save file will only remember 8 locations.
I would rewrite the whole thing to be more dynamic. But that would be too much work for a minor inconvenience.
 
Allow me to ask a question again.

Everything works fine so far. But theres one probem left.

The picture/window where the name of the current location is shown overlaps with the icons of the locations activated. Normally the Icons of the locations should be under the window where the location name is shown. I hope you got my point.. :))
Can you fix that?
 
I think I understand.
You need to set a z coordinate. That title bar is made of 2 parts, the graphic and the text.
Add
@map_help.z = 140
@command_window.z = 150

under line 88. There should be other Z settings for Map descriptions. Just plug it in there. That should keep the title bar above the icons.
 
like this
likeThis_zps5a845e87.png
 
Hey coyotecraft, I wanted to say thanks for being so helpful! It's community members like you that keep me coming here. I was also having difficulties adding locations with this script until I read your posts. One error that I can't seem to work around, is that the order in which locations are added can cause the script to crash.
Locations = []
  # Location.push([map_id, tele_x, tele_y, unlocked?, map_x, Map_y, Map_icon])
  Locations.push([1, 5, 5, false, 360, 230, "move_05"]) #Map A
  Locations.push([2, 5, 5, false, 220, 340, "move_06"]) #Map B
  Locations.push([3, 5, 5, false, 320, 160, "move_07"]) #Map C
For example, all three locations are locked by default when the game loads, which works fine. However, if location B is unlocked and added to the map before location A is unlocked and added, then the script gives this error:

line 175: NoMethodError occurred.
undefined method 'x' for nil:NilClass
(I just realized 175 will be different lines depending on the # of locations, but here's the line it was referencing:
Code:
 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))


I know you've stated that this isn't exactly efficiently scripted, but do you think there's any work around to solve this problem? The way it is now, it'd work fine in a game with linear progression, but in an open world game this script wouldn't function properly. Thanks in advance!
 
hmmm. I can't replicate the problem.
Are you using this to add locations?
$game_system.add_location(n)

That line error is in a loop in the update method
for i in 0...@ ico.size
meaning for each location, "i", it checks if the cursor is close enough to snap to a location icon. But the no method error suggest that one of the locations doesn't have an X coordinate for the cursor to snap to. Or maybe it's trying to snap to a location that's not unlocked and therefore not on the map. I sorta recall fixing that but I can't remember what all I changed.

My update method might look different then yours. Tell me, does the line above 175 have
if $game_system.unlocked?(i) == true
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top