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.

Map Icon

Well, Hi.  :)

I got this common event;
Code:
<>Conditional Branch: Switch [0002: Map Name] == ON
 <>Variable: [0005: Map ID] = Map ID
  <>Conditional Branch: Variable [0005: Map ID] == 52
   <>Show Picture: 1, 'Map Icon - Mushroom Town', Upper-Left Pixel (1,5), (100%,100%),255,Normal
   <>
   : Else handler
   <>Erase Picture: 1
   <>
   : End
   <>
  : Else handler
 <>Erase Picture: 1
  : End
<>

And I was wandering if something like this is possible in a script, because there's a bug; the picture won't go away in like for example Scene_Menu.

Also, I would not want the picture to dissapear, it has to stay where it is when a specifix switch is on.

All help is welcome.  ::)
 
I found Moghunter's Map Name script, thank you for the clue baniff. However, it's not really what I meant.

I already made the basic stuff myself;

Code:
SWITCH = 2
#========================================================================
# ** Window_Info
#------------------------------------------------------------------------------
# This class is used to display the current location.
#========================================================================
class Window_Info < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(-16, -16, 640, 480)
self.contents = Bitmap.new(width-32, height-32)
self.opacity = 0
self.contents.font.size = 16
self.visible = $game_switches[SWITCH]
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.font.color = normal_color

#Images ------------------------------------------------------------------
bitmap = RPG::Cache.picture("Game - Map Info")
self.contents.blt(0, 0, bitmap, Rect.new(0, 0, 600, 600))

self.contents.font.name = "Monotype Corsiva"
self.contents.font.size = 16
self.contents.font.bold = false
self.contents.font.color = system_color
$data_map_infos = load_data("Data/MapInfos.rxdata")
self.contents.draw_text(35, 10, 490, 17, $data_map_infos[$game_map.map_id].name)
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
  def update
    super
    self.visible = $game_switches[SHOW_SWITCH]
  end
end

http://img65.imageshack.us/img65/5605/gamemapinfouj1.png (For the image in the script above.)

Could somebody modify that script so that before the map's name it shows a picture and so that every map has a picture of its own. Something like :

Code:
 if $game_map.map_id == 1
 bitmap = RPG::Cache.picture("Game - Mushroom Town")
 elsif $game_map.map_id == 2
 bitmap = RPG::Cache.picture("Game - Garde Forest")
 *etcetera...*

First of all; I know that's probaly not even in the right direction how to handle this, but I hope you'll get the idea.
And second; I want it so that I can decide the x and y position of the picture offcourse. :P

Thanks in advance. If I get it to work myself I'll say so. :)
 

jhd

Member

I did a similar thing using MOG's map name script. It displays a picture that shares the same name as the map + _fc. For example, if your map is called Mushroom Town then you will need a picture called "Mushroom Town_fc". If there are no pictures associated with a map, no name will show up (an advantage for locations you don't want to show the map name of).

Also, unlike Mog's original script a back image will not be shown, only "mapname_fc".

Hope this helps. However, you should know I am most certainly not a scripter but I will try to help if you are having problems.

PS Credit Moghunter if used.

#_______________________________________________________________________________
# MOG_MPW Map_Name V1.2           
#_______________________________________________________________________________
# By Moghunter     
# http://www.atelier-rgss.com
#_______________________________________________________________________________
module MOG
#Font Name.
MPFONT = "Georgia"
#Fade ON/OFF(True - False).
MPNMFD = true
#Fade Time(in seconds).
MPNMTM = 10
#Window Position.
# 0 = Upper Left.
# 1 = Lower Left.
# 2 = Upper Right.
# 3 = Lower Right.
MPNMPS = 2
# Disable Window Switch(ID).
WM_SWITCH_VIS_DISABLE = 15
end
#_________________________________________________
$mogscript = {} if $mogscript == nil
$mogscript["mpmapname"] = true
###############
# Game_System #
###############
class Game_System
attr_accessor :fdtm
attr_accessor :mpnm_x
attr_accessor :mpnm_y
alias mog24_initialize initialize
def initialize
mog24_initialize
@fdtm = 255 + 40 * MOG::MPNMTM
if MOG::MPNMPS == 0
@mpnm_x = -300
@mpnm_y = 0
elsif MOG::MPNMPS == 1
@mpnm_x = -300
@mpnm_y = 380
elsif MOG::MPNMPS == 2
@mpnm_x = 640
@mpnm_y = 0
else
@mpnm_x = 640
@mpnm_y = 380
end 
end
def mpnm_x
return @mpnm_x
end
def mpnm_y
return @mpnm_y
end
def fdtm
if @fdtm <= 0
@fdtm = 0
end
return @fdtm
end
end
############
# Game_Map #
############
class Game_Map
attr_reader  :map_id 
def mpname
$mpname = load_data("Data/MapInfos.rxdata")
$mpname[@map_id].name
end
end
###############
# Window Base #
###############
class Window_Base < Window
def nd_mapic
mapic = RPG::Cache.picture("")   
end 
def draw_mpname(x,y)
mapic = RPG::Cache.picture($game_map.mpname.to_s + "_fc") rescue nd_mapic 
cw = mapic.width 
ch = mapic.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x - 10 , y - ch + 65, mapic, src_rect)
end
end
##########
# Mpname #
##########
class Mpname < Window_Base
def initialize
super($game_system.mpnm_x, $game_system.mpnm_y, 250, 100)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
refresh
end
def refresh
self.contents.clear
draw_mpname(10,0)   
end
end
#############
# Scene_Map #
#############
class Scene_Map
alias mog24_main main
def main
@mpnm = Mpname.new
@mpnm.contents_opacity = $game_system.fdtm
if $game_switches[MOG::WM_SWITCH_VIS_DISABLE] == false
@mpnm.visible = true
else
@mpnm.visible = false 
end 
mog24_main
@mpnm.dispose
end
alias mog24_update update
def update
mog24_update 
$game_system.mpnm_x = @mpnm.x
$game_system.mpnm_y = @mpnm.y
if $game_switches[MOG::WM_SWITCH_VIS_DISABLE] == false
if $game_system.fdtm <= 0
@mpnm.visible = false 
else
@mpnm.visible = true 
end
else
@mpnm.visible = false 
end
if MOG::MPNMPS == 0 or MOG::MPNMPS == 1
if @mpnm.x < 0
  @mpnm.x += 8
elsif @mpnm.x >= 0
  @mpnm.x = 0
end 
else
if @mpnm.x > 400
  @mpnm.x -= 8
elsif @mpnm.x <= 400
  @mpnm.x = 400
end   
end
@mpnm.contents_opacity = $game_system.fdtm
if MOG::MPNMFD == true
$game_system.fdtm -= 3
end
end
alias mog24_transfer_player transfer_player
def transfer_player
mog24_transfer_player
if MOG::MPNMPS == 0
$game_system.mpnm_x = -300
$game_system.mpnm_y = 0
elsif MOG::MPNMPS == 1
$game_system.mpnm_x = -300
$game_system.mpnm_y = 380
elsif MOG::MPNMPS == 2
$game_system.mpnm_x = 640
$game_system.mpnm_y = 0
else
$game_system.mpnm_x = 640
$game_system.mpnm_y = 380
end 
@mpnm.y = $game_system.mpnm_y
@mpnm.x = $game_system.mpnm_x
$game_system.fdtm = 255 + 40 * MOG::MPNMTM
@mpnm.refresh
end
end
 
Thank you. That's something.  :D

Now, can somebody just tell me how you can check what the ID of a map is?
Cause;
Code:
if $game_map.map_id = 52
That doesn't seem to work.

I get 'undefined method for map_id=' :-X
 

jhd

Member

Sorry if this seems like a daft question, but what do you need that for?

All you should need is the name of the map, so by default it is Map001, Map002 etc.

If you have named your maps something else then the Map ID shouldn't matter...

EDIT: Just tried this with a new project. The only script used was the one I just posted. For the sake of this post there will be only one map. Call the map Mushroom City. Create a picture file (mine is about 65*215px) of whatever it is you want to be displayed. Name the picture file: Mushroom City_fc. Place this file in the picture folder. Begin the game and hey presto, your image should scroll in to the top right hand corner and after a short while fade.
 
First of all; I don't want it displayed there and I don't want it to come in scrolling or whatever. ::)
(But i could modify that myself.)
Second; I need the map ID cause I want to do it an other way an 'easier for me to understand' way. :P
Third; I need to do it this way to make it work with my own location script.

And on top of that, I can't use it correctly because my pc doesn't allow me to put ':' in names of files. (I have ':' in my map names.)  ;)
 

jhd

Member

Fair enough, although it should be easy enough for you to change where the image displays (I know that Mog's script gives the option of top left, top right, bottom left and bottom right - all of which are changeable easily enough I would think).

As far as ease of use goes, it should be easier this way than using events. All you need is a picture file per map, if the map doesn't have a picture then it won't display anything which will also stop any errors coming up. All you need to know for this is the map name which means if the order of the maps is changed you won't get confused unlike using mapIDs.

About using ":" in your file names, you don't necessarily need to. If your map names is, for example, Mushroom City:Inn, change it to Mushroom City-Inn or MushroomCityInn or any variation of this. The actually map name is inconsequential, it will not be displayed. When I used this script I used a text graphic saying "Mushroom City", the game itself no longer displays it with this script. As far as the script is concerned, the map could be called - This is my first map ever!!! If image "this is my first map ever!!!_fc" is an image of  a mushroom and the words "mushroom city" it shouldn't matter.

Anyway, it was worth a try. If you would like further help I would be glad to try, if not then good luck, I'm sure you'll find a way!
 
Yes, it's obvious i could change my map names, but no. Just no. :P

Thanks anyways. ::)

Now, can somebody just tell me how you can check what the ID of a map is?
Cause;
Code:
if $game_map.map_id = 52
That doesn't seem to work.

I get 'undefined method for map_id='
 

jhd

Member

Okay...well, out of the goodness of my heart, I decided to have one last go.

As I said, I know very little about scripting and couldn't get it to work by map_id.

However, I made a quick edit to your common event that should also do what you wanted (although fairly badly).

But!!! It will involve:
a) a lot of eventing
b) editing every transfer player event to add a control switch command.

<>Control Variables: [001:Map ID]=Map ID
<>Conditional Branch: Switch [001:Show Map Name] == ON
    <> Conditional Branch: Variable [001:Map ID] == 1
    <> Show Picture: 50, 'MAP 1', Upper Left (0,0), (100%,100%),255,Normal
    <> Wait: 20 frames
    <> Control Switches: [001:Show Map Name] == OFF
  : Else
    <> Conditional Branch: Variable [001:Map ID] == 2
    <> Show Picture: 50, 'MAP 2', Upper Left (0,0), (100%,100%),255,Normal
    <> Wait: 20 frames
    <> Control Switches: [001:Show Map Name] == OFF
  : Else
  <>Erase Picture: 50
  <>
  : End
  <>Erase Picture: 50
  <>
  : End
  <>Erase Picture: 50
  <>
  : Else
<>Erase Picture: 50
<>
  : End
<>

That should work, picture 50 is used in case any other pictures get messed up by this script. It should be on a Parallel trigger.

"Wait 20 frames" is nowhere near enough (I wouldn't say) but it is just to give you an idea of how it works. Obviously, now the name of the picture doesn't matter, you just have to pick the one you need. As I said, it will take more effort, but should be easier for you if you didn't like the script. Every transfer event (or at least the ones you want to show the map picture after) should have a control switch command (Show Map Name switch to ON) AFTER the transfer player command.
 
I now know we had a misunderstanding, because I don't want the location to go away or anything.
I have another common event called 'Quick Keys', like if you press S it brings up the status menu of the leading actor. If you press A it will bring up the location window in the top of the screen.
And if you press A again, the location screen will dissapear again. When A is pressed again, the location window will be visible again. ;)

Yes, i tried it using a common event. But, the picture then won't dissapear when going to the menu and such. Strangly enough it does dissapear when going in-battle.
 

jhd

Member

Ah, so that's where we went wrong!

Okay, firstly, I would edit your first post to include this information, it really is not explained at all in that first post. Don't worry about it, it's been sorted know but maybe keep in mind for next time - people don't know everything about your game, you will need to give as much information as possible about your systems.

As far as I know, pictures will show above everything else which is why it remains when you open the menu. One option would be to disable the option menu whilst the button is pressed (an event option), just remember to enable it when the button is released. That way people can't open the menu whilst the picture is displayed.

Another idea would be change your Quick Keys event to one where the displays will only show whilst the button is being pressed i.e. you hold A to show map location, when you release A it disappears, hold S -status screen shows, let go and it disappears etc. This should stop the picture being shown over the menu, unless you hold the keys in the menu which is unlikely.

If neither of these options are ideal then I really am stumped. Nonetheless, I wish you the best luck in finding a solution.
 

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