hey guys, i have been trying to impliment an updating word on a window when the index changes, heres what i got:
def refresh
if @index = 193
self.contents.clear
self.contents.font.color = normal_color
self.contents.font.size = 20
cx = contents.text_size("test 1").width
self.contents.draw_text(0, 0, cx, 32, "test 1")
return
end
if @index = 174
self.contents.clear
self.contents.font.color = normal_color
self.contents.font.size = 20
cx = contents.text_size("test 2").width
self.contents.draw_text(0, 0, cx, 32, "test 2")
return
else
self.contents.clear
end
end
so if the index is either of the said it should say the corisponding word, or if its else then there should be no text displayed, but say i start on index 193 when i call the scene, then change the word doesnt clear and stays the same, i want it to sort of work like the help window, but inside this window :/
This is your issue.
That is setting the index's value to 193 instead of checking to see if it is equal. To see if its equal to 193, you must use two equal signs.
ok ye i get that, i did try it like that, but the problem im having when its like that is that no text is written, i cant understand why really the code seems pretty clean :???:
Can you post your entire script? Indexes 193 and 174 are pretty high.
ye sure here it is:
#-------------#
#beging config#
#-------------#
module Config
#IMPORT ALL YOUR IMAGES TO THE PICTURES DIRECTORY!
#your main map's image name
MAP_NAME = "kantomap.png"
#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
#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.text_map(index)
return case index
when 193 then 'pallet town'
else ''
end
end
def self.image_name(index)
return case index
when 193 then 'pallettown.png'
#----------#
#END CONFIG#
#----------#
else ''
end
end
end
#============================================================================
# ** Window_Map
#----------------------------------------------------------------------------
class Window_MapMenu < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
refresh
end
#-------------------------------------------------------------------------
# * def index
#-------------------------------------------------------------------------
def index=(index)
@index = index
# Update cursor rectangle
update_cursor_rect
end
#-------------------------------------------------------------------------
# * def refresh
#-------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = normal_color
self.contents.font.size = 20
cx = contents.text_size(Config.text_map(index)).width
self.contents.draw_text(0, 0, cx, 32, Config.text_map(index))
end
#--------------------------------------------------------------------------
# * Cursor Rectangle Update
#--------------------------------------------------------------------------
def update_cursor_rect
x = 0 + @index % 19 * 32
y = 0 + @index / 19 % 14 * 32
self.cursor_rect.set(x, y, 32, 32)
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
# if enter is being pressed
if Input.trigger?(Input::C)
name = Config.image_name(@index)
if name == ''
$scene = Scene_MapMenu.new(@index)
else
$scene = Scene_Index.new(@index)
$game_system.se_play($data_system.decision_se)
end
# If right directional button is pushed
elsif 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 % 19 < 18
# Move cursor to right
$game_system.se_play($data_system.cursor_se)
if @index % 19 < 18
@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 % 19 > 0
# Move cursor to left
$game_system.se_play($data_system.cursor_se)
if @index % 19 > 0
@index -= 1
end
end
# If down directional button is pushed
elsif Input.repeat?(Input::DOWN)
# Move cursor down
if @index / 19 < 13
@index += 19
$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 / 19 > 0
@index -= 19
$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
@mapmenu_window = Window_MapMenu.new
@mapmenu_window.index = @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
@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
$scene = Scene_Menu.new(2)
return
end
end
end
#===========================================================================
# * class Window_Index
#---------------------------------------------------------------------------
class Window_Index < Window_Base
#-------------------------------------------------------------------------
# * Object Initialization
#-------------------------------------------------------------------------
def initialize(index)
super(*Config::WINDOW_SIZE)
@bitmap = RPG::Cache.picture(Config.image_name(index))
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = Config::WINDOW_OPACITY
refresh
end
#-------------------------------------------------------------------------
# * refresh
#-------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.blt(0, 0, @bitmap, Rect.new(0, 0, @bitmap.width, @bitmap.height), 255)
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
i have actually tried implementing the text like how the images are shown but to no avail, anyway you will see :)
try this
#-------------------------------------------------------------------------
# * def index
#-------------------------------------------------------------------------
def index=(index)
@index = index
# Update cursor rectangle
update_cursor_rect
refresh
end
no still no avail, did you post that to use with the first posts refresh method or the second script where i tried implementing it into the module? tried it with both anyway, it seems that if i have self.contents.clear in an else command like so:
def refresh
if @index == 193
self.contents.clear
self.contents.font.color = normal_color
self.contents.font.size = 20
cx = contents.text_size("test 1").width
self.contents.draw_text(0, 0, cx, 32, "test 1")
end
if @index == 174
self.contents.clear
self.contents.font.color = normal_color
self.contents.font.size = 20
cx = contents.text_size("test 2").width
self.contents.draw_text(0, 0, cx, 32, "test 2")
else
self.contents.clear
end
end
then it doesnt display any text, no matter what the index is, but if its at the top like this:
def refresh
self.contents.clear
if @index == 193
self.contents.clear
self.contents.font.color = normal_color
self.contents.font.size = 20
cx = contents.text_size("test 1").width
self.contents.draw_text(0, 0, cx, 32, "test 1")
end
if @index == 174
self.contents.clear
self.contents.font.color = normal_color
self.contents.font.size = 20
cx = contents.text_size("test 2").width
self.contents.draw_text(0, 0, cx, 32, "test 2")
end
end
then test 1 is constantly displayed no matter what the index is, my guess was that it doesnt really matter if self.contents.clear is in an else or not as it should only be doing that if the index isnt equal, but it seems to not be checking the index properly :???:
In this part of your script:
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
# if enter is being pressed
if Input.trigger?(Input::C)
name = Config.image_name(@index)
if name == ''
$scene = Scene_MapMenu.new(@index)
else
$scene = Scene_Index.new(@index)
$game_system.se_play($data_system.decision_se)
end
# If right directional button is pushed
elsif 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 % 19 < 18
# Move cursor to right
$game_system.se_play($data_system.cursor_se)
if @index % 19 < 18
@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 % 19 > 0
# Move cursor to left
$game_system.se_play($data_system.cursor_se)
if @index % 19 > 0
@index -= 1
end
end
# If down directional button is pushed
elsif Input.repeat?(Input::DOWN)
# Move cursor down
if @index / 19 < 13
@index += 19
$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 / 19 > 0
@index -= 19
$game_system.se_play($data_system.cursor_se)
end
end
update_cursor_rect
end
end
When you are setting @index a value, use self.index instead. For example:
self.index += 1 # Assigning @index a value while also calling the method 'def index=(index)'
# However, do not change it to self.index in cases like this here:
name = Config.image_name(@index) # Leave @index alone in cases like this
@ kk20, ok i did that, so it now looks like this:
#-------------#
#beging config#
#-------------#
module Config
#IMPORT ALL YOUR IMAGES TO THE PICTURES DIRECTORY!
#your main map's image name
MAP_NAME = "kantomap.png"
#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
#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'
#----------#
#END CONFIG#
#----------#
else ''
end
end
end
#============================================================================
# ** Window_Map
#----------------------------------------------------------------------------
class Window_MapMenu < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
refresh
end
#-------------------------------------------------------------------------
# * def index
#-------------------------------------------------------------------------
def index=(index)
@index = index
# Update cursor rectangle
update_cursor_rect
refresh
end
#-------------------------------------------------------------------------
# * def refresh
#-------------------------------------------------------------------------
def refresh
if @index == 193
self.contents.clear
self.contents.font.color = normal_color
self.contents.font.size = 20
cx = contents.text_size("test 1").width
self.contents.draw_text(0, 0, cx, 32, "test 1")
end
if @index == 174
self.contents.clear
self.contents.font.color = normal_color
self.contents.font.size = 20
cx = contents.text_size("test 2").width
self.contents.draw_text(0, 0, cx, 32, "test 2")
else
self.contents.clear
end
end
#--------------------------------------------------------------------------
# * Cursor Rectangle Update
#--------------------------------------------------------------------------
def update_cursor_rect
x = 0 + @index % 19 * 32
y = 0 + @index / 19 % 14 * 32
self.cursor_rect.set(x, y, 32, 32)
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
# if enter is being pressed
if Input.trigger?(Input::C)
name = Config.image_name(@index)
if name == ''
$scene = Scene_MapMenu.new(@index)
else
$scene = Scene_Index.new(@index)
$game_system.se_play($data_system.decision_se)
end
# If right directional button is pushed
elsif 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 % 19 < 18
# Move cursor to right
$game_system.se_play($data_system.cursor_se)
if @index % 19 < 18
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 % 19 > 0
# Move cursor to left
$game_system.se_play($data_system.cursor_se)
if @index % 19 > 0
self.index -= 1
end
end
# If down directional button is pushed
elsif Input.repeat?(Input::DOWN)
# Move cursor down
if @index / 19 < 13
self.index += 19
$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 / 19 > 0
self.index -= 19
$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
@mapmenu_window = Window_MapMenu.new
@mapmenu_window.index = @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
@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
$scene = Scene_Menu.new(2)
return
end
end
end
#===========================================================================
# * class Window_Index
#---------------------------------------------------------------------------
class Window_Index < Window_Base
#-------------------------------------------------------------------------
# * Object Initialization
#-------------------------------------------------------------------------
def initialize(index)
super(*Config::WINDOW_SIZE)
@bitmap = RPG::Cache.picture(Config.image_name(index))
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = Config::WINDOW_OPACITY
refresh
end
#-------------------------------------------------------------------------
# * refresh
#-------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.blt(0, 0, @bitmap, Rect.new(0, 0, @bitmap.width, @bitmap.height), 255)
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
im now getting a "no method error for index" on the lines i changed to self.index when i press the corisponding direction :(
Uh...give index a read method.
#============================================================================
# ** Window_Map
#----------------------------------------------------------------------------
class Window_MapMenu < Window_Base
attr_reader :index
# Continue on with the code...
ok that solved it :D im still getting the ropes on scripting so bear with me, i have also been trying to implement what is written into the module config, so it can be added easily, so i added this code to the config:
def self.map_text(index)
return case index
when 193 then [0, 0, cx, 32, "test"]
then changed refresh to look like this:
def refresh
self.contents.clear
self.contents.font.color = normal_color
self.contents.font.size = 20
cx = contents.text_size("test").width
self.contents.draw_text(Config.map_text(index))
end
i tryed to do it like the way the images are shown if you look at my module in the last script, but cant get it to work, iv tryed doing it multiple other ways to, also how would i direct cx at the 5th part of the text config so it reads what is writen?
Well, first off, 'draw_text' needs 5 arguments (or 2 if you use a Rect) to define x-coord, y-coord, width, height, and the string. In your method 'self.map_text' you are returning an array, which would only satisfy one of the five arguments. You will most likely have to call 'self.map_text' and store its result in a temporary variable. Like such:
def refresh
self.contents.clear
self.contents.font.color = normal_color
self.contents.font.size = 20
cx = contents.text_size("test").width
a = Config.map_text(@index) # a will be our temporary array
self.contents.draw_text(a[0], a[1], a[2], a[3], a[4])
end
You will have to use @index instead of index as your parameter when calling 'self.map_text' by the way.
Also, cx in 'refresh' and 'self.map_text' are local variables--they don't share the same values. Not to mention, they're not even in the same class.
Rewrite your script so that 'self.map_text' doesn't use cx, but 'refresh' still does.
def self.map_text(index)
return case index
when 193 then [0, 0, 32, "test"]
end
def refresh
self.contents.clear
self.contents.font.color = normal_color
self.contents.font.size = 20
cx = contents.text_size("test").width
a = Config.map_text(@index) # a will be our temporary array
self.contents.draw_text(a[0], a[1], cx, a[2], a[3])
end
--------------------------
ABOVE ISSUE RESOLVED
--------------------------
cool i totaly get it now :) i understood that i had to create an argument to point it at i just didnt understand how to point at more than 1 argument if it had more in it if you get what i mean, anyway you have been a great help, thanks :D
hey, iv now been messing with the way i call my scene, so heres where im at now:
module:
module Map
#the variable ID which stores what map square to go to
MAP_VARIABLE = 1
def self.map_evariable(index)
return case [Map::MAP_VARIABLE] == [Map.map_evariable(index)]
when 1 then [193]
else [0]
end
end
end
menu selection:
when 2 # map
variable = Map.map_evariable(@index)
# Play decision SE
$game_system.se_play($data_system.decision_se)
# switch to map screen
$scene = Scene_MapMenu.new(variable)
you can probably see what im trying to achieve, i want it to check what the variable declared at the top of the module is equal to and set the number of the index to call to, at the moment im getting the error stack level too deep, i think im nearly there :O.o:
The brackets are not needed, the "[Map::MAP_VARIABLE] == [Map.map_evariable(index)]" would result in a boolean, not a number, and the method is recursive, meaning it calls itself. Ruby does not allow this, and it will throw an error.
Why not just set the variable of each map to its ID, or its ID + 100, etc, etc. Then you wouldn't need a method at all.
im not setting the varriable to the map id because some maps consist of 2 or more index points so say if x is over x then it sets the variable to 1 if its under x then it sets the variable to 2 etc, this way it just makes it easier to configure the way i want it i also just reallised i forgot to add the code for the varriable heres what it looks like as of now:
module Map
#the variable ID which stores what map square to go to
MAP_VARIABLE = 1
def self.map_evariable(index)
return case $game_variables[Map::MAP_VARIABLE]
when 1 then [193]
else [0]
end
end
end
so how would i get it to check the varriable properly? i know how to do it with if statments but it would be easier if it was in the module
What variable?
The above example looks okay, but I don't really know what "index points" are.
What you have will return an array depending on the value of the game variable with the ID of MAP_VARIABLE. If thats what you are aiming for, then you got it. You can add multiple conditions to each "when" in case statements, like this:
def self.get_number(index)
case index
when 0..5 # Returns 0 if index is between 0 and 5 (including 5)
return 0
when 5, 8, 9, 10, 67 # If index is any of these, it returns 3
return 3
when 4..40, 80..90 # Uses two ranges
return 2
end
return [0]
end
ok i sorted it, what i had above was dead on but it was giving me an error for writing the numbers in "[]", also thanks for letting me know how to add multiple conditions, you wouldnt be able to throw all the text comands at me would you? i noticed that some ppl have given there text black outlines etc in some scripts i have seen, iv tryed googling to see if theres a list anywhere but i have only found how to change the text to bold and change the color, having a list would prove very helpful :)
Outlined text is from script addons. Tons of Addons has a very nice one in it.
Aside from that, look in the RMXP help manual. It has some good scripting stuff to learn in there, and should be the Bible of anyone trying to learn RGSS. The draw_text commands are in the Bitmap class, while settings like bold and italic are in the Font class.
text = 'This is text'
bitmap = Bitmap.new(256, 32)
bitmap.font.name = 'Comic Sans'
bitmap.font.size = 22
bitmap.font.color = Color.new(255, 128, 128)
bitmap.font.bold = true
bitmap.font.italic = true
bitmap.draw_text(0, 0, 256, 32, text, 1)
It might also help to know that in the window class, "contents" is just another word for describing the window's bitmap. There is nothing special about it other than that is what it goes by.
-----------------------------
ABOVE ISSUE RESOLVED
-----------------------------
cool thanks man, i never even knew rmxp had scripting help in the help files :o also found the code snippet to make outlined text, trawling through tons :P its actually so simple, :)
hey, so iv been editing away at the menu to include my scene and call it, i have also broke the party menu into a differnt scene so its no longer viewed from the main menu, the isue is that im using blizz abs, so when i open the pre-menu when testing, then go to the main menu, quit out then try opening the pre-menu again the game crashes, i have no idea what could be causing this :wacko:
heres my menu script as of now:
=begin
begin config-
set the id of the varriable that will record what map you are on
=end
module Map
MAP_VARIABLE = 1
end
#end config-
class Scene_Menu
#--------------------------------------------------------------------------
# * Object Initialization
# menu_index : command cursor's initial position
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
end
#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
# This class performs Party screen processing.
#==============================================================================
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Make command window
s1 = $data_system.words.item
s2 = "Party"
s3 = "Map"
s4 = "Save"
s5 = "End Game"
@command_window = Window_Command.new(160, [s1, s2, s3, s4, s5])
@command_window.index = @menu_index
@command_window.x = 480
@command_window.y = 0
@spriteset = Spriteset_Map.new
# If save is forbidden
if $game_system.save_disabled
# Disable save
@command_window.disable_item(2)
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
@command_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@command_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_Map.new
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @command_window.index
when 0 # item
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to item screen
$scene = Scene_Item.new
when 1 # party
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to party screen
$scene = Scene_Party.new
when 2
# Play decision SE
@index = $game_variables[Map::MAP_VARIABLE]
$game_system.se_play($data_system.decision_se)
# switch to map screen
$scene = Scene_MapMenu.new(@index)
when 3 # save
# If saving is forbidden
if $game_system.save_disabled
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to save screen
$scene = Scene_Save.new
when 4 # end game
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to end game screen
$scene = Scene_End.new
end
return
end
end
end
then here is the party scene after removing it from the main menu:
class Scene_Party
#--------------------------------------------------------------------------
# * Object Initialization
# menu_index : command cursor's initial position
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
end
#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
# This class performs Party screen processing.
#==============================================================================
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Make command window
s1 = $data_system.words.skill
s2 = $data_system.words.equip
s3 = "Status"
@command_window = Window_Command.new(160, [s1, s2, s3])
@command_window.index = @menu_index
@command_window.x = 480
@command_window.y = 0
@spriteset = Spriteset_Map.new
# If number of party members is 0
if $game_party.actors.size == 0
# Disable skills, equipment, and status
@command_window.disable_item(0)
@command_window.disable_item(1)
@command_window.disable_item(2)
end
# Make status window
@status_window = Window_MenuStatus.new
@status_window.x = 0
@status_window.y = 0
# 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
@command_window.dispose
@status_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@command_window.update
@status_window.update
# If command window is active: call update_command
if @command_window.active
update_command
return
end
# If status window is active: call update_status
if @status_window.active
update_status
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when command window is active)
#--------------------------------------------------------------------------
def update_command
# 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(1)
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# If command other than save or end game, and party members = 0
if $game_party.actors.size == 0 and @command_window.index < 2
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Branch by command window cursor position
case @command_window.index
when 0 # skill
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 1 # equipment
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 2 # status
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
end
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when status window is active)
#--------------------------------------------------------------------------
def update_status
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Make command window active
@command_window.active = true
@status_window.active = false
@status_window.index = -1
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @command_window.index
when 0 # skill
# If this actor's action limit is 2 or more
if $game_party.actors[@status_window.index].restriction >= 2
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to skill screen
$scene = Scene_Skill.new(@status_window.index)
when 1 # equipment
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to equipment screen
$scene = Scene_Equip.new(@status_window.index)
when 2 # status
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to status screen
$scene = Scene_Status.new(@status_window.index)
end
return
end
end
end
anyone have any ideas what is up???
You are not disposing the @spriteset.
ha nice one, i just chucked it in there without thinking about it :P
I learned that the hard way, too. ;)
Any time the game actually crashes, in Windows I mean, not a script crash, first thing to look for is a sprite you forgot to dispose.
i should have noticed to be fair, after closing the menu it lagged like hell so i should have realised that something was still there :P
--------------------------
above issues resolved
--------------------------
hey, iv created a rect in my window, the code is this:
cx = contents.text_size(@wtext[2]).width
tx = contents.text_size(@wtext[2]).height
self.contents.fill_rect(@wtext[0] - 8, @wtext[1], cx + 16, tx, Color.new(0, 0, 0, 100))
self.contents.draw_text_full(@wtext[0], @wtext[1], cx, tx, @wtext[2])
as you can see this basicly draws a rectangle behind the text that is written, the problem is i have an image behind the rect so when i set the opacity down like seen above i notice its actually deleting the section of the image the rect covers, but i want the image to still be shown behind it, any ideas how i can sort this anyone??
Instead of using fill_rect, create the bitmap as a separate object, then blit it onto the window, like so:
text = 'This is text'
rect = self.contents.text_size(text)
bitmap = Bitmap.new(rect.width, rect.height)
bitmap.fill_rect(0, 0, rect.width, rect.height, Color.new(255, 0, 0, 60))
self.contents.blt(0, 0, bitmap, rect)
self.contents.draw_text(0, 0, rect.width, rect.height, text, 1)
You will need to set the coordinates as needed, but it will not clear out whats already on the "contents".
ok this is how i got it now:
rect = self.contents.text_size(@wtext[2])
bitmap = Bitmap.new(rect.width, rect.height)
bitmap.fill_rect(0, 0, rect.width, rect.height, Color.new(0, 0, 0, 255))
self.contents.blt(@wtext[0]-8, @wtext[1], bitmap, rect)
self.contents.draw_text_full(@wtext[0], @wtext[1], rect.width, rect.height, @wtext[2], 1)
as you can see i minused the x of the blt by 8, what i wanna do is increase the rect width by 16 so it has an offset of 8 on either side, cant get my head round it :<_<:
rect = self.contents.text_size('SOME TEXT')
highlight_rect = Rect.new(rect.x - 8, rect.y, rect.width + 16, rect.height)
Something like that?
ye something like that, although that didnt seem to change anything, so the box should be extended giving the text some space around it so the text doesnt touch the borders, heres what the code looks like now:
cx = contents.text_size(@wtext[2]).width
tx = contents.text_size(@wtext[2]).height
rect = self.contents.text_size(@wtext[2])
if Config::W_TEXT_BACK == true
highlight_rect = Rect.new(rect.x-8, rect.y, rect.width+16, rect.height)
bitmap = Bitmap.new(rect.width, rect.height)
bitmap.fill_rect(0, 0, rect.width, rect.height, Color.new(0, 0, 0, 255))
self.contents.blt(@wtext[0], @wtext[1], bitmap, rect)
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
It doesn't work because you never use it. You have to replace "rect" with "highlight_rect" in the fill_rect call.
ok i edited fill rect like so:
bitmap.fill_rect(0, 0, highlight_rect.width, highlight_rect.height, Color.new(0, 0, 0, 255))
this still does nothing, but if i change blt to this:
self.contents.blt(@wtext[0], @wtext[1], bitmap, highlight_rect)
then it adds some onto the width but the x + 8??? i hate rectangles >:(
You would want to subtract from the x, this will move the left edge of the rect to the left. You then add double that amount you subtracted from the X, and add it to the width. This widens the rect to account for the space that you moved it to the left, and to add the equal amount of space on the right side.
cool i got it to work the way i want it, now im trying to add a border to it by drawing a larger rectangle behind it, the problem is i want the rectangle that is drawn in front of the border one to erase what is behind like what was happerning with the image before, so if the front rectangle is transparent you cant see the border behind it, heres how i have tried implimenting it:
if Config::W_TEXT_BACK == true
if Config::W_TEXT_BACK_BORDER == true
rect = self.contents.text_size(@wtext[2])
highlight_rect = Rect.new(rect.x - 12, rect.y - 8, rect.width + 36, rect.height + 24)
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(255, 255, 255, 255))
self.contents.blt(@wtext[0] - 24, @wtext[1] -16, bitmap, highlight_rect)
end
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(0, 0, 0, 100))
self.contents.blt(@wtext[0] - 16, @wtext[1] - 8, bitmap, highlight_rect)
end
-------------------------------
above issue resolved
-------------------------------
hey, i have been trying to implement a teleport function into a menu, heres what i have so far:
module setup:
#set if tele windows are enabled
TELE_WINDOW = true
#setup teleport locations for index points [id, x, y, direction]
def self.tele_config(index)
return case index
when 193 then [2, 9, 7, 6]
#leave else, this returns no window if no image is set
else ''
end
end
the part of my scene that calls the tele menu:
def update
super
# if enter is being pressed
if Input.trigger?(Input::C)
name = Config.image_name(@index)
if name == ''
$scene = Scene_MapMenu.new(@index)
else
if Config::TELE_WINDOW == true
tele = Config.tele_config(@index)
if tele == ''
$scene = Scene_Index.new(@index)
$game_system.se_play($data_system.decision_se)
else
$scene = Scene_Tele.new
$game_system.se_play($data_system.decision_se)
end
else
$scene = Scene_Index.new(@index)
$game_system.se_play($data_system.decision_se)
end
the tele scene:
#==============================================================================
# ** Scene_Tele
#------------------------------------------------------------------------------
# This class performs Party screen processing.
#==============================================================================
class Scene_Tele
#--------------------------------------------------------------------------
# * Object Initialization
# menu_index : command cursor's initial position
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Make command window
s1 = "teleport"
s2 = "location info"
@command_window = Window_Command.new(120, [s1, s2])
@command_window.index = @menu_index
@command_window.x = 0
@command_window.y = 0
#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
@command_window.dispose
@sprite.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@command_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_Map.new
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @command_window.index
when 0 # teleport
telesetup = Config.tele_config(@index)
# Play decision SE
$game_system.se_play($data_system.decision_se)
# teleport
$game_temp.player_transferring = true
# Set player move destination
$game_temp.player_new_map_id = telesetup[0]
$game_temp.player_new_x = telesetup[1]
$game_temp.player_new_y = telesetup[2]
$game_temp.player_new_direction = telesetup[3]
$scene = Scene_Map.new
when 1 #
# Play decision SE
$game_system.se_play($data_system.decision_se)
end
return
end
end
end
so depending on the index of the previous menu it will return you at the id, x, y, direction, specified for that index in the module, the problem is i get the error cant find map id 000 rx data,
i cant figure out what could be up with it :uhm:
Looks like your Config method is not returning the correct values.
$game_temp.player_new_map_id = telesetup[0]
This is returning either 0 or nil, both of which are not valid for a map ID.
Add a "p telesetup" before this call to see what the values are.
ok i did that, when running it i got a box with ""
im guesing this was supposed to say the value?
Yeah.
What's your config look like?
like this:
#-------------#
#beging config#
#-------------#
module Config
#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 windows are enabled
TELE_WINDOW = true
#setup teleport locations for index points [id, x, y, direction]
def self.tele_config(index)
return case index
when 193 then [2, 9, 7, 6]
#leave else, this returns no window if no image is set
else ''
end
end
end
the config for the teleport is at the bottom
At the very end...
def self.tele_config(index)
return case index
when 193 then [2, 9, 7, 6]
#leave else, this returns no window if no image is set
else ''
end
end
You only have one thing defined.
If you try to call this and @index does not equal 193, you are going to get an error.
at the end of my config else''
heres the part that calls the window:
if Config::TELE_WINDOW == true
tele = Config.tele_config(@index)
if tele == ''
$scene = Scene_Index.new(@index)
$game_system.se_play($data_system.decision_se)
else
$scene = Scene_Tele.new
$game_system.se_play($data_system.decision_se)
end
else
$scene = Scene_Index.new(@index)
$game_system.se_play($data_system.decision_se)
end
end
notice if Config.tele_config == '' then it bypasses the scene, it does this corectly, the fact is im calling the scene from index 193 and im getting the error when trying to use the teleport
edit:
i have figured out why its getting the wrong values, it is going by the else condition instead of the index, here is what happens exactly in the scene:
you open the map
when you press the c button on a location(index) it checks if teleporting function is on
if teleporting function is on it creates a new command window
the command window has a teleporting selection and another to view a window of the location
when the teleporting selection is selected it should transfer you according to the index of the map window(previous window to this)
i set a value for the else and it transfered me to where i specified, even though i had accessed the transfer method from a index point specified in the config :/
----------------------------
above issue resolved
----------------------------
hey people, im having an issue relating to my teleporting function, i have got it to work, what im trying to do now is make it so i can disable the selection to teleport, i have tryed making it like how the save option is disabled, heres what i have got,
i added this to Game_System:
attr_accessor :tele_disabled
then i added this to the initialization in game_system:
then i add into my script if conditions checking if the tele option is disabled or not, and i enable and disable it in an event like so:
@>condition branch: script: $game_system.tele_disabled == true
@>text: enable teleport?
@>choices: yes, no
: when [yes]
@>script: $game_system.tele_disabled = false
: when [no]
@>
: branch end
@>
: Else
@>text: disable teleport?
@>choices: yes, no
: when [yes]
@>script: $game_system.tele_disabled = true
: when [no]
@>
: branch end
@>
: branch end
@>
------------
the problem im having with this is when the game first starts up the teleporting is enabled and works fine, then when i activate the event to enable or disable it i can disable it fine, and it disables in the menu, then when i activate the event again it reconizes that teleporting is disabled and asks if you want to enable it, when i choose the option yes i the game hangs, it does not crash just hangs :/
I believe this is related to a bug in RMXP when setting something to false via a call script. there is a fix for that somewhere.
thanks i found it, and that sorted it :)
hey guys, i have been trying to figure out how i could implement a way to disable teleport locations via script call, the way i have my teleport set up is i have a command window pop up asking if you want to teleport or just search the map, like this:
def main
# 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
when you select an option the variable $tele is set a value which is checked in the map window when selecting a location like so:
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
# Play decision SE
$game_system.se_play($data_system.decision_se)
#transfering is happening
$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
$scene = Scene_Map.new
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
so as you can se if the variable is set to 0 it teleports you, if the variable is 1 it opens a window with location information etc, then the location you teleport is set up in the config like so:
def self.tele_config(index)
return case index
when 155 then [3, 9, 7, 6]
when 174 then [2, 9, 7, 6]
when 193 then [1, 9, 7, 6]
#leave else, this disables teleporting at index's unasigned
else ''
end
end
so what im trying to achieve is disabling teleport locations at certain index points, i have no clue how i would go about it, i know how to disable items in a window and how to create a method to disable the selection like how the save function is enabled and disabled but doing it that way would require me to create a method for every single index point and the index goes up to 240+, even if i could add and remove teleporting locations from the config via script calls would work, but i dont even know if that is possible :huh:
Practical way I can think of is make an accessible array that contains the index values of your map. When you want to disable teleporting to (for example) map index 100, push 100 into the array. In your script, when the cursor is located at index 100, you can use the array method 'include?' to check if 100 is in it or not. That way, you won't need a bunch of booleans for each and every index :wacko:
On the game map, you can use script calls to this array using 'push' and 'delete' to enable/disable teleport.
ok i added this to the window_mapmenu in the update:
then i added this to the teleporting selection:
if telearray.include?[@index]
#play buzzer
else
#teleporting happens
end
and im trying to add to the array with this script call:
$window_mapmenu.telearray.push[193]
when using the script call i get the error undefined method for telearray, thats about how far i got into testing it, am i going down the right track?
Use parentheses when calling array methods. It's include?(index), not include?[index]. Same with push.
-points to the RMXP Help File-
ok i changed that and i still get the same error, i even tryed def the method like so:
def telearray
telearray = []
@telearray = telearray
end
am i using the script call right?
$window_mapmenu.telearray.push(193)
edit:
nvm i got it to work, thanks for the help :D
---------------------------
above issues resolved
---------------------------
What I would do is create the array in Game System (also make it an attr_accessor).
ye thats exactly what i did, as for adding to game system i gues it is better to allias it rather than add it straight in? im not fully sure on what alliasing does but from what iv read i figured it adds to a class rather that replacing it? +1 for the help i really should give people + more often :shy:
It just makes a copy of the original method and renames it, allowing you to make changes to the original without rewriting everything.
class Do_Something
# The original method
def say_something
print "I'm cool..."
end
# Now we alias it
alias say_something_cooler say_something
# This is what the alias creates:
def say_something_cooler
print "I'm cool..."
end
# Now we redefine the original method
def say_something
say_something_cooler
print "...just like ice cream"
end
# In essence, the modified method looks like this:
def say_something
print "I'm cool..."
print "...just like ice cream"
end
end
Yeah, alias made no sense to me when I first saw it. But after playing around with it, I :facepalm:
cool, that makes sense now, it will probably be easier to do it that way rather than write it into the default script so that people dont have to replace them scripts with my edits to, thanks again :D