Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
  • 0
Sign in to follow this  
Tosharu

[XP] I need help with a map name script

Question

This is the Map_Count class I created. It checks to see up to which map# exists so that I don't get a file can not load error later on.

It also tells my other script using variable[01] how many maps are in the game.

class Map_Count


def initialize

for i in 1..999
@map_id=i
if @map_id <10
 @map_id="00#{i}"
end
 @exist=FileTest.exist?("Data/Map#{@map_id}.rxdata") 
if @exist
 $game_variables[1]=i
end

end

end

end

 

 

This is my class for retrieving the name of the map and storing it into an actor name.

 

class Getmapnames

attr_accessor :map_id
attr_accessor :map_name
attr_accessor :map_number


 def initialize(map_number)
   @map_id=map_number
   @map = load_data(sprintf("Data/Map%03d.rxdata", @map_id))
   map_name=@map.data.name
   @map_name=map_name
   return @map_name
 end

end




 

 

And this is my common event which is triggered when the switch "Init" is turned on.

Eventshot1.jpg

 

Now the problem I'm having is that it seems like you can only use $game_map.name as a call to the map the player is currently on.

Even if I try to load a DIFFERENT map file... and get the name for it, it doesn't work.

 

What I want to do is get the name of a map file before a player transfer event.

So here's my question.

 

How do I load a map, and get it's name, put the name in a variable and then close the map file, without changing the map the player is currently on??

The only thing I can think of is to do a sequenced transfer player, and store the map name of the current map into an array index with the same value as the loop number. :/

But that means I'd have to do that for EVERY map in the game and that would make the entire game slow at startup.

 

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

I think that script will not work.This one will do.

 

Instruction:

Insert this script above the Main.

There is only two easy thing u will need to edit. And that is...

 

1# See this one on the script? See on the spoiler below. Change the "Chip Location" To your specific window that will be straight and long and thin one, or that will fit your map name. If you don't have it, just click on this url and right click on the picture and save it. http://yfrog.com/5echiplocationp

 

Now, you have it. Don't forget to import this on the windowskins. And 1 more thing, if you rename the picture you just downloaded now, don't forget to type the name exactly like the same in the "Chip_Location". :)

 

 

 

# pictur loction must be on ( Windowskin )
   BackGroundImage = "Chip_Location"

 

 

If u don't get it, see this on the spoiler below.

 

 


If your picture name is something like "chaos".

# pictur loction must be on ( Windowskin )
   BackGroundImage = "chaos"

 

 

Ok, good to go?

2# if you want to change the invisblility of the window change the opacity of the window to 255.Like this

 

# Opacity of the Hud

Opacity = 255

 

Got it? Ok here's the script.

 

Script

 

 

 


#==============================================================================
# Map_Location
#------------------------------------------------------------------------------
# simple map loction ,iam typr note if you want to changr 
# by Hunter x
# v. 1.0
# http://www.rpgrevolution.com/
#==============================================================================
module LSRS


 module ScriptConfig_001

   # time for the hud hidden
   Timer = 150

   # pictur loction must be on ( Windowskin )
   BackGroundImage = "Chip_Location"

   # Position(3=down 9=up)
   Position = 9

   # Opacity of the Hud
   Opacity = 255

   # Position of the Font (0:Left 1:Midlle 2:right)
   LabelPosition = 1

   # Font Type and Color
   LabelFont = Font.new(["MS UI Gothic", "Tahoma", "Tahoma"])
   LabelFont.color = Color.new(0, 0, 0)
   #LabelFont.size = 22      #Size of the font
   #LabelFont.bold = false   # (true : bold, false :Normal)
   #LabelFont.italic = false # (true : italic, false :Normal)
 end
end

# Dont touch 
class LSRS::Sprite_Location < Sprite
 include LSRS::ScriptConfig_001
 @@cache = {}


 def initialize(text)
   super()
   RPG::Cache.windowskin(BackGroundImage).font = LabelFont
   self.z = 9996
   self.opacity = 0
   @count = 0
   @text = text
   refresh
   set_align
 end


 def update
   if @text != $game_map.map_name
     @text = $game_map.map_name
     refresh
   end
   if $game_system.map_interpreter.running?

     self.opacity -= 24

     @count = 0
   elsif @count.zero?
     self.opacity -= 12
   elsif self.opacity < Opacity
     self.opacity = [self.opacity += 12, Opacity].min
   else
     @count -= 1
   end
 end


 def refresh
   if @text.empty?

     self.visible = false
     return
   end
   if @@cache[@text]
     self.bitmap = @@cache[@text]
   else
     self.bitmap = RPG::Cache.windowskin(BackGroundImage).dup

     self.bitmap.draw_text(self.bitmap.rect, @text, LabelPosition)
     @@cache[@text] = self.bitmap
   end
   self.visible = true
   @count = Timer
 end


 def set_align
   self.x = case Position % 3
     when 1 then 0
     when 2 then 320 - self.width / 2
     else 640 - self.width
   end
   self.y = case Position
     when 1 .. 3 then 480 - self.height
     when 4 .. 6 then 240 - self.height / 2
     else 0
   end
 end


 def height
   self.bitmap ? self.bitmap.rect.height : 0
 end


 def width
   self.bitmap ? self.bitmap.rect.width : 0
 end
end


class Game_Map
 @@mapinfo = load_data("Data/MapInfos.rxdata")


 def map_name(id = @map_id)
   @@mapinfo[id].name.sub(/@.*/, "")
 end
end


class Scene_Map
 alias :main_lsrs1 :main
 alias :update_lsrs1 :update


 def main
   @location_sprite = LSRS::Sprite_Location.new($game_map.map_name)
   main_lsrs1
   @location_sprite.dispose
 end


 def update
   update_lsrs1
   @location_sprite.update
 end
end

 

 

Hope, ya all like it :)

 

And don't forget to tell me how to make the map name unpopping if you know :)

For someone who can not wait this unpopping map name, just erase the map name. :)

Edited by ChaosBlitz

Share this post


Link to post
Share on other sites
  • 0

If you want the number of maps you can use this snippet:

infos = load_data('data/mapinfos.rxdata')
$game_variables[1] = infos.size

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...