Jump to content
Sign in to follow this  
Mikalo

Simple Change Map Display Name - Notetag version added!

Recommended Posts

UPDATE: New version uses notetags.

 

So, I'm still new at this scripting thing and maybe there is an easier way to do this, but I wrote a very simple script to change the map display name. I didn't see an event for this (I saw one for turning it on or off, but not changing the actual name).

 

 

#------------------------------------------------------------------------------
#Mikalo's Very Simple Map Name Changer
#
#A simple script that allows you to change the display name for a map. Helpful
#if you have multiple areas(all the shops in town for example) on one map and
#want to adjust the display name according to what shop they enter.
#
#Create a variable that all doors leading to that map can change the value of.
#Than create an event on the map that checks the variable and changes the
#name accordingly. Like the following example.
#
# Conditional Branch: Variable[0001:TownNames] == 1
#   Script: $game_map.map_name_change('NewMap1')
# Branch End
#------------------------------------------------------------------------------
class Game_Map
 def map_name_change(newName)
@map.display_name = newName
 end
end

 

 

This next version uses notetags! It's a bit simpler for those to use who don't want to mess with events and variable checking.

 

 

#------------------------------------------------------------------------------
#Map Display Name Changer
#By Mikalo
#
#Allows you to change the map display name based on where the person teleports
#into. To use, place the following notetag in a map note field.
#<Map Name Change: x-coord, y-coord, "Display Name">
#Example
#<Map Name Change: 23, 12, "Blacksmith Shop">
#x-coord and y-coord should be the coordinates you are teleporting to on the map
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#Do not edit past this point or else your head might explode.
#------------------------------------------------------------------------------
module MIK
 module LINEEXP
CHANGE_NAME_LINE = /<(?:CHANGE_NAME_LINE|Map Name Change):[ ]*(\d+),[ ]*(\d+),[ ]*.*>/i
 end
end

class Game_Player
 alias new_moveto moveto
 def moveto(x, y)
$game_map.get_notes(x,y)
new_moveto(x,y)
 end
end

class Game_Map
 def get_notes(x,y)
@playerX = x
@playerY = y
split_notes
 end
 def split_notes
@mapNotes = @map.note
unless @mapNotes.nil?
@mapNotes.split(/[\r\n]+/).each { |line|
case line
#---
when MIK::LINEEXP::CHANGE_NAME_LINE
  xy = 0
  line.scan(/\d+/).each { |num|
  case xy
	when 0
	  @xcoord = num.to_i
	  xy = 1
	when 1
	  @ycoord = num.to_i
	  xy = 0
	  break
  end} #End of case
  line.scan(/".*"/).each { |title|
  @newMapName = title[1,title.length-2]}
  if @xcoord == @playerX and @ycoord == @playerY
	map_name_change(@newMapName)
  end
end
  }
end
 end

 def map_name_change(newName)
@map.display_name = newName
 end
end

 

 

There isn't any customization for it really, and it's pretty straight forward. Hope it helps.

Edited by Mikalo

Share this post


Link to post
Share on other sites

Thanks! I was looking for that. I have updated the code and added a new version. The new version allows....notetags! No more tracking variables and calling event scripts. You can now simply set name location changes in the map notetags. Hope this is helpful to someone!

 

Note: You can sitll make direct calls to the method, so I have left both versions up.

Edited by Mikalo

Share this post


Link to post
Share on other sites

Sorry, I've been away for a bit. I certainly have no issues with it being used in commercial games if it's useful and proper credit is given.

Share this post


Link to post
Share on other sites

Could you add option to force displaying new map name on current map to first version of script? I need this feature for my game.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted