#last updated 3/6/2012
#credits to diagostimo
#comercial use prohibited
#-------------#
#beging config#
#-------------#
module Config
#notes when using this system:
#when making your background bear in mind that the window has an offset of 16
#pixles on all sides, this means that when the grids x and y are both 0 then
#they are actually 16 so always draw an image with a bordeline of 16 on all
#sides so it meets up with the grid properly
#also when setting the variable that controls the cursor position on the map,
#if you set it higher than the maximum index value of the map it will return
#0 when calling the scene.
#if you change the default grid settings then you will need to count how many
#index squares are on your grid, you can still use the index reference image as
#a reference, just note that it starts at 0 and increases linear
#setup how many grid squares wide and high the map is, the example used here
#gives it a width of 19 and a height of 14 in grid squares, this setup makes
#each square 32 by 32 pixles, say we double these values, so the width is 38
#and the height is 28, this will make each grid square 16 by 16 pixles comprende!
X_GRID = 19
Y_GRID = 14
# note if your grid is large then giving it an offset will make it go off screen
#this is intended for smaller grids
GRIDX_OFFSET = 0
GRIDY_OFFSET = 0
#this sets the total width for your grid, note the max width it can go is 608
#and the max height is 448, if you do set it higher then your map will simply go
#off the screen, your grid squares pixle size is also divided by these
#numbers, so say you set it to be 5 grid squares wide and the grid width is 608
#then a grid squares width is roughly 121, this is so you can make smaller grids
GRID_WIDTH = 608
GRID_HEIGHT = 448
#IMPORT ALL YOUR IMAGES TO THE PICTURES DIRECTORY!
#your main map's image name
MAP_NAME = 'map.png'
#here you can complete configure the text show when the cursor is at differnt
#locations on the map
#config whether you wish to use custom font, true or false
CUSTOM_FONT = false
#configure the name of the custom font
TEXT_FONT = 'Georgia'
#configure whether you wish to manually set the color of the text, true or false
CUSTOM_COLOR = true #when false default is white
# set the color of the text like so: [RED, GREEN, BLUE]min=0 max=255
SET_COLOR = [0, 0, 0]
#configure whether the text writen will be bold or not, true or false
BOLD_TEXT = true
#set the fonts size
FONT_SIZE = 25 #maximum size = 96
#set if you would like to use outlined text
OUTLINED_TEXT = true
#set if you would like to customize the color of the outline
OUTLINED_COLOR = true #when false default is black
# set the color of the outline: [red, green, blue]min=0 max=255
OUTLINED_COLOR_SET = [255, 255, 255]
#set to true to draw a box behind the text
TEXT_BACK = true
#set the color and opacity of the box
TEXT_BACK_COLOR = [255, 0, 0, 150]#[red, green, blue, opacity]
#set to true to give the box a border, only returns if back box = true
TEXT_BACK_BORDER = true #not functional
#set the color and opacity of the border
TEXT_BACK_BORDER_COLOR = [0, 0, 255, 255]#[red, green, blue, opacity]
#set to true to give the box a border
TEXT_BACK_BORDER = true #not functional
#set up the names that will be shown when the cursor is over locations,
#when 193 points at the index point of the map, refer to the index refernece
#image, config like so: when INDEX ID then [x, y , "TEXT"]
#just simply add a new line to configure a new location
#for index's not configured it will not return any text
def self.map_text(index)
return case index
when 193 then [6, 6, 'example text']
when 174 then [50, 50, 'example2 text']
#leave else, this returns no text if none is set
else ''
end
end
#here you configure the window that will show an image of the town you press
#the action button on
#define the windows [x, y, width, height] for your town images ect
WINDOW_SIZE = [112, 64, 416, 352]
#define the opacity of your towns windows(this does not effect the images)
#255=max, 0=min
WINDOW_OPACITY = 255
#configure the maps name that will be shown in the window, configure
#it exactly how you configured the text above, the index is set the same, it
#will show the text for the index point it is called from
def self.window_text(index)
return case index
when 193 then [30, 30, "example text"]
when 174 then [80, 50, "example text"]
#leave else, this returns no text if none is set
else ''
end
end
#config whether you wish to use custom font, true or false
W_CUSTOM_FONT = false
#configure the name of the custom font
W_TEXT_FONT = 'Georgia'
#configure whether you wish to manually set the color of the text, true or false
W_CUSTOM_COLOR = true #when false default is white
# set the color of the text like so: [RED, GREEN, BLUE]min=0 max=255
W_SET_COLOR = [0, 0, 0]
#configure whether the text writen will be bold or not, true or false
W_BOLD_TEXT = true
#set the fonts size
W_FONT_SIZE = 20 #maximum size = 96
#set if you would like to use outlined text
W_OUTLINED_TEXT = true
#set if you would like to customize the color of the outline
W_OUTLINED_COLOR = true #when false default is black
# set the color of the outline: [red, green, blue]min=0 max=255
W_OUTLINED_COLOR_SET = [255, 255, 255]
#set to true to draw a box behind the text
W_TEXT_BACK = true
#set the color and opacity of the box
W_TEXT_BACK_COLOR = [0, 0, 255, 100]#[red, green, blue, opacity]
#set to true to give the box a border, only returns if back box = true
W_TEXT_BACK_BORDER = true #not functional
#set the color and opacity of the border
W_TEXT_BACK_BORDER_COLOR = [255, 0, 0, 255]#[red, green, blue, opacity]
#to add a new image for an index point simply add a new line with the image's
#name E.G you want to add a image for index 0 you would add this:
#when 0 then 'IMAGE_NAME'
#where IMAGE_NAME is the name of the image to show, use the index reference
#image in the projects root folder for a reference of how the index is set-up
def self.image_name(index)
return case index
when 193 then 'pallettown.png'
when 174 then 'pallettown.png'
#leave else, this returns no window if no image is set
else ''
end
end
#set the [x, y, opacity] of the images, opacity max=255 min=0
IMAGE_XY = [0, 0, 255]
#set if tele window is enabled
#when the tele window is enabled a pre menu comes up before the map, asking if
#you wish to teleport or view location information
TELE_WINDOW = true
#below is the teleport setup, there are also script calls you can use to manipulate the
#teleport menu, here is a list of them:
#$game_system.tele_disabled = true #disables the teleport menu selection
#$game_system.tele_disabled = false #enables the teleport menu selection
#the following calls are used to disable individual locations:
#$game_system.telearray.push(193)
#the above disables teleporting to index 193 if it has a teleport method setup
#$game_system.telearray.delete(193)
#the above removes index 193 from the list of disabled locations
#end of script calls#
#setup teleport locations for index points: when INDEX then [id, x, y, direction]
#drections: 0 = retain, 2 = down, 4 = left, 6 = right, 8 = up
def self.tele_config(index)
return case index
when 155 then [3, 9, 7, 0]
when 174 then [2, 9, 7, 0]
when 193 then [1, 9, 7, 0]
#leave else, this disables teleporting at index's unasigned
else ''
end
end
#set if a custom sound should be played when teleporting
TELE_SOUND = true
#set the name of the sound file/this must be in the SE directory
#you may need to add the file extension depending on the format of the
#sound, i.e .mp3
TELE_NAME = '020-Teleport03'
end
#----------#
#END CONFIG#
#----------#
#==============================================================================
# * game system teleporting addons
#==============================================================================
class Game_System
attr_accessor :tele_disabled #tele menu disable
attr_accessor :telearray #tele array to disable individual tele's
alias teleinit initialize
def initialize
teleinit
@tele_disabled = false
@telearray = []
end
end
#==============================================================================
# Bitmap Addon (Outlined Text)
#==============================================================================
class Bitmap
#----------------------------------------------------------------------------
# draw_text_full
# x2 - x coordinate or rectangle
# y2 - y coordinate or text
# w2 - width or align
# h2 - height
# text2 - the text to be drawn
# a2 - align
# Draws outlines text.
#----------------------------------------------------------------------------
def draw_text_full(x2, y2, w2 = 0, h2 = 0, text2 = '', a2 = 0)
# set coordinates whether x2 is rectangle
if x2.is_a?(Rect)
x, y, w, h, text, a = x2.x, x2.y, x2.width, x2.height, y2, w2
else
x, y, w, h, text, a = x2, y2, w2, h2, text2, a2
end
# store font color
save_color = self.font.color.clone
# set font color to black
if Config::OUTLINED_COLOR == true
rgb = Config::OUTLINED_COLOR_SET
self.font.color = Color.new(rgb[0], rgb[1], rgb[2])
else
self.font.color = Color.new(0, 0, 0)
end
# draw outline
draw_text(x+1, y, w, h, text, a)
draw_text(x-1, y, w, h, text, a)
draw_text(x, y+1, w, h, text, a)
draw_text(x, y-1, w, h, text, a)
draw_text(x+1, y+1, w, h, text, a)
draw_text(x-1, y+1, w, h, text, a)
draw_text(x-1, y-1, w, h, text, a)
draw_text(x+1, y-1, w, h, text, a)
# restore font color
self.font.color = save_color
# draw normal text
draw_text(x, y, w, h, text, a)
end
end
#============================================================================
# ** Window_Map
#----------------------------------------------------------------------------
class Window_MapMenu < Window_Base
attr_reader :index
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
end
#-------------------------------------------------------------------------
# * def index
#-------------------------------------------------------------------------
def index=(index)
@index = index
# Update cursor rectangle
update_cursor_rect
refresh
end
#-------------------------------------------------------------------------
# * def refresh
#-------------------------------------------------------------------------
def refresh
ctext = Config.map_text(@index) # a will be our temporary array
if ctext == ''
self.contents.clear
else
self.contents.clear
if Config::CUSTOM_FONT == true
self.contents.font.name = Config::TEXT_FONT
end
if Config::CUSTOM_COLOR == true
rgb = Config::SET_COLOR
self.contents.font.color = Color.new(rgb[0], rgb[1], rgb[2])
end
if Config::BOLD_TEXT == true
self.contents.font.bold = true
end
size = Config::FONT_SIZE
self.contents.font.size = (size)
cx = contents.text_size(ctext[2]).width
tx = contents.text_size(ctext[2]).height
if Config::TEXT_BACK == true
if Config::TEXT_BACK_BORDER == true
rect = self.contents.text_size(ctext[2])
bc = Config::TEXT_BACK_BORDER_COLOR
#border right
highlight_rect = Rect.new(rect.x, rect.y, 2, rect.height + 8)
bitmap = Bitmap.new(highlight_rect.width, highlight_rect.height)
bitmap.fill_rect(highlight_rect.x, highlight_rect.y, highlight_rect.width, highlight_rect.height, Color.new(bc[0], bc[1], bc[2], bc[3]))
self.contents.blt(ctext[0] + rect.width + 4, ctext[1] - 4, bitmap, highlight_rect)
#border left
highlight_rect = Rect.new(rect.x, rect.y, 2, rect.height + 8)
bitmap = Bitmap.new(highlight_rect.width, highlight_rect.height)
bitmap.fill_rect(highlight_rect.x, highlight_rect.y, highlight_rect.width, highlight_rect.height, Color.new(bc[0], bc[1], bc[2], bc[3]))
self.contents.blt(ctext[0] - 6, ctext[1] - 4, bitmap, highlight_rect)
#border bottom
highlight_rect = Rect.new(rect.x, rect.y, rect.width + 12, 2)
bitmap = Bitmap.new(highlight_rect.width, highlight_rect.height)
bitmap.fill_rect(highlight_rect.x, highlight_rect.y, highlight_rect.width, highlight_rect.height, Color.new(bc[0], bc[1], bc[2], bc[3]))
self.contents.blt(ctext[0] - 6, ctext[1] + rect.height + 4, bitmap, highlight_rect)
#border top
highlight_rect = Rect.new(rect.x, rect.y, rect.width + 12, 2)
bitmap = Bitmap.new(highlight_rect.width, highlight_rect.height)
bitmap.fill_rect(highlight_rect.x, highlight_rect.y, highlight_rect.width, highlight_rect.height, Color.new(bc[0], bc[1], bc[2], bc[3]))
self.contents.blt(ctext[0] - 6, ctext[1] - 6, bitmap, highlight_rect)
#draw back box
bc = Config::TEXT_BACK_COLOR
highlight_rect = Rect.new(rect.x, rect.y, rect.width + 8, rect.height + 8)
bitmap = Bitmap.new(highlight_rect.width, highlight_rect.height)
bitmap.fill_rect(highlight_rect.x, highlight_rect.y, highlight_rect.width, highlight_rect.height, Color.new(bc[0], bc[1], bc[2], bc[3]))
self.contents.blt(ctext[0] - 4, ctext[1] - 4, bitmap, highlight_rect)
else
#draw back box
bc = Config::TEXT_BACK_COLOR
rect = self.contents.text_size(ctext[2])
highlight_rect = Rect.new(rect.x - 8, rect.y - 4, rect.width + 24, rect.height + 12)
bitmap = Bitmap.new(highlight_rect.width, highlight_rect.height)
bitmap.fill_rect(highlight_rect.x, highlight_rect.y, highlight_rect.width, highlight_rect.height, Color.new(bc[0], bc[1], bc[2], bc[3]))
self.contents.blt(ctext[0] - 16, ctext[1] - 8, bitmap, highlight_rect)
end
end
if Config::OUTLINED_TEXT == true
self.contents.draw_text_full(ctext[0], ctext[1], cx, tx, ctext[2])
else
self.contents.draw_text(ctext[0], ctext[1], cx, tx, ctext[2])
end
if Config::BOLD_TEXT == true
self.contents.font.bold = false
end
end
end
#--------------------------------------------------------------------------
# * Cursor Rectangle Update
#--------------------------------------------------------------------------
def update_cursor_rect
gswidth = Config::GRID_WIDTH / Config::X_GRID
gsheight = Config::GRID_HEIGHT / Config::Y_GRID
x = Config::GRIDX_OFFSET + @index % Config::X_GRID * gswidth
y = Config::GRIDX_OFFSET + @index / Config::X_GRID % Config::Y_GRID * gsheight
self.cursor_rect.set(x, y, gswidth, gsheight)
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
telearray = []
# if enter is being pressed
if Input.trigger?(Input::C)
if Config::TELE_WINDOW == true
tele = Config.tele_config(@index)
if $tele == 0
if tele == ''
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
else
if $game_system.telearray.include?(@index)
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
else
# Play decision SE
$game_system.se_play($data_system.decision_se)
#transfering is happening
$scene = Scene_Map.new
$game_temp.player_transferring = true
# Set player move destination
i = tele[0]
x = tele[1]
y = tele[2]
d = tele[3]
$game_temp.player_new_map_id = i
$game_temp.player_new_x = x
$game_temp.player_new_y = y
$game_temp.player_new_direction = d
# Prepare for transition
Graphics.freeze
# Set transition processing flag
#$game_temp.transition_processing = true
#$game_temp.transition_name = ""
Graphics.transition(20)
if Config::TELE_SOUND == true
# Play decision SE
Audio.se_play("Audio/SE/" + Config::TELE_NAME, 100, 100)
end
return false
end
end
else
name = Config.image_name(@index)
if name == ''
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
else
#Play decision SE
$game_system.se_play($data_system.decision_se)
$scene = Scene_Index.new(@index)
end
end
else
name = Config.image_name(@index)
if name == ''
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
else
#Play decision SE
$game_system.se_play($data_system.decision_se)
$scene = Scene_Index.new(@index)
end
end
end
# If right directional button is pushed
if Input.repeat?(Input::RIGHT)
# If directional button pressed down is not a repeat, or
# cursor is not positioned on the right edge
if Input.trigger?(Input::RIGHT) or
@index % Config::X_GRID < Config::X_GRID-1
# Move cursor to right
$game_system.se_play($data_system.cursor_se)
if @index % Config::X_GRID < Config::X_GRID-1
self.index += 1
end
end
# If left directional button is pushed
elsif Input.repeat?(Input::LEFT)
# If directional button pressed down is not a repeat, or
# cursor is not positioned on the left edge
if Input.trigger?(Input::LEFT) or
@index % Config::X_GRID > 0
# Move cursor to left
$game_system.se_play($data_system.cursor_se)
if @index % Config::X_GRID > 0
self.index -= 1
end
end
# If down directional button is pushed
elsif Input.repeat?(Input::DOWN)
# Move cursor down
if @index / Config::X_GRID < Config::Y_GRID-1
self.index += Config::X_GRID
$game_system.se_play($data_system.cursor_se)
end
# If up directional button is pushed
elsif Input.repeat?(Input::UP)
# Move cursor up
if @index / Config::X_GRID > 0
self.index -= Config::X_GRID
$game_system.se_play($data_system.cursor_se)
end
end
update_cursor_rect
end
end
#---------------------------------------------------------------------------
# * Scene Map_Menu
#---------------------------------------------------------------------------
class Scene_MapMenu
def initialize(index)
@index = index
end
#-------------------------------------------------------------------------
# * MAIN
#-------------------------------------------------------------------------
def main
#calculate the index value of the map
ival = Config::X_GRID * Config::Y_GRID - 1
#sets @index to 0 if it is greater than the value
if @index > ival
@index = 0
end
#creates the map window
@mapmenu_window = Window_MapMenu.new
#windows index = @index
@mapmenu_window.index = @index
#new sprite (background)
@sprite = Sprite.new
#set sprite image
@sprite.bitmap = RPG::Cache.picture(Config::MAP_NAME)
# Execute transition
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 windows
@mapmenu_window.dispose
@sprite.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@mapmenu_window.update
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to Menu screen
if $tele == 0
$scene = Scene_Tele.new(0)
else
$scene = Scene_Tele.new(1)
end
return
end
end
end
#===========================================================================
# * class Window_Index
#---------------------------------------------------------------------------
class Window_Index < Window_Base
#-------------------------------------------------------------------------
# * Object Initialization
#-------------------------------------------------------------------------
def initialize(index)
super(*Config::WINDOW_SIZE)
wtext = Config.window_text(index)
@wtext = wtext
self.contents = Bitmap.new(width - 32, height - 32)
@bitmap = RPG::Cache.picture(Config.image_name(index))
self.opacity = Config::WINDOW_OPACITY
refresh
end
#-------------------------------------------------------------------------
# * refresh
#-------------------------------------------------------------------------
def refresh
xy = Config::IMAGE_XY
if @wtext == ''
self.contents.clear
self.contents.blt(xy[0], xy[1], @bitmap, Rect.new(0, 0, @bitmap.width, @bitmap.height), xy[2])
else
self.contents.clear
self.contents.blt(xy[0], xy[1], @bitmap, Rect.new(0, 0, @bitmap.width, @bitmap.height), xy[2])
if Config::W_CUSTOM_FONT == true
self.contents.font.name = Config::W_TEXT_FONT
end
if Config::W_CUSTOM_COLOR == true
rgb = Config::W_SET_COLOR
self.contents.font.color = Color.new(rgb[0], rgb[1], rgb[2])
end
if Config::W_BOLD_TEXT == true
self.contents.font.bold = true
end
self.contents.font.size = Config::W_FONT_SIZE
cx = contents.text_size(@wtext[2]).width
tx = contents.text_size(@wtext[2]).height
if Config::W_TEXT_BACK == true
if Config::W_TEXT_BACK_BORDER == true
rect = self.contents.text_size(@wtext[2])
bc = Config::W_TEXT_BACK_BORDER_COLOR
#border right
highlight_rect = Rect.new(rect.x, rect.y, 2, rect.height + 8)
bitmap = Bitmap.new(highlight_rect.width, highlight_rect.height)
bitmap.fill_rect(highlight_rect.x, highlight_rect.y, highlight_rect.width, highlight_rect.height, Color.new(bc[0], bc[1], bc[2], bc[3]))
self.contents.blt(@wtext[0] + rect.width + 4, @wtext[1] - 4, bitmap, highlight_rect)
#border left
highlight_rect = Rect.new(rect.x, rect.y, 2, rect.height + 8)
bitmap = Bitmap.new(highlight_rect.width, highlight_rect.height)
bitmap.fill_rect(highlight_rect.x, highlight_rect.y, highlight_rect.width, highlight_rect.height, Color.new(bc[0], bc[1], bc[2], bc[3]))
self.contents.blt(@wtext[0] - 6, @wtext[1] - 4, bitmap, highlight_rect)
#border bottom
highlight_rect = Rect.new(rect.x, rect.y, rect.width + 12, 2)
bitmap = Bitmap.new(highlight_rect.width, highlight_rect.height)
bitmap.fill_rect(highlight_rect.x, highlight_rect.y, highlight_rect.width, highlight_rect.height, Color.new(bc[0], bc[1], bc[2], bc[3]))
self.contents.blt(@wtext[0] - 6, @wtext[1] + rect.height + 4, bitmap, highlight_rect)
#border top
highlight_rect = Rect.new(rect.x, rect.y, rect.width + 12, 2)
bitmap = Bitmap.new(highlight_rect.width, highlight_rect.height)
bitmap.fill_rect(highlight_rect.x, highlight_rect.y, highlight_rect.width, highlight_rect.height, Color.new(bc[0], bc[1], bc[2], bc[3]))
self.contents.blt(@wtext[0] - 6, @wtext[1] - 6, bitmap, highlight_rect)
#draw back box
bc = Config::W_TEXT_BACK_COLOR
highlight_rect = Rect.new(rect.x, rect.y, rect.width + 8, rect.height + 8)
bitmap = Bitmap.new(highlight_rect.width, highlight_rect.height)
bitmap.fill_rect(highlight_rect.x, highlight_rect.y, highlight_rect.width, highlight_rect.height, Color.new(bc[0], bc[1], bc[2], bc[3]))
self.contents.blt(@wtext[0] - 4, @wtext[1] - 4, bitmap, highlight_rect)
else
#draw back box
bc = Config::W_TEXT_BACK_COLOR
rect = self.contents.text_size(@wtext[2])
highlight_rect = Rect.new(rect.x - 8, rect.y - 4, rect.width + 24, rect.height + 12)
bitmap = Bitmap.new(highlight_rect.width, highlight_rect.height)
bitmap.fill_rect(highlight_rect.x, highlight_rect.y, highlight_rect.width, highlight_rect.height, Color.new(bc[0], bc[1], bc[2], bc[3]))
self.contents.blt(@wtext[0] - 16, @wtext[1] - 8, bitmap, highlight_rect)
end
end
if Config::W_OUTLINED_TEXT == true
self.contents.draw_text_full(@wtext[0], @wtext[1], cx, tx, @wtext[2], 1)
else
self.contents.draw_text(@wtext[0], @wtext[1], cx, tx, @wtext[2], 1)
end
if Config::W_BOLD_TEXT == true
self.contents.font.bold = false
end
end
end
end
#---------------------------------------------------------------------------
# * Scene_Index
#---------------------------------------------------------------------------
class Scene_Index
def initialize(index)
@index = index
end
#-------------------------------------------------------------------------
# * Main
#-------------------------------------------------------------------------
def main
@index_window = Window_Index.new(@index)
@sprite = Sprite.new
@sprite.bitmap = RPG::Cache.picture(Config::MAP_NAME)
# Execute transition
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 windows
@index_window.dispose
@sprite.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@index_window.update
# set text
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to map screen
$scene = Scene_MapMenu.new(@index)
return
end
end
end
#==============================================================================
# ** Scene_Tele
#------------------------------------------------------------------------------
# This class performs Party screen processing.
#==============================================================================
class Scene_Tele
#--------------------------------------------------------------------------
# * Object Initialization
# menu_index : command cursor's initial position
#--------------------------------------------------------------------------
def initialize(tele_index = 0)
@tele_index = tele_index
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
$tele_disabled
# Make command window
s1 = "teleport"
s2 = "location info"
@tele_window = Window_Command.new(120, [s1, s2])
@tele_window.index = @tele_index
@tele_window.x = 0
@tele_window.y = 0
#new sprite (background)
@sprite = Sprite.new
#set sprite image
@sprite.bitmap = RPG::Cache.picture(Config::MAP_NAME)
if $game_system.tele_disabled
@tele_window.disable_item(0)
end
# Execute transition
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 windows
@tele_window.dispose
@sprite.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@tele_window.update
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to map screen
$scene = Scene_Menu.new(2)
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @tele_window.index
when 0 # teleport
if $game_system.tele_disabled
#buzzer here
else
$tele = 0
@index = $game_variables[Menu_Config::MAP_VARIABLE]
# Play decision SE
$game_system.se_play($data_system.decision_se)
#Scene_MapMenu
$scene = Scene_MapMenu.new(@index)
end
when 1 #
$tele = 1
# Play decision SE
$game_system.se_play($data_system.decision_se)
@index = $game_variables[Menu_Config::MAP_VARIABLE]
# Play decision SE
$game_system.se_play($data_system.decision_se)
#Scene_MapMenu
$scene = Scene_MapMenu.new(@index)
end
return
end
end
end
#---------------------------------------------------------------------
# * interpreter fix when setting false via script * credits to Juan, Blizzard
#---------------------------------------------------------------------
class Interpreter
SCRIPT_WAIT_RESULTS = [:wait, FalseClass]
#-------------------------------------------------------------------
# * Script
#-------------------------------------------------------------------
def command_355
# Set first line to script
script = @list[@index].parameters[0] + "\n"
# Store index in case we need to wait.
current_index = @index
# Loop
loop do
# If next event command is second line of script or after
if @list[@index+1].code == 655
# Add second line or after to script
script += @list[@index+1].parameters[0] + "\n"
# If event command is not second line or after
else
# Abort loop
break
end
# Advance index
@index += 1
end
# Evaluation
result = eval(script)
# If return value is false
if SCRIPT_WAIT_RESULTS.include?(result)
# Set index back (If multi-line script call)
@index = current_index
# End and wait
return false
end
# Continue
return true
end
end