The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Scripting => Topic started by: Tsunokiette on February 06, 2006, 10:22:49 PM

Title: Floating Location Window
Post by: Tsunokiette on February 06, 2006, 10:22:49 PM
Do you want a window to pop up everytime you enter a new map area? Just insert this above main.

class Scene_Title
 #Dubealex Addition (from XRXS) to show Map Name on screen
$map_infos = load_data("Data/MapInfos.rxdata")
for key in $map_infos.keys
$map_infos[key] = $map_infos[key].name
end
end
class Game_Map
#Dubealex Addition (from XRXS) to show Map Name on screen
def name
$map_infos[@map_id]
end
end
class Window_Float_Location < Window_Base
  def initialize(location = '')
     super(0,416,232,64)
     self.contents = Bitmap.new(width - 32, height - 32)
     self.contents.font.name = 'Times New Roman'
     self.contents.font.size = 22
     self.opacity = 100
     self.back_opacity = 100
     @location = location
     @wait_count = 70
     show_location
  end
  def show_location
     self.contents.clear
     self.contents.font.color = normal_color
     w = self.contents.width
     h = self.contents.height
     self.contents.draw_text(0,0,w,h,@location,0)
     wait
  end
  def wait
    loop do
      self.update
      @wait_count -= 1
      if @wait_count == 0
        break
      end
    end
    self.dispose
  end
  def update
    Graphics.update
  end
end
class Scene_Map
 def transfer_player
   # Clear player place move call flag
   $game_temp.player_transferring = false
   # If move destination is different than current map
   if $game_map.map_id != $game_temp.player_new_map_id
     # Set up a new map
     $game_map.setup($game_temp.player_new_map_id)
   end
   # Set up player position
   $game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)
   # Set player direction
   case $game_temp.player_new_direction
   when 2  # down
     $game_player.turn_down
   when 4  # left
     $game_player.turn_left
   when 6  # right
     $game_player.turn_right
   when 8  # up
     $game_player.turn_up
   end
   # Straighten player position
   $game_player.straighten
   # Update map (run parallel process event)
   $game_map.update
   # Remake sprite set
   @spriteset.dispose
   @spriteset = Spriteset_Map.new
   # If processing transition
   if $game_temp.transition_processing
     # Clear transition processing flag
     $game_temp.transition_processing = false
     # Execute transition
     Graphics.transition(20)
   end
   location = $game_map.name
   float_location = Window_Float_Location.new(location)
   # Run automatic change for BGM and BGS set on the map
   $game_map.autoplay
   # Frame reset
   Graphics.frame_reset
   # Update input information
   Input.update
 end
end


Yes I realize the code itself isn't that pretty, but I'll clean it up later, it was a quick job.

BTW: credit to dubealex for the location name itself.
Title: Floating Location Window
Post by: Neko on February 06, 2006, 11:09:09 PM
Great script! but is there a way to make it so you can walk while it says the location?
Title: Floating Location Window
Post by: Neko on February 07, 2006, 02:18:43 AM
No answer? Seems kinda mean =\ (   Sorry for double post =[  )
Title: Floating Location Window
Post by: Tsunokiette on February 07, 2006, 03:02:45 AM
Quote from: NekoNo answer? Seems kinda mean =\ (   Sorry for double post =[  )

Well you happened to pick the 3 hours I was at karate -_- lol.

I'm working on that atm lol.

EDIT: well, I can, but as soon as you move anywhere, you go straight in that direction until the window goes away no matter what you press; which shouldn't be happening, so...
Title: Floating Location Window
Post by: Neko on February 07, 2006, 04:20:18 AM
Erm.. ummm.. can you not make it like a regular message window really? like have it auto bring up a message window?
Title: Floating Location Window
Post by: blueXx on February 07, 2006, 11:22:35 AM
Quote from: NekoErm.. ummm.. can you not make it like a regular message window really? like have it auto bring up a message window?

if you want that you don't need a script..
put a message button on each teleporter

something like:

teleport(new map)
-message: Welcome to place X

and then you can have all sorts of useless stuff in the message ~_~

tsu , nice script, though being stuck until it goes away is sort of not the way i like it ~_~
Title: Floating Location Window
Post by: Neko on February 07, 2006, 04:47:30 PM
ok, but is there a way to make it kinda transparent and on the bottom corse like that?
Title: Floating Location Window
Post by: blueXx on February 07, 2006, 05:18:41 PM
Quote from: Nekook, but is there a way to make it kinda transparent and on the bottom corse like that?

message display options button.
just don't show window and bottom

using slipknot's script or rm2k3 or rm2k you can even make the window go away after a certain period of time
Title: Floating Location Window
Post by: Tsunokiette on February 07, 2006, 10:52:37 PM
To reduce the ammount of time the window shows, just find this line -

@wait_count = 70

And make the number lower.
Title: Floating Location Window
Post by: blueXx on February 07, 2006, 10:54:19 PM
yar.. but any lower than that will make the map name hard to read
i actually want it a little bit longer but allowing the game to keep going with it could be really nice... >>
Title: Floating Location Window
Post by: Tsunokiette on February 14, 2006, 11:16:36 PM
Quote from: blueXxyar.. but any lower than that will make the map name hard to read
i actually want it a little bit longer but allowing the game to keep going with it could be really nice... >>

Got it... done... works...

(I kept forgetting to update the input, so here it is, and it also fades out now. I just forget to update the graphics sometimes.)

Here ya go.

class Scene_Title
 #Dubealex Addition (from XRXS) to show Map Name on screen
$map_infos = load_data("Data/MapInfos.rxdata")
for key in $map_infos.keys
$map_infos[key] = $map_infos[key].name
end
end
class Game_Map
#Dubealex Addition (from XRXS) to show Map Name on screen
def name
$map_infos[@map_id]
end
end
class Window_Float_Location < Window_Base
  def initialize(location = '')
     super(0,416,232,64)
     self.contents = Bitmap.new(width - 32, height - 32)
     self.contents.font.name = 'Times New Roman'
     self.contents.font.size = 22
     self.opacity = 200
     self.back_opacity = 200
     @location = location
     @wait_count = 200
     show_location
  end
  def show_location
     self.contents.clear
     self.contents.font.color = normal_color
     w = self.contents.width
     h = self.contents.height
     self.contents.draw_text(0,0,w,h,@location,0)
     wait
  end
  def wait
    loop do
      self.update
      $scene.update
      Input.update
      @wait_count -= 1
      if @wait_count == 0
        break
      end
    end
    for i in 1..40
      self.opacity -= 5
      self.back_opacity -= 5
      self.contents_opacity -= 5
      Graphics.update
      $scene.update
      Input.update
    end
    self.dispose
  end
  def update
    Graphics.update
  end
end class Scene_Map
 def transfer_player
   # Clear player place move call flag
   $game_temp.player_transferring = false
   # If move destination is different than current map
   if $game_map.map_id != $game_temp.player_new_map_id
     # Set up a new map
     $game_map.setup($game_temp.player_new_map_id)
   end
   # Set up player position
   $game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)
   # Set player direction
   case $game_temp.player_new_direction
   when 2  # down
     $game_player.turn_down
   when 4  # left
     $game_player.turn_left
   when 6  # right
     $game_player.turn_right
   when 8  # up
     $game_player.turn_up
   end
   # Straighten player position
   $game_player.straighten
   # Update map (run parallel process event)
   $game_map.update
   # Remake sprite set
   @spriteset.dispose
   @spriteset = Spriteset_Map.new
   # If processing transition
   if $game_temp.transition_processing
     # Clear transition processing flag
     $game_temp.transition_processing = false
     # Execute transition
     Graphics.transition(20)
   end
   location = $game_map.name
   float_location = Window_Float_Location.new(location)
   # Run automatic change for BGM and BGS set on the map
   $game_map.autoplay
   # Frame reset
   Graphics.frame_reset
   # Update input information
   Input.update
 end
end
Title: Floating Location Window
Post by: Neko on February 15, 2006, 12:23:25 AM
YOU ARE A GOD! lol This is perfect thank you
Title: Floating Location Window
Post by: blueXx on February 15, 2006, 11:04:02 AM
well done tsu
Title: Floating Location Window
Post by: dwarra on February 15, 2006, 05:15:56 PM
Nice scripts  :P

This could be very useful.

Does it work?
Title: Floating Location Window
Post by: Neko on February 15, 2006, 09:46:45 PM
It works great!!!I think I'm going to shorten the time that the window is up though.. its up for like 5 seconds or somthing but nobugs from what Ive seen so far =]
Title: Floating Location Window
Post by: Tsunokiette on February 15, 2006, 10:51:54 PM
Quote from: NekoIt works great!!!I think I'm going to shorten the time that the window is up though.. its up for like 5 seconds or somthing but nobugs from what Ive seen so far =]

*cough* there's only one, but it wont happen unless you go to a different map before the window goes away.

(it simply layers)
Title: Floating Location Window
Post by: Neko on February 15, 2006, 11:28:04 PM
Can you like put a line or two that erases it when changed???
Title: Floating Location Window
Post by: Blizzard on March 08, 2006, 01:35:50 PM
I found another bug. If you enter a map, the BGM of the new map won