Edited
My game started throwing up this error message
Script 'Part I' line 1809: TypeError occurred.
cannot convert nil into String
Here's the snippet of code that's at that line.
# draw shade
draw_text_shaded_later(x+1, y+1, w, h, text, a)
But I now know that it's not Tons of Addons doing it. It's another script I had that's doing it.
A Window Location script I had been using started causing the problem. I have all my maps set so they change and alter the variable required by the script when needed. I can't seem to figure it out.
#==============================================================================
# ** Window_Location
#------------------------------------------------------------------------------
# This window displays universe name and map name.
# Version 1.0
# Written by Sailerius
#
# Instructions: Define the constants below.
# You can make the location window visible/invisible by toggling the visibility switch.
# It will display the name of the current map.
# You can define what it says for each universe below.
#==============================================================================
class Window_Location < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
#--------------------------------------------------------------------------
# * Constants: Edit these values to customize
#--------------------------------------------------------------------------
$VISIBILITY_SWITCH = 2 # Enter the ID number of the switch used to determine window visibility
$WORLD_VAR = 38 # Enter the ID number of the variable used to determine current universe
#--------------------------------------------------------------------------
# * Values: Here, enter what you want the location window to display for each
# variable value. For example, for WORLD[1], enter what you want the universe
# section of the window to say when the variable is set to 1.
# Feel free to add more.
# NOTE: If you set the variable to a number not defined here, it'll probably crash.
#--------------------------------------------------------------------------
$WORLD=[]
$WORLD[0] = "???"
$WORLD[1] = "Abstinvidia"
$WORLD[2] = "Majeep"
$WORLD[3] = "Ashirka"
$WORLD[4] = "Icara"
$WORLD[5] = "Map of"
$WORLD[6] = "In Transit"
$WORLD[7] = "Rune Island"
$WORLD[8] = "Secreat Area"
$WORLD[9] = "Pleasent Shores"
$WORLD[10] = "Afterlife"
$WORLD[17] = "Fithavile"
$WORLD[18] = "Times Tower"
$WORLD[28] = "Squrril Woods"
$WORLD[29] = "Livindia"
$WORLD[37] = "Lion's Minning Settlement"
$WORLD[42] = "Mountian Shores"
$WORLD[58] = "Desert Sands"
$WORLD[61] = "Millington"
$WORLD[65] = "Icara Volcano"
$WORLD[80] = "Ferndale Isle"
$WORLD[82] = "Lost Sands"
#--------------------------------------------------------------------------
# Don't edit anything below here.
#--------------------------------------------------------------------------
super(0, 0, 160, 64) #96
self.z = 8000
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.size = 16
self.contents.font.bold = false
self.visible = $game_switches[$VISIBILITY_SWITCH]
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(5, -10, 120, 32, $WORLD[$game_variables[$WORLD_VAR]])
self.contents.font.color = normal_color
self.contents.draw_text(-13, 7, 120, 32, $game_map.name, 1)
end
end
#==========================================================================
# * Game_Map
#==========================================================================
class Game_Map
def name
$map_infos[@map_id]
end
end
#==========================================================================
# * Scene_Title
#==========================================================================
class Scene_Title
# Enables ability 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
#==========================================================================
# * Scene_Map
#==========================================================================
class Scene_Map
attr_accessor:location_window
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Make sprite set
@spriteset = Spriteset_Map.new
# Make message window
@message_window = Window_Message.new
# Make location window
@location_window = Window_Location.new
@location_window.x = 327
@location_window.y = 0
# Transition run
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of sprite set
@spriteset.dispose
# Dispose of message window
@message_window.dispose
# Dispose of location window
@location_window.dispose
# If switching to title screen
if $scene.is_a?(Scene_Title)
# Fade out screen
Graphics.transition
Graphics.freeze
end
end
#--------------------------------------------------------------------------
# * Player Place Move
#--------------------------------------------------------------------------
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)
@location_window.refresh
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
# 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
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Loop
loop do
# Update map, interpreter, and player order
# (this update order is important for when conditions are fulfilled
# to run any event, and the player isn't provided the opportunity to
# move in an instant)
$game_map.update
$game_system.map_interpreter.update
$game_player.update
# Update system (timer), screen
$game_system.update
$game_screen.update
# Abort loop if player isn't place moving
unless $game_temp.player_transferring
break
end
# Run place move
transfer_player
# Abort loop if transition processing
if $game_temp.transition_processing
break
end
end
# Update sprite set
@spriteset.update
# Update message window
@message_window.update
# Update location window
@location_window.update
# If game over
if $game_temp.gameover
# Switch to game over screen
$scene = Scene_Gameover.new
return
end
# If returning to title screen
if $game_temp.to_title
# Change to title screen
$scene = Scene_Title.new
return
end
# If transition processing
if $game_temp.transition_processing
# Clear transition processing flag
$game_temp.transition_processing = false
# Execute transition
if $game_temp.transition_name == ""
Graphics.transition(20)
else
Graphics.transition(40, "Graphics/Transitions/" +
$game_temp.transition_name)
end
end
# If showing message window
if $game_temp.message_window_showing
return
end
# If encounter list isn't empty, and encounter count is 0
if $game_player.encounter_count == 0 and $game_map.encounter_list != []
# If event is running or encounter is not forbidden
unless $game_system.map_interpreter.running? or
$game_system.encounter_disabled
# Confirm troop
n = rand($game_map.encounter_list.size)
troop_id = $game_map.encounter_list[n]
# If troop is valid
if $data_troops[troop_id] != nil
# Set battle calling flag
$game_temp.battle_calling = true
$game_temp.battle_troop_id = troop_id
$game_temp.battle_can_escape = true
$game_temp.battle_can_lose = false
$game_temp.battle_proc = nil
end
end
end
# If B button was pressed
if Input.trigger?(Input::B)
# If event is running, or menu is not forbidden
unless $game_system.map_interpreter.running? or
$game_system.menu_disabled
# Set menu calling flag or beep flag
$game_temp.menu_calling = true
$game_temp.menu_beep = true
end
end
# If debug mode is ON and F9 key was pressed
if $DEBUG and Input.press?(Input::F9)
# Set debug calling flag
$game_temp.debug_calling = true
end
# If player is not moving
unless $game_player.moving?
# Run calling of each screen
if $game_temp.battle_calling
call_battle
elsif $game_temp.shop_calling
call_shop
elsif $game_temp.name_calling
call_name
elsif $game_temp.menu_calling
call_menu
elsif $game_temp.save_calling
call_save
elsif $game_temp.debug_calling
call_debug
end
end
end
end
Also on a side note this script doesn't play well with Tons of Addons. It has to be place before ToA inorder to work. If it's placed after ToA then the HUD in ToA won't show. If at all posible I'd like for Window_Location and ToA to be 'friends'.
It's not Tons, but if you have Tons installed, this is the line it will point to. It happens when you use the "draw_text" method on something that equals nil. If you remove Tons, it will point to where the error is actually occurring.
Ok I'll remove it and see. Thanks for the tip.
Edit
Found the problem and edited the first post accordingly.
Thats because that script is written very poorly. It is about 5 times longer than it needs to be (probably more than that), and has a lot of technical errors. There is no need for a global variable of for the names, and if so, no need to reinitialize it every time the the window is made. The other globals are even more useless.
Anyways, the problem is probably stemming from the variable not being right. It controls the index of the $WORLD array, and if it is a value with no matching index in the array, the return value is "nil", and then you get your error.
Hmm. So I need to check all my maps to make sure they're setting the variable correctly. I can do that. On a side note (sorta) if you aren't busy, could you clean up the script for me. It not it's ok won't hurt my feelings.
Tons has one in it. have you tried that one yet?
Yeah it's a bit to simple for what I'd like for it to do. But nathmatt has just helped me with another script that'll take care of this one as far as each map properly setting the variable accordingly. The thing I like about this script that the one in Tons doesn't do, is it shows the name of the 'universe' or in my case the continent that you're on then the name of the town. So I'll mark this topic as solved. But if a scripter wants to clean up this script I'd still be thankful. << wasn't trying to drop a hint :P
lol didn't notice the solved i aliased all the methods so it will be more compatible with other scripts
#==============================================================================
# ** Window_Location
#------------------------------------------------------------------------------
# This window displays universe name and map name.
# Version 1.0
# Written by Sailerius
#
# Instructions: Define the constants below.
# You can make the location window visible/invisible by toggling the visibility switch.
# It will display the name of the current map.
# You can define what it says for each universe below.
#==============================================================================
class Window_Location < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
#--------------------------------------------------------------------------
# * Constants: Edit these values to customize
#--------------------------------------------------------------------------
$VISIBILITY_SWITCH = 2 # Enter the ID number of the switch used to determine window visibility
$WORLD_VAR = 38 # Enter the ID number of the variable used to determine current universe
#--------------------------------------------------------------------------
# * Values: Here, enter what you want the location window to display for each
# variable value. For example, for WORLD[1], enter what you want the universe
# section of the window to say when the variable is set to 1.
# Feel free to add more.
# NOTE: If you set the variable to a number not defined here, it'll probably crash.
#--------------------------------------------------------------------------
$WORLD=[]
$WORLD[0] = "???"
$WORLD[1] = "Abstinvidia"
$WORLD[2] = "Majeep"
$WORLD[3] = "Ashirka"
$WORLD[4] = "Icara"
$WORLD[5] = "Map of"
$WORLD[6] = "In Transit"
$WORLD[7] = "Rune Island"
$WORLD[8] = "Secreat Area"
$WORLD[9] = "Pleasent Shores"
$WORLD[10] = "Afterlife"
$WORLD[17] = "Fithavile"
$WORLD[18] = "Times Tower"
$WORLD[28] = "Squrril Woods"
$WORLD[29] = "Livindia"
$WORLD[37] = "Lion's Minning Settlement"
$WORLD[42] = "Mountian Shores"
$WORLD[58] = "Desert Sands"
$WORLD[61] = "Millington"
$WORLD[65] = "Icara Volcano"
$WORLD[80] = "Ferndale Isle"
$WORLD[82] = "Lost Sands"
#--------------------------------------------------------------------------
# Don't edit anything below here.
#--------------------------------------------------------------------------
super(0, 0, 160, 64) #96
self.z = 8000
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.size = 16
self.contents.font.bold = false
self.visible = $game_switches[$VISIBILITY_SWITCH]
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def update
super
return if self.visible == $game_switches[$VISIBILITY_SWITCH]
self.visible = $game_switches[$VISIBILITY_SWITCH]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(5, -10, 120, 32, $WORLD[$game_variables[$WORLD_VAR]])
self.contents.font.color = normal_color
self.contents.draw_text(-13, 7, 120, 32, $game_map.name, 1)
end
end
$map_infos = load_data("Data/MapInfos.rxdata")
#==========================================================================
# * Game_Map
#==========================================================================
class Game_Map
def name
return $map_infos[@map_id].name
end
end
#==========================================================================
# * Scene_Map
#==========================================================================
class Scene_Map
attr_accessor:location_window
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
alias location_window_main main
def main
@location_window = Window_Location.new
@location_window.x = 327
@location_window.y = 0
location_window_main
@location_window.dispose
end
#--------------------------------------------------------------------------
# * Player Place Move
#--------------------------------------------------------------------------
alias location_window_transfer_player transfer_player
def transfer_player
@location_window.refresh if $game_map.map_id != $game_temp.player_new_map_id
location_window_transfer_player
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias location_window_update update
def update
@location_window.update
location_window_update
end
end
I don't like the global variables being used, especially in this case where you can just attr them.
Global variables should be used as little as possible (http://c2.com/cgi/wiki?GlobalVariablesAreBad).
i wouldn't have set it up that way myself i would have made a
def map_name(id=0)
case id
when 0 then return map name
end
end
Quote from: nathmatt on August 03, 2011, 09:05:20 pm
lol didn't notice the solved i aliased all the methods so it will be more compatible with other scripts
#==============================================================================
# ** Window_Location
#------------------------------------------------------------------------------
# This window displays universe name and map name.
# Version 1.0
# Written by Sailerius
#
# Instructions: Define the constants below.
# You can make the location window visible/invisible by toggling the visibility switch.
# It will display the name of the current map.
# You can define what it says for each universe below.
#==============================================================================
class Window_Location < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
#--------------------------------------------------------------------------
# * Constants: Edit these values to customize
#--------------------------------------------------------------------------
$VISIBILITY_SWITCH = 2 # Enter the ID number of the switch used to determine window visibility
$WORLD_VAR = 38 # Enter the ID number of the variable used to determine current universe
#--------------------------------------------------------------------------
# * Values: Here, enter what you want the location window to display for each
# variable value. For example, for WORLD[1], enter what you want the universe
# section of the window to say when the variable is set to 1.
# Feel free to add more.
# NOTE: If you set the variable to a number not defined here, it'll probably crash.
#--------------------------------------------------------------------------
$WORLD=[]
$WORLD[0] = "???"
$WORLD[1] = "Abstinvidia"
$WORLD[2] = "Majeep"
$WORLD[3] = "Ashirka"
$WORLD[4] = "Icara"
$WORLD[5] = "Map of"
$WORLD[6] = "In Transit"
$WORLD[7] = "Rune Island"
$WORLD[8] = "Secreat Area"
$WORLD[9] = "Pleasent Shores"
$WORLD[10] = "Afterlife"
$WORLD[17] = "Fithavile"
$WORLD[18] = "Times Tower"
$WORLD[28] = "Squrril Woods"
$WORLD[29] = "Livindia"
$WORLD[37] = "Lion's Minning Settlement"
$WORLD[42] = "Mountian Shores"
$WORLD[58] = "Desert Sands"
$WORLD[61] = "Millington"
$WORLD[65] = "Icara Volcano"
$WORLD[80] = "Ferndale Isle"
$WORLD[82] = "Lost Sands"
#--------------------------------------------------------------------------
# Don't edit anything below here.
#--------------------------------------------------------------------------
super(0, 0, 160, 64) #96
self.z = 8000
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.size = 16
self.contents.font.bold = false
self.visible = $game_switches[$VISIBILITY_SWITCH]
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def update
super
return if self.visible == $game_switches[$VISIBILITY_SWITCH]
self.visible = $game_switches[$VISIBILITY_SWITCH]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(5, -10, 120, 32, $WORLD[$game_variables[$WORLD_VAR]])
self.contents.font.color = normal_color
self.contents.draw_text(-13, 7, 120, 32, $game_map.name, 1)
end
end
$map_infos = load_data("Data/MapInfos.rxdata")
#==========================================================================
# * Game_Map
#==========================================================================
class Game_Map
def name
return $map_infos[@map_id].name
end
end
#==========================================================================
# * Scene_Map
#==========================================================================
class Scene_Map
attr_accessor:location_window
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
alias location_window_main main
def main
@location_window = Window_Location.new
@location_window.x = 327
@location_window.y = 0
location_window_main
@location_window.dispose
end
#--------------------------------------------------------------------------
# * Player Place Move
#--------------------------------------------------------------------------
alias location_window_transfer_player transfer_player
def transfer_player
@location_window.refresh if $game_map.map_id != $game_temp.player_new_map_id
location_window_transfer_player
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias location_window_update update
def update
@location_window.update
location_window_update
end
end
You are simply awesome in my book nathmatt!. Thank you for making this script more compatible with other scripts.
Here's the script without a single global variable. It also eliminates the coding mistake of re-initializing the $WORLD variable every time the window is created. You will also not get errors for not having if the variable is set wrong, it will just display a "????". I also eliminated all the double quotes and replaced them with single quotes, which are slightly more efficient in these circumstances.
#==============================================================================
# ** Window_Location
#------------------------------------------------------------------------------
# This window displays universe name and map name.
# Version 1.0
# Written by Sailerius
#
# Instructions: Define the constants below.
# You can make the location window visible/invisible by toggling the visibility switch.
# It will display the name of the current map.
# You can define what it says for each universe below.
#==============================================================================
class Window_Location < Window_Base
VISIBILITY_SWITCH = 2 # Enter the ID number of the switch used to determine window visibility
WORLD_VAR = 38 # Enter the ID number of the variable used to determine current universe
def world_name(variable_id)
return case variable_id
when 1 then 'Abstinvidia'
when 2 then 'Majeep'
when 3 then 'Ashirka'
when 4 then 'Icara'
when 5 then 'Map of'
when 6 then 'In Transit'
when 7 then 'Rune Island'
when 8 then 'Secreat Area'
when 9 then 'Pleasent Shores'
when 10 then 'Afterlife'
when 17 then 'Fithavile'
when 18 then 'Times Tower'
when 28 then 'Squrril Woods'
when 29 then 'Livindia'
when 37 then 'Lion\'s Minning Settlement'
when 42 then 'Mountian Shores'
when 58 then 'Desert Sands'
when 61 then 'Millington'
when 65 then 'Icara Volcano'
when 80 then 'Ferndale Isle'
when 82 then 'Lost Sands'
else
'???'
end
end
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 64) #96
self.z = 8000
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.size = 16
self.contents.font.bold = false
self.visible = $game_switches[VISIBILITY_SWITCH]
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def update
super
if self.visible == $game_switches[VISIBILITY_SWITCH]
self.visible = $game_switches[VISIBILITY_SWITCH]
end
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(5, -10, 120, 32, world_name($game_variables[WORLD_VAR]))
self.contents.font.color = normal_color
self.contents.draw_text(-13, 7, 120, 32, $game_map.name, 1)
end
end
#==========================================================================
# * Game_Map
#==========================================================================
class Game_Map
alias zer0_map_names_init initialize
def initialize
@names = []
load_data('Data/MapInfos.rxdata').each_pair {|k, v| @names[k] = v.name }
zer0_map_names_init
end
def name
return @names[@map_id]
end
end
#==========================================================================
# * Scene_Map
#==========================================================================
class Scene_Map
attr_accessor:location_window
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
alias location_window_main main
def main
@location_window = Window_Location.new
@location_window.x = 327
@location_window.y = 0
location_window_main
@location_window.dispose
end
#--------------------------------------------------------------------------
# * Player Place Move
#--------------------------------------------------------------------------
alias location_window_transfer_player transfer_player
def transfer_player
@location_window.refresh if $game_map.map_id != $game_temp.player_new_map_id
location_window_transfer_player
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias location_window_update update
def update
@location_window.update
location_window_update
end
end
Much better, Zer0. I can sleep tonight now knowing that this person's game will have one less global variable.
Quote from: ForeverZer0 on August 04, 2011, 06:01:03 pm
Here's the script without a single global variable. It also eliminates the coding mistake of re-initializing the $WORLD variable every time the window is created. You will also not get errors for not having if the variable is set wrong, it will just display a "????". I also eliminated all the double quotes and replaced them with single quotes, which are slightly more efficient in these circumstances.
#==============================================================================
# ** Window_Location
#------------------------------------------------------------------------------
# This window displays universe name and map name.
# Version 1.0
# Written by Sailerius
#
# Instructions: Define the constants below.
# You can make the location window visible/invisible by toggling the visibility switch.
# It will display the name of the current map.
# You can define what it says for each universe below.
#==============================================================================
class Window_Location < Window_Base
VISIBILITY_SWITCH = 2 # Enter the ID number of the switch used to determine window visibility
WORLD_VAR = 38 # Enter the ID number of the variable used to determine current universe
def world_name(variable_id)
return case variable_id
when 1 then 'Abstinvidia'
when 2 then 'Majeep'
when 3 then 'Ashirka'
when 4 then 'Icara'
when 5 then 'Map of'
when 6 then 'In Transit'
when 7 then 'Rune Island'
when 8 then 'Secreat Area'
when 9 then 'Pleasent Shores'
when 10 then 'Afterlife'
when 17 then 'Fithavile'
when 18 then 'Times Tower'
when 28 then 'Squrril Woods'
when 29 then 'Livindia'
when 37 then 'Lion\'s Minning Settlement'
when 42 then 'Mountian Shores'
when 58 then 'Desert Sands'
when 61 then 'Millington'
when 65 then 'Icara Volcano'
when 80 then 'Ferndale Isle'
when 82 then 'Lost Sands'
else
'???'
end
end
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 64) #96
self.z = 8000
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.size = 16
self.contents.font.bold = false
self.visible = $game_switches[VISIBILITY_SWITCH]
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def update
super
if self.visible == $game_switches[VISIBILITY_SWITCH]
self.visible = $game_switches[VISIBILITY_SWITCH]
end
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(5, -10, 120, 32, world_name($game_variables[WORLD_VAR]))
self.contents.font.color = normal_color
self.contents.draw_text(-13, 7, 120, 32, $game_map.name, 1)
end
end
#==========================================================================
# * Game_Map
#==========================================================================
class Game_Map
alias zer0_map_names_init initialize
def initialize
@names = []
load_data('Data/MapInfos.rxdata').each_pair {|k, v| @names[k] = v.name }
zer0_map_names_init
end
def name
return @names[@map_id]
end
end
#==========================================================================
# * Scene_Map
#==========================================================================
class Scene_Map
attr_accessor:location_window
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
alias location_window_main main
def main
@location_window = Window_Location.new
@location_window.x = 327
@location_window.y = 0
location_window_main
@location_window.dispose
end
#--------------------------------------------------------------------------
# * Player Place Move
#--------------------------------------------------------------------------
alias location_window_transfer_player transfer_player
def transfer_player
@location_window.refresh if $game_map.map_id != $game_temp.player_new_map_id
location_window_transfer_player
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias location_window_update update
def update
@location_window.update
location_window_update
end
end
Thanks everyone for your help with this. I'm very greatful at the work both nathmatt and Foreverzer0 have put into this script for me. Just one thing I've noticed now. When switching maps, the map name (not the continent name) doesn't refresh to the new map name. But other then that thanks for the help. :). I've picked up learning some ruby with the program Hackety Hack and even though I'm not yet at the level to write my own scripts for RMXP it is helping me read and understand other scripts and see how they work. Thanks for explaining why doing things certain ways are better also.
here i should have done it that way in the first place
#==============================================================================
# ** Window_Location
#------------------------------------------------------------------------------
# This window displays universe name and map name.
# Version 1.0
# Written by Sailerius
#
# Instructions: Define the constants below.
# You can make the location window visible/invisible by toggling the visibility switch.
# It will display the name of the current map.
# You can define what it says for each universe below.
#==============================================================================
class Window_Location < Window_Base
VISIBILITY_SWITCH = 2 # Enter the ID number of the switch used to determine window visibility
WORLD_VAR = 38 # Enter the ID number of the variable used to determine current universe
def world_name(variable_id)
return case variable_id
when 1 then 'Abstinvidia'
when 2 then 'Majeep'
when 3 then 'Ashirka'
when 4 then 'Icara'
when 5 then 'Map of'
when 6 then 'In Transit'
when 7 then 'Rune Island'
when 8 then 'Secreat Area'
when 9 then 'Pleasent Shores'
when 10 then 'Afterlife'
when 17 then 'Fithavile'
when 18 then 'Times Tower'
when 28 then 'Squrril Woods'
when 29 then 'Livindia'
when 37 then 'Lion\'s Minning Settlement'
when 42 then 'Mountian Shores'
when 58 then 'Desert Sands'
when 61 then 'Millington'
when 65 then 'Icara Volcano'
when 80 then 'Ferndale Isle'
when 82 then 'Lost Sands'
else
'???'
end
end
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 64) #96
self.z = 8000
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.size = 16
self.contents.font.bold = false
self.visible = $game_switches[VISIBILITY_SWITCH]
@map_id = $game_map.map_id
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def update
super
if self.visible == $game_switches[VISIBILITY_SWITCH]
self.visible = $game_switches[VISIBILITY_SWITCH]
end
if @map_id != $game_map.map_id
@map_id = $game_map.map_id
refresh
end
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(5, -10, 120, 32, world_name($game_variables[WORLD_VAR]))
self.contents.font.color = normal_color
self.contents.draw_text(-13, 7, 120, 32, $game_map.name, 1)
end
end
#==========================================================================
# * Game_Map
#==========================================================================
class Game_Map
alias zer0_map_names_init initialize
def initialize
@names = []
load_data('Data/MapInfos.rxdata').each_pair {|k, v| @names[k] = v.name }
zer0_map_names_init
end
def name
return @names[@map_id]
end
end
#==========================================================================
# * Scene_Map
#==========================================================================
class Scene_Map
attr_accessor:location_window
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
alias location_window_main main
def main
@location_window = Window_Location.new
@location_window.x = 327
@location_window.y = 0
location_window_main
@location_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias location_window_update update
def update
@location_window.update
location_window_update
end
end
That did the trick, thank you again nathmatt :up:.