I'm moving all of my scripts from rmxp.org to this site. I like it here better.IntroductionA simple script that shows you how to have the name of your map appear on screen while you walk around. I've seen other scripts that were created to perform this task, but I found that they were either incomplete or had too much clutter. I've also kept this script simple so that you can build off of it.
FeaturesShow the name of the current map on screen
ScriptNOTE: ONLY ADD ITEMS IN
BLUE TO YOUR SCRIPTS. YOU DO NOT NEED TO DELETE ANY EXISTING SCRIPTS.
Use the the following scripts to modify your existing classes. For a script that merges all of these things together, scroll down to Raziel's post.
Update the
Game_Map class with these changes:
CODE
#=======================================================
# ■ Game_Map
#=======================================================
class Game_Map
#-------------------------------------------------------------------
# ● Properties
#-------------------------------------------------------------------
[COLOR=blue]attr_reader :map_name[/COLOR]
#-------------------------------------------------------------------
# ● Set up game
#-------------------------------------------------------------------
def setup(map_id)
[COLOR=blue] # Get the name of the map
@map_id = map_id
@map = load_data(sprintf("Data/Map%03d.rxdata", @map_id))
@map_name = load_data("Data/MapInfos.rxdata")[$game_map.map_id].name[/COLOR]
end
Create the following class,
Window_MapName, and put it with your window classes. (Copy and paste it)
CODE
[COLOR=blue]#========================================================
# ■ Window_MapName
#========================================================
class Window_MapName < Window_Base
#---------------------------------------------------------------------
# ● Initializes the Map Name window
#---------------------------------------------------------------------
def initialize
super(0, 0, 260, 64)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
#----------------------------------------------------------------------
# ● Draw the name of the map
#----------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, 220, 32, $game_map.map_name.to_s, 2)
end
#---------------------------------------------------------------------
# ● Update the name of the map
#---------------------------------------------------------------------
def update
super
refresh
end
end[/COLOR]
Update the
Scene_Map class:
CODE
#=======================================================
# ■ Scene_Map
#=======================================================
#---------------------------------------------------------------------
# ● Set up the scene
#---------------------------------------------------------------------
def main
@spriteset = Spriteset_Map.new
@message_window = Window_Message.new
[COLOR=Blue] # Add name of map to window
@name_window = Window_MapName.new
@name_window.opacity = 0
@name_window.x = 390
@name_window.y = 430[/COLOR]
Graphics.transition
Graphics.freeze
@spriteset.dispose
@message_window.dispose
[COLOR=blue] @name_window.dispose[/COLOR]
end
#----------------------------------------------------------------------
# ● Player Place Move
#----------------------------------------------------------------------
def transfer_player
$game_temp.player_transferring = false
# Map to teleport to
if $game_map.map_id != $game_temp.player_new_map_id
$game_map.setup($game_temp.player_new_map_id)
[COLOR=blue]@name_window.update[/COLOR]
end
end
end
Instructions1. In the Game_Map class, add this to the list of properties:
attr_reader :map_name
2. In the Game_Map class, within the setup method, add this line beneath the @map_id = map_id line:
@map_name = load_data("Data/MapInfos.rxdata")[$game_map.map_id].name
3. Copy the Window_MapName class (see code above) and create a new section for it in the Script Editor. It should appear in the section where you have all of your Window classes.
4. In the Scene_Map class, within the main method, add this beneath the @message_window = Window_Message.new line:
# Add name of map to window
@name_window = Window_MapName.new
@name_window.opacity = 0
@name_window.x = 390
@name_window.y = 430
5. In the Scene_Map class, within the main method, add this beneath the @message_window.dispose line:
@name_window.dispose
6. In the Scene_Map class, within the transfer_player method, add this within the if $game_map.map_id != $game_temp.player_new_map_id statement:
@name_window.update
This post has been edited by amaranth: Dec 21 2008, 07:38 PM