The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Scripting => Topic started by: Nathmatt on November 15, 2006, 02:47:15 AM

Title: can some 1 help me with this script
Post by: Nathmatt on November 15, 2006, 02:47:15 AM
i know it works just dont know to use it hers the script its a mini map script



#==============================================================================
# ? MiniMapScript
#------------------------------------------------------------------------------
# Translation credit: Mr. DJ
# Stolen by : KHORN, markusmks
#==============================================================================

class MiniMapScript < Window_Base
  attr_accessor :modus
  #--------------------------------------------------------------------------
  # ? Initialize
  #--------------------------------------------------------------------------
  def initialize(mapname=nil)
    super(0, 0, 200, 67)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.color = normal_color
    self.contents.font.name = "Arial"
    self.contents.font.size = 20
    self.windowskin = nil
    # ---------------------------OPTIONEN-------------------------
    # Modus 1 = Name of the map as: "mapname.png"
    # Vb: "Dungeon.png"
    # Modus 2 = Id as the name as "mapID.png"
    # Vb: "1.png"
    # Modus 3 = $name_minim[MapID] = "Screen" / screenone ".png"
    # in Modus 3 you save all the images in /pictures/MiniMaps and asign them to the map with call script
    #============================================================
    @modus = 3
    # ------------------------------------------------------------
    @mapname = mapname
    if @modus == 1
      real_map = $game_map.name
    elsif @modus == 2
      real_map = $game_map.map_id.to_s
    elsif @modus == 3
      real_map = $name_minim[$game_map.map_id]
    end
    @real_map = real_map
    if FileTest.exist?("Graphics/Pictures/MiniMaps/"+real_map+".png")
      @mapname = real_map
    end
    if @mapname != nil
      #--<Colors>-- Will be the colors of the player and NPC, but do not change these! see below
      player_color = Color.new(0,0,0)
      npc_color = Color.new(255,0,0)
      #----MAP------------------------#
      @player_color=player_color
      @npc_color=npc_color
      @gra_dir = "Graphics/Pictures/MiniMaps/"
      @mmap = @gra_dir+@mapname+".png"
      map = Bitmap.new(@mmap)
      @map_sprite = Sprite.new
      @map_sprite.bitmap = map
      @map_sprite.x = 0
      @map_sprite.y = 0
      @map_sprite.opacity = 180
      @map_sprite.zoom_x = 0.98
      @map_sprite.zoom_y = 0.98
      #------PLAYER------------#
      @player_sprite = Sprite.new
      @player_sprite.bitmap = Bitmap.new(3,3)
      @player_sprite.bitmap.fill_rect(0,0,3,3,@player_color) #you can change these
      @event_sprite = []
      for i in $game_map.events.keys.sort
        if ($game_map.events[i].is_a?(Game_Event) and $game_map.events[i].list!=nil and $game_map.events[i].list[0].code == 108 and $game_map.events[i].list[0].parameters == ["mm_point"])
          @event_sprite[i] = Sprite.new   
          @event_sprite[i].bitmap = Bitmap.new(3,3)
          if $game_map.events[i].list[1].parameters[0] != nil
            colors = $game_map.events[i].list[1].parameters[0].split
            red = colors[0].to_i
            green = colors[1].to_i
            blue = colors[2].to_i
            @npc_color = Color.new(red,green,blue)
          else
            @npc_color = Color.new(255,0,0)
          end
          @event_sprite[i].bitmap.fill_rect(0,0,3,3,@npc_color)
        end
      end
      refresh
    end
  end
  #--------------------------------------------------------------------------
  # ? Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    if @event_sprite == []
      renew
    end
    if FileTest.exist?("Graphics/Pictures/MiniMaps/"+@real_map+".png")
      @mapname = @real_map
    else
      @mapname = nil
    end
    if @mapname != nil
      for i in $game_map.events.keys.sort
        if ($game_map.events[i].is_a?(Game_Event) and $game_map.events[i].list!=nil and $game_map.events[i].list[0].code == 108 and $game_map.events[i].list[0].parameters == ["mm_point"])
          if @event_sprite == []
            renew
            return
          end
          @event_sprite[i].x = $game_map.events[i].real_x/16
          @event_sprite[i].y = $game_map.events[i].real_y/16
          @event_sprite[i].opacity = 255
          @event_sprite[i].zoom_x = 1
          @event_sprite[i].zoom_y = 1
        end
        i += 1
      end
      #----PLAYER MOVE---------#
      @player_sprite.x = $game_player.real_x/16
      @player_sprite.y = $game_player.real_y/16
      @player_sprite.opacity = 255
      @player_sprite.zoom_x = 1
      @player_sprite.zoom_y = 1 
      #----------------------------#
    end
  end
  #--------------------------------------------------------------------------
  # ? Renew Graphics
  #--------------------------------------------------------------------------
  def renew
    dispose
    if @modus == 1
      real_map = $game_map.name
    elsif @modus == 2
      real_map = $game_map.map_id.to_s
    elsif @modus == 3
      real_map = $name_minim[$game_map.map_id]
    end
    @real_map = real_map
    if FileTest.exist?("Graphics/Pictures/MiniMaps/"+@real_map+".png")
      @mapname = real_map
    end
    @gra_dir = "Graphics/Pictures/MiniMaps/"
    @mmap = @gra_dir+@mapname+".png"
    map = Bitmap.new(@mmap)
    @map_sprite = Sprite.new
    @map_sprite.bitmap = map
    @map_sprite.x = 0
    @map_sprite.y = 0
    @map_sprite.opacity = 180
    @map_sprite.zoom_x = 0.98
    @map_sprite.zoom_y = 0.98
    @player_sprite = Sprite.new
    @player_sprite.bitmap = Bitmap.new(3,3) #you can change these
   
    @player_sprite.bitmap.fill_rect(0,0,3,3,@player_color=Color.new(0,0,0)) #you can change these
    @event_sprite = []
    for i in $game_map.events.keys.sort
      if ($game_map.events[i].is_a?(Game_Event) and $game_map.events[i].list!=nil and $game_map.events[i].list[0].code == 108 and $game_map.events[i].list[0].parameters == ["mm_point"])
        @event_sprite[i] = Sprite.new   
        @event_sprite[i].bitmap = Bitmap.new(3,3)
        if $game_map.events[i].list[1].parameters[0] != nil
          colors = $game_map.events[i].list[1].parameters[0].split
          red = colors[0].to_i
          green = colors[1].to_i
          blue = colors[2].to_i
          @npc_color = Color.new(red,green,blue)
        else
          @npc_color = Color.new(255,0,0)
        end
        @event_sprite[i].bitmap.fill_rect(0,0,3,3,@npc_color) #you can change these
      end
    end
  end
  #--------------------------------------------------------------------------
  # ? Update
  #--------------------------------------------------------------------------
  def update
    if @modus == 3 and $name_minim[$game_map.map_id] != ""
      renew
    end
    refresh
  end
  #--------------------------------------------------------------------------
  # ? Dispose all
  #--------------------------------------------------------------------------
  def dispose
    if @event_sprite != nil
      for sprite in @event_sprite
        if sprite != nil
          sprite.dispose
        end
      end
    end
    if @player_sprite != nil
      @player_sprite.dispose
    end
    if @map_sprite != nil
      @map_sprite.dispose
    end
  end
end

#==============================================================================
# ? Game_MiniMap
#------------------------------------------------------------------------------
# © i dont know
#==============================================================================

class Game_MiniMap
  #--------------------------------------------------------------------------
  # ? Initialize
  #--------------------------------------------------------------------------
  def initialize
    @data = []
  end
  #--------------------------------------------------------------------------
  # ? Map ID
  #     variable_id : Map ID
  #--------------------------------------------------------------------------
  def [](variable_id)
    if variable_id <= 5000 and @data[variable_id] != nil
      return @data[variable_id]
    else
      return ""
    end
  end
  #--------------------------------------------------------------------------
  # ? MiniMap Screen declared here
  #     variable_id : Map ID
  #     value       : Screen Name
  #--------------------------------------------------------------------------
  def []=(variable_id, value)
    if variable_id <= 5000
      @data[variable_id] = value
    end
  end
end

# ====================  Read this  =======================================
#
# As i cannot alias, please read this!!
# To make sure the data of the minimaps is saved,
# Copy the text between the edits, to the corresponding place in:
# Scene_Title, Scene_Load, Scene_Save
# After you did that...
# ...Delete all the codes below
# so they wont work here ^^... Mr. DJ
#
# ==================================================================

class Scene_Title
  def command_new_game
    $game_system.se_play($data_system.decision_se)
    Audio.bgm_stop
    Graphics.frame_count = 0
    $game_temp          = Game_Temp.new
    $game_system        = Game_System.new
    $game_switches      = Game_Switches.new
    $game_variables     = Game_Variables.new
    $game_self_switches = Game_SelfSwitches.new
    $game_screen        = Game_Screen.new
    $game_actors        = Game_Actors.new
    $game_party         = Game_Party.new
    $game_troop         = Game_Troop.new
    $game_map           = Game_Map.new
    $game_player        = Game_Player.new
    # EDIT -------------------------------
    $name_minim         = Game_MiniMap.new
    # ------------------------------------
    $game_party.setup_starting_members
    $game_map.setup($data_system.start_map_id)
    $game_player.moveto($data_system.start_x, $data_system.start_y)
    $game_player.refresh
    $game_map.autoplay
    $game_map.update
    $scene = Scene_Map.new
  end
end
class Scene_Save
  def write_save_data(file)
    characters = []
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      characters.push([actor.character_name, actor.character_hue])
    end
    Marshal.dump(characters, file)
    Marshal.dump(Graphics.frame_count, file)
    $game_system.save_count += 1
    $game_system.magic_number = $data_system.magic_number
    Marshal.dump($game_system, file)
    Marshal.dump($game_switches, file)
    Marshal.dump($game_variables, file)
    Marshal.dump($game_self_switches, file)
    Marshal.dump($game_screen, file)
    Marshal.dump($game_actors, file)
    Marshal.dump($game_party, file)
    Marshal.dump($game_troop, file)
    Marshal.dump($game_map, file)
    Marshal.dump($game_player, file)
    # EDIT ------------------------
    Marshal.dump($name_minim, file)
    # -----------------------------
  end
end
class Scene_Load
  def read_save_data(file)
    characters = Marshal.load(file)
    Graphics.frame_count = Marshal.load(file)
    $game_system        = Marshal.load(file)
    $game_switches      = Marshal.load(file)
    $game_variables     = Marshal.load(file)
    $game_self_switches = Marshal.load(file)
    $game_screen        = Marshal.load(file)
    $game_actors        = Marshal.load(file)
    $game_party         = Marshal.load(file)
    $game_troop         = Marshal.load(file)
    $game_map           = Marshal.load(file)
    $game_player        = Marshal.load(file)
    # EDIT ---------------------------------
    $name_minim         = Marshal.load(file)
    # --------------------------------------
    if $game_system.magic_number != $data_system.magic_number
      $game_map.setup($game_map.map_id)
      $game_player.center($game_player.x, $game_player.y)
    end
    $game_party.refresh
  end
end
Title: Re: can some 1 help me with this script
Post by: :) on November 15, 2006, 02:57:49 AM
have you inserted it into your game? is taht what you are asking how to insert a script?
Title: Re: can some 1 help me with this script
Post by: Nathmatt on November 15, 2006, 03:03:33 AM
iv inserted it but it erors heres the demo the guy made who made it but i cant figure out hot to use it
Title: Re: can some 1 help me with this script
Post by: sum41freak on November 15, 2006, 04:27:44 AM
Where'd you put it, above main? if not, do so. that may help.
Title: Re: can some 1 help me with this script
Post by: :) on November 15, 2006, 04:30:37 AM
(not sure if its needed)

But do you have the sdk, and follow the instructions on the page you found the script on how to run it on a map.
Title: Re: can some 1 help me with this script
Post by: Blizzard on November 15, 2006, 10:04:00 AM
And use [ code ] tags, otherwise the code may get corrupted.
Title: Re: can some 1 help me with this script
Post by: Nathmatt on November 15, 2006, 01:44:17 PM
as far as i know i did everything he told me to do but i just cant get the mini map to work if coppied his script & his call script .  i even coppied the pics he was using but its still not working
Title: Re: can some 1 help me with this script
Post by: :) on November 16, 2006, 12:24:20 AM
can we get a link to the exact page the script is on?
Title: Re: can some 1 help me with this script
Post by: Nathmatt on November 16, 2006, 02:38:45 AM
here the website http://www.dubealex.com/asylum/index.php?showtopic=2001