Jump to content
kal

Ruby/RGSS3 questions that don't deserve their own thread

Recommended Posts

Bump ?? 
New question :

I have trouble changing a value inside a 2D array

 

Using msgbox I can see my array is correctly defined [ [0,0] , [0,0] , [0,0] ]

but trying something like this

array[2][1] = 3

return me this [ [0,3] [0,3] [0,3] ]

while i would want this [ [0,0] , [0,0] , [0,3] ] 

 

What am I doing wrong ? 

Share this post


Link to post
Share on other sites

@Shiggy,

Could be the way you created the array.

arr = [[0,0],[0,0],[0,0]]
p arr
arr[2][1] = 3
p arr # => [[0,0], [0,0], [0,3]]

While

arr = [[0,0]]*3
p arr
arr[2][1] = 3
p arr # => [[0,3], [0,3], [0,3]]

Share this post


Link to post
Share on other sites

array[2][1] = 3 is not wrong. If that is what you are doing and that is the result you are getting then that means that all the three arrays in that array are the same, meaning that they are all references to the same array. So if you were to first do array[1] = [0,0] and then do array[2][1] = 3 again I think you would get this result: [ [0,3] [0,0] [0,3] ]

 

edit: ack, I was too late

Edited by Quack

Share this post


Link to post
Share on other sites

thanks to both of you, i didn't write exactly this [[0,0]]*3 but it's probably equivalent .

i will redefine it then.

 

thanks again,it was making me crazy

Share this post


Link to post
Share on other sites

Hi, guys!

 

Quick question. I'm trying to call a method from inside class Scene_Menu < Scene_MenuBase, but I'm confused by the < symbol in there. Is Scene_MenuBase a subclass or something? How should I call the method?

 

Thanks in advance! :)

Share this post


Link to post
Share on other sites

Hi, guys!

 

Quick question. I'm trying to call a method from inside class Scene_Menu < Scene_MenuBase, but I'm confused by the < symbol in there. Is Scene_MenuBase a subclass or something? How should I call the method?

 

Thanks in advance! :)

 

Actually Scene_Menu is the subclass of Scene_MenuBase. The < just tells ruby that the class you are defining is a subclass of another class, it's more or less irrelevant when calling methods.

 

Though what do you mean you are calling the method from inside that class? Calling another method on  the same object? Remember that you can use "self" as a handy way to do that. For example:

 

 

class MyClass
 
  def method_a
    self.method_b #call method_b of this object
  end
 
  def method_b
    #do something
  end
 
end
  • Like 1

Share this post


Link to post
Share on other sites

Thanks for the fast answer :) Sorry for not explaining myself properly, I'm still learning and don't know very well what I'm doing.

 

What I want to do is call a method from outside of its class. I'll show you the snippet in question to get some context:

class Scene_Menu < Scene_MenuBase
  
  #--------------------------------------------------------------------------
  # * Save BGM and BGS
  #--------------------------------------------------------------------------
  def save_bgm_and_bgs
    if $game_switches[10] == false
    @map_bgm = RPG::BGM.last
    @map_bgs = RPG::BGS.last
    $game_switches[10] = true
    end
  end
  
  #--------------------------------------------------------------------------
  # * Play Menu BGM
  #--------------------------------------------------------------------------
  def play_menu_bgm
    RPG::BGM.new("Menu", 100, 100).play
    RPG::BGS.stop
  end
  
  #--------------------------------------------------------------------------
  # * Resume BGM and BGS
  #--------------------------------------------------------------------------
  def replay_bgm_and_bgs
    $game_switches[10] = false
    @map_bgm.replay
    @map_bgs.replay
  end

end

I'd like to call the replay_bgm_and_bgs method from a script call in an event, from other classes, etc.

Edited by Absurdiness

Share this post


Link to post
Share on other sites

Well, long story short, methods are run on objects not classes. You need a instance of the class for those methods to work. Basically classes are not actually things that do stuff, they just are like blueprints for making things that do stuff. With a few exceptions anyway... but best not get into that.

 

For scenes, the default scripts put the current instance of the scene you are in at SceneManager.scene so you can call SceneManager.scene.save_bgm_and_bgs for example if the current scene is a instance of the Scene_Menu class. If you want to make a new scene that uses code from Scene_Menu you will basically have to make a subclass.

Edited by KilloZapit
  • Like 1

Share this post


Link to post
Share on other sites

Thanks! I understand better now. I've tried storing RPG::BGM.last and RPG::BGS.last into game variables instead of local (lazy fix... I guess there must be a way to create global variables, right?, but I've got no idea how. Well, it works, anyway), then copying the replay_bgm_and_bgs method into the Scene in question I was trying to call this from, and I got the desired result. Thank you for your help and for the explanation! :)

Share this post


Link to post
Share on other sites

You can declare a global variable by starting the variable name with '$'.

If you want to know how to do something that's just general programming knowledge and not rpg maker specific you could just google it (google ruby global variables in this case) and you are pretty much guaranteed to find what you are looking for.

  • Like 1

Share this post


Link to post
Share on other sites

Hi, how do I access a variable located inside a script from the script event command?

I want to give an ingame variable the value of a variable located inside a script

Edited by Flechita

Share this post


Link to post
Share on other sites

You can attribut a ingame variable fromthe script with ...

$game_variables

 

If it's not enough define a new method in your stuff 

 

def new_method

 $game_variables= @script_variable

end

 

you can easily access methods from scene with SceneManager.scene.new_method
Other stuff you can easily acess $game_player  , $game_party , $game_map 

for the classes Game_Player , Game_party ,Game_Map

 

some other classes are instanced into global variables, check DataManager for more info

  • Like 1

Share this post


Link to post
Share on other sites

Do you know of some restriction with the make_save_sontents / Marshal.save . I could'nt save some objects , I managed to find a workaround but knowing more might be useful.

Share this post


Link to post
Share on other sites

Well basically you shouldn't be able to dump any object that:

 

  1. Involves open file streams or network connections (usually not a thing you have to worry about since most scripters don't deal with these)
  2. Involves engine data that is handled in C code (such as bitmaps, sprites, windows, and other graphics objects, which should always be created and updated independently in the same manner the default scripts do, using scene sprite sets and stuff)
  3. Involves procs, lambdas, and other such objects (strings that are evaled are fine though).

You can however define functions that override the default behavior in how an object is dumped and loaded though, enabling you to maybe be able to dump objects you normally wouldn't be able to, provided you have a good way to remember everything needed for the object and reconstruct it. Look at this for more info.

 

It's entirely possible for example to modify the Bitmap class to remember what file was loaded and just dump that and recreate it form the original file when loaded. In the end it's a work around for a problem that shouldn't exist if you keep the sprite and object data well separated like the default scripts though, so I wouldn't recommend it. Of course it won't save the exact state of every pixel anyway. You could transform it into a pixel array by reading or setting each pixel one by one I guess but that would be really slow.

Edited by KilloZapit
  • Like 1

Share this post


Link to post
Share on other sites

Ok thank you. You are the best fairy I know <3

 

I was trying to save a bitmap containing player drawing so I saved an array containing pixel coordinates instead.

Good to know what I can and cannot do for the future.

Share this post


Link to post
Share on other sites

Yeah, there is no proper way to save bitmaps without doing it pixel by pixel unfortunately.  It should be doable for smaller bitmaps maybe, but larger ones are bound to cause problems. You also might want to try using the Table class instead of an array, I think that can be dumped and it is meant to be faster and use less memory.

Share this post


Link to post
Share on other sites

I 'm not saving every pixel only the ones the players has drawn so it's ok -ish . I may try table if i need to optimise. Thanks again.

 

Edit : 

When I move up to bigger images,it was taking too much time even with tables. I find a wa to save my bitmap files via a piece of code from Tsukihime 's map screenshot script

Edited by Shiggy

Share this post


Link to post
Share on other sites

Hi, guys!

 

Quick question: is there a way to call from a script the F1 options window? To force it to open somehow, without needing to press the F1 key?

Share this post


Link to post
Share on other sites

Thanks for the fast answer!

 

Mmm. That's unfortunate... Could it be possible to make a simulation of a key press, then? Make the game think that you have pressed a button, even if you haven't?

Share this post


Link to post
Share on other sites

Can you describe the context of what you want?

Share this post


Link to post
Share on other sites

I'm working on a customised version of Yanfly's System Options script. Ideally, I'd disable the F1 menu access and add a way to change keyboard and joystick configuration from inside the game itself, but after looking around I've seen that doesn't really seem to be possible, or at least it would be far beyond my current ability. So I thought I'd call the default external window from inside the menu instead.

 

My version of the script:

 

#==============================================================================
# 
# â–¼ Yanfly Engine Ace - System Options v1.00
# -- Last Updated: 2012.01.01
# -- Level: Normal
# -- Requires: n/a
# 
#==============================================================================

$imported = {} if $imported.nil?
$imported["YEA-SystemOptions"] = true

#==============================================================================
# â–¼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2012.01.01 - Started Script and Finished.
# 
#==============================================================================
# â–¼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script replaces the "Game End" option in the Main Menu with a "System"
# menu where the player can adjust various settings in the game. Of them, the
# player can change the window colour, the volume for BGM, BGS, SFX, set
# automatic dashing, message text to display instantly, and speed up battles by
# hiding battle animations.
# 
#==============================================================================
# â–¼ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below â–¼ Materials/ç´ æ but above â–¼ Main. Remember to save.
# 
# -----------------------------------------------------------------------------
# Script Calls - These commands are used with script calls.
# -----------------------------------------------------------------------------
# $game_system.volume_change(:bgm, x)
# $game_system.volume_change(:bgs, x)
# $game_system.volume_change(:sfx, x)
# Unlike the previous Yanfly Engines, this version does not bind volume to a
# variable. Use the script call to change the bgm, bgs, or sfx sound rate by
# x increment. Use a negative value to lower the volume.
# 
# $game_system.set_autodash(true)
# $game_system.set_autodash(false)
# Turns autodash on (true) or off (false).
# 
# $game_system.set_instantmsg(true)
# $game_system.set_instantmsg(false)
# Turns instant messages on (true) or off (false).
# 
# $game_system.set_animations(true)
# $game_system.set_animations(false)
# Turns battle animations on (true) or off (false).
# 
#==============================================================================
# â–¼ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
# 
#==============================================================================

module YEA
  module SYSTEM
    
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # - General Setting -
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # These are the general settings that govern the System settings. This will
    # change the "Game End" vocab, and disable or enable autodash, instant
    # messages, or animations by default.
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    COMMAND_NAME = "Configura"      # Command name used to replace Game End.
    DEFAULT_AUTODASH   = false    # Enable automatic dashing by default?
    DEFAULT_INSTANTMSG = false   # Enable instant message text by default?
    DEFAULT_ANIMATIONS = true    # Enable battle animations by default?
    
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # - Command Settings -
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # These settings adjust the commands shown in the command list. Add, remove
    # or rearrange the commands as you see fit. Here's a list of which commands
    # do what:
    # 
    # -------------------------------------------------------------------------
    # :command         Description
    # -------------------------------------------------------------------------
    # :blank           Inserts an empty blank space.
    # 
    # :window_red      Changes the red tone for all windows.
    # :window_grn      Changes the green tone for all windows.
    # :window_blu      Changes the blue tone for all windows.
    # 
    # :volume_bgm      Changes the BGM volume used.
    # :volume_bgs      Changes the BGS volume used.
    # :volume_sfx      Changes the SFX volume used.
    # 
    # :autodash        Sets the player to automatically dash.
    # :instantmsg      Sets message text to appear instantly.
    # :animations      Enables battle animations or disables them.
    # 
    # :to_title        Returns to the title screen.
    # :shutdown        Shuts down the game.
    # 
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    COMMANDS =[
#~       :window_red,   # Changes the red tone for all windows.
#~       :window_grn,   # Changes the green tone for all windows.
#~       :window_blu,   # Changes the blue tone for all windows.
      :screensize,
      :fullscreen,
      :fullscreen2,
      :joystick,
      :blank,
      :volume_bgm,   # Changes the BGM volume used.
      :volume_bgs,   # Changes the BGS volume used.
      :volume_sfx,   # Changes the SFX volume used.
      :blank,
      :autodash,     # Sets the player to automatically dash.
      :instantmsg,   # Sets message text to appear instantly.
    #  :animations,   # Enables battle animations or disables them.
    # :switch_1,     # Custom Switch 1. Adjust settings below.
    # :switch_2,     # Custom Switch 2. Adjust settings below.
      :variable_1,   # Custom Variable 1. Adjust settings below.
    # :variable_2,   # Custom Variable 2. Adjust settings below.
      :blank,
      :to_title,     # Returns to the title screen.
      :shutdown,     # Shuts down the game.
    ] # Do not remove this.
    
    #--------------------------------------------------------------------------
    # - Custom Switches -
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    # If you want your game to have system options other than just the ones
    # listed above, you can insert custom switches here to produce such an
    # effect. Adjust the settings here as you see fit.
    #--------------------------------------------------------------------------
    CUSTOM_SWITCHES ={
    # -------------------------------------------------------------------------
    # :switch    => [Switch, Name, Off Text, On Text, 
    #                Help Window Description
    #               ], # Do not remove this.
    # -------------------------------------------------------------------------
      :switch_1  => [ 1, "Custom Switch 1", "OFF", "ON",
                     "Help description used for custom switch 1."
                    ],
    # -------------------------------------------------------------------------
      :switch_2  => [ 2, "Custom Switch 2", "OFF", "ON",
                     "Help description used for custom switch 2."
                    ],
    # -------------------------------------------------------------------------
    } # Do not remove this.
    
    #--------------------------------------------------------------------------
    # - Custom Variables -
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    # If you want your game to have system options other than just the ones
    # listed above, you can insert custom variables here to produce such an
    # effect. Adjust the settings here as you see fit.
    #--------------------------------------------------------------------------
    CUSTOM_VARIABLES ={
    # -------------------------------------------------------------------------
    # :variable   => [Switch, Name, Colour1, Colour2, Min, Max,
    #                 Help Window Description
    #                ], # Do not remove this.
    # -------------------------------------------------------------------------
      :variable_1 => [ 15, "Color del menú", 9, 1, 0, 6,
                      "Tria el color de fons del menú. 0: aleatori, 1: groc, 2: blau, 3: blanc i negre, 4: verd, 5: lila, 6: vermell."
                     ],
    # -------------------------------------------------------------------------
      :variable_2 => [ 2, "Custom Variable 2", 10, 2, -10, 10,
                      "Help description used for custom variable 2."
                     ],
    # -------------------------------------------------------------------------
    } # Do not remove this.
    
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # - Vocab Settings -
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # This hash adjusts the vocab used for both the commands and the help
    # description that appears above the command window. Note that for the
    # command help descriptions, you may use text codes. Use \n to linebreak.
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    COMMAND_VOCAB ={
    # -------------------------------------------------------------------------
    # :command    => [Command Name, Option1, Option2
    #                 Help Window Description,
    #                ], # Do not remove this.
    # -------------------------------------------------------------------------
      :blank      => ["", "None", "None",
                      ""
                     ], # Do not remove this.
    # -------------------------------------------------------------------------
      :window_red => ["Window Red", "None", "None",
                      "Change the red colour tone for windows.\n" +
                      "Hold SHIFT to change increment by 10."
                     ], # Do not remove this.
    # -------------------------------------------------------------------------
      :window_grn => ["Window Green", "None", "None",
                      "Change the green colour tone for windows.\n" +
                      "Hold SHIFT to change increment by 10."
                     ], # Do not remove this.
    # -------------------------------------------------------------------------
      :window_blu => ["Window Blue", "None", "None",
                      "Change the blue colour tone for windows.\n" +
                      "Hold SHIFT to change increment by 10."
                     ], # Do not remove this.
    # -------------------------------------------------------------------------
      :volume_bgm => ["Volum música", 12, 4, # Options 1 & 2 are Gauge Colours.
                      "Canvia el volum de la música de fons.\n" +
                      "Pulsa SHIFT per canviar el volum per un increment de 10."
                     ], # Do not remove this.
    # -------------------------------------------------------------------------
      :volume_bgs => ["Volum sons", 13, 5, # Options 1 & 2 are Gauge Colours.
                      "Canvia el volum dels sons de fons.\n" +
                      "Pulsa SHIFT per canviar el volum per un increment de 10."
                     ], # Do not remove this.
    # -------------------------------------------------------------------------
      :volume_sfx => ["Volum efectes", 14, 6, # Options 1 & 2 are Gauge Colours.
                      "Canvia el volum dels efectes de so.\n" +
                      "Pulsa SHIFT per canviar el volum per un increment de 10."
                     ], # Do not remove this.
    # -------------------------------------------------------------------------
      :autodash   => ["Córrer automàticament", "Caminar", "Córrer",
                      "Corre tota l'estona sense prémer el botó de córrer (SHIFT)."
                     ], # Do not remove this.
    # -------------------------------------------------------------------------
      :instantmsg => ["Text instantani", "Lletra per lletra", "Instantani",
                      "Fes aparèixer els missatges d'immediat a la pantalla o bé lletra per lletra."
                     ], # Do not remove this.
    # -------------------------------------------------------------------------
      :animations => ["Animacions batalla", "Amaga", "Mostra",
                      "Amaga les animacions de les batalles per accelerar-les."
                     ], # Do not remove this.
    # -------------------------------------------------------------------------
      :to_title   => ["Retorna al títol", "None", "None",
                      "Torna al títol d'inici del joc."
                     ], # Do not remove this.
    # -------------------------------------------------------------------------
      :shutdown   => ["Apaga el joc", "None", "None",
                      "Apaga el joc."
                     ], # Do not remove this.
    # -------------------------------------------------------------------------
      :joystick  => ["Configura els controls [F1]", "None", "None",
                      "Configura els controls de teclat i de joystick."
                     ], # Do not remove this.
    # -------------------------------------------------------------------------
      :fullscreen  => ["Pantalla completa (opció 1) [F5]", "None", "None",
                      "Activa o desactiva el mode de pantalla completa."
                     ], # Do not remove this.
    # -------------------------------------------------------------------------
      :fullscreen2  => ["Pantalla completa (opció 2)", "None", "None",
                      "Mode alternatiu de pantalla completa. També es pot activar i desactivar des de la configuració de controls (F1)."
                     ], # Do not remove this.
    # -------------------------------------------------------------------------
      :screensize  => ["Augment de pantalla [F6]", "None", "None",
                      "Canvia l'augment de la pantalla i la mida de la finestra."
                     ], # Do not remove this.
    # -------------------------------------------------------------------------
  
    
    } # Do not remove this.
    
  end # SYSTEM
end # YEA

#==============================================================================
# â–¼ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================

#==============================================================================
# â–  Vocab
#==============================================================================

module Vocab
  
  #--------------------------------------------------------------------------
  # overwrite method: self.game_end
  #--------------------------------------------------------------------------
  def self.game_end
    return YEA::SYSTEM::COMMAND_NAME
  end
  
end # Vocab

#==============================================================================
# â–  RPG::BGM
#==============================================================================

class RPG::BGM < RPG::AudioFile
  
  #--------------------------------------------------------------------------
  # overwrite method: play
  #--------------------------------------------------------------------------
  def play(pos = 0)
    if @name.empty?
      Audio.bgm_stop
      @@last = RPG::BGM.new
    else
      volume = @volume
      volume *= $game_system.volume(:bgm) * 0.01 unless $game_system.nil?
      Audio.bgm_play('Audio/BGM/' + @name, volume, @pitch, pos)
      @@last = self.clone
    end
  end
  
end # RPG::BGM

#==============================================================================
# â–  RPG::ME
#==============================================================================

class RPG::ME < RPG::AudioFile
  
  #--------------------------------------------------------------------------
  # overwrite method: play
  #--------------------------------------------------------------------------
  def play
    if @name.empty?
      Audio.me_stop
    else
      volume = @volume
      volume *= $game_system.volume(:bgm) * 0.01 unless $game_system.nil?
      Audio.me_play('Audio/ME/' + @name, volume, @pitch)
    end
  end
  
end # RPG::ME

#==============================================================================
# â–  RPG::BGS
#==============================================================================

class RPG::BGS < RPG::AudioFile
  
  #--------------------------------------------------------------------------
  # overwrite method: play
  #--------------------------------------------------------------------------
  def play(pos = 0)
    if @name.empty?
      Audio.bgs_stop
      @@last = RPG::BGS.new
    else
      volume = @volume
      volume *= $game_system.volume(:bgs) * 0.01 unless $game_system.nil?
      Audio.bgs_play('Audio/BGS/' + @name, volume, @pitch, pos)
      @@last = self.clone
    end
  end
  
end # RPG::BGS

#==============================================================================
# â–  RPG::SE
#==============================================================================

class RPG::SE < RPG::AudioFile
  
  #--------------------------------------------------------------------------
  # overwrite method: play
  #--------------------------------------------------------------------------
  def play
    unless @name.empty?
      volume = @volume
      volume *= $game_system.volume(:sfx) * 0.01 unless $game_system.nil?
      Audio.se_play('Audio/SE/' + @name, volume, @pitch)
    end
  end
  
end # RPG::SE

#==============================================================================
# â–  Game_System
#==============================================================================

class Game_System
  
  #--------------------------------------------------------------------------
  # alias method: initialize
  #--------------------------------------------------------------------------
  alias game_system_initialize_so initialize
  def initialize
    game_system_initialize_so
    init_volume_control
    init_autodash
    init_instantmsg
    init_animations
  end
  
  #--------------------------------------------------------------------------
  # new method: init_volume_control
  #--------------------------------------------------------------------------
  def init_volume_control
    @volume = {}
    @volume[:bgm] = 100
    @volume[:bgs] = 100
    @volume[:sfx] = 100
  end
  
  #--------------------------------------------------------------------------
  # new method: volume
  #--------------------------------------------------------------------------
  def volume(type)
    init_volume_control if @volume.nil?
    return [[@volume[type], 0].max, 100].min
  end
  
  #--------------------------------------------------------------------------
  # new method: volume_change
  #--------------------------------------------------------------------------
  def volume_change(type, increment)
    init_volume_control if @volume.nil?
    @volume[type] += increment
    @volume[type] = [[@volume[type], 0].max, 100].min
  end
  
  #--------------------------------------------------------------------------
  # new method: init_autodash
  #--------------------------------------------------------------------------
  def init_autodash
    @autodash = YEA::SYSTEM::DEFAULT_AUTODASH
  end
  
  #--------------------------------------------------------------------------
  # new method: autodash?
  #--------------------------------------------------------------------------
  def autodash?
    init_autodash if @autodash.nil?
    return @autodash
  end
  
  #--------------------------------------------------------------------------
  # new method: set_autodash
  #--------------------------------------------------------------------------
  def set_autodash(value)
    @autodash = value
  end
  
  #--------------------------------------------------------------------------
  # new method: init_instantmsg
  #--------------------------------------------------------------------------
  def init_instantmsg
    @instantmsg = YEA::SYSTEM::DEFAULT_INSTANTMSG
  end
  
  #--------------------------------------------------------------------------
  # new method: instantmsg?
  #--------------------------------------------------------------------------
  def instantmsg?
    init_instantmsg if @instantmsg.nil?
    return @instantmsg
  end
  
  #--------------------------------------------------------------------------
  # new method: set_instantmsg
  #--------------------------------------------------------------------------
  def set_instantmsg(value)
    @instantmsg = value
  end
  
  #--------------------------------------------------------------------------
  # new method: init_animations
  #--------------------------------------------------------------------------
  def init_animations
    @animations = YEA::SYSTEM::DEFAULT_ANIMATIONS
  end
  
  #--------------------------------------------------------------------------
  # new method: animations?
  #--------------------------------------------------------------------------
  def animations?
    init_animations if @animations.nil?
    return @animations
  end
  
  #--------------------------------------------------------------------------
  # new method: set_animations
  #--------------------------------------------------------------------------
  def set_animations(value)
    @animations = value
  end
  
end # Game_System

#==============================================================================
# â–  Game_Player
#==============================================================================

class Game_Player < Game_Character
  
  #--------------------------------------------------------------------------
  # alias method: dash?
  #--------------------------------------------------------------------------
  alias game_player_dash_so dash?
  def dash?
    if $game_system.autodash?
      return false if @move_route_forcing
      return false if $game_map.disable_dash?
      return false if vehicle
      return !Input.press?(:A)
    else
      return game_player_dash_so
    end
  end
  
end # Game_Player

#==============================================================================
# â–  Scene_Battle
#==============================================================================

class Scene_Battle < Scene_Base
  
  #--------------------------------------------------------------------------
  # alias method: show_fast?
  #--------------------------------------------------------------------------
  alias scene_battle_show_fast_so show_fast?
  def show_fast?
    return true unless $game_system.animations?
    return scene_battle_show_fast_so
  end
  
  #--------------------------------------------------------------------------
  # alias method: show_normal_animation
  #--------------------------------------------------------------------------
  alias scene_battle_show_normal_animation_so show_normal_animation
  def show_normal_animation(targets, animation_id, mirror = false)
    return unless $game_system.animations?
    scene_battle_show_normal_animation_so(targets, animation_id, mirror)
  end
  
end # Scene_Battle

#==============================================================================
# â–  Window_Message
#==============================================================================

class Window_Message < Window_Base
  
  #--------------------------------------------------------------------------
  # alias method: clear_flags
  #--------------------------------------------------------------------------
  alias window_message_clear_flags_so clear_flags
  def clear_flags
    window_message_clear_flags_so
    @show_fast = true if $game_system.instantmsg?
  end
  
end # Window_Message

#==============================================================================
# â–  Window_SystemOptions
#==============================================================================

class Window_SystemOptions < Window_Command
  
  #--------------------------------------------------------------------------
  # initialize
  #--------------------------------------------------------------------------
  def initialize(help_window)
    @help_window = help_window
    super(0, @help_window.height)
    refresh
  end
  
  #--------------------------------------------------------------------------
  # window_width
  #--------------------------------------------------------------------------
  def window_width; return Graphics.width; end
  
  #--------------------------------------------------------------------------
  # window_height
  #--------------------------------------------------------------------------
  def window_height; return Graphics.height - @help_window.height; end
  
  #--------------------------------------------------------------------------
  # update_help
  #--------------------------------------------------------------------------
  def update_help
    if current_symbol == :custom_switch || current_symbol == :custom_variable
      text = @help_descriptions[current_ext]
    else
      text = @help_descriptions[current_symbol]
    end
    text = "" if text.nil?
    @help_window.set_text(text)
  end
  
  #--------------------------------------------------------------------------
  # ok_enabled?
  #--------------------------------------------------------------------------
  def ok_enabled?
    return true if [:to_title, :shutdown, :joystick, :fullscreen, :fullscreen2, :screensize].include?(current_symbol)
    return false
  end
  
  #--------------------------------------------------------------------------
  # make_command_list
  #--------------------------------------------------------------------------
  def make_command_list
    @help_descriptions = {}
    for command in YEA::SYSTEM::COMMANDS
      case command
      when :blank
        add_command(YEA::SYSTEM::COMMAND_VOCAB[command][0], command)
        @help_descriptions[command] = YEA::SYSTEM::COMMAND_VOCAB[command][3]
      when :window_red, :window_grn, :window_blu
        add_command(YEA::SYSTEM::COMMAND_VOCAB[command][0], command)
        @help_descriptions[command] = YEA::SYSTEM::COMMAND_VOCAB[command][3]
      when :volume_bgm, :volume_bgs, :volume_sfx
        add_command(YEA::SYSTEM::COMMAND_VOCAB[command][0], command)
        @help_descriptions[command] = YEA::SYSTEM::COMMAND_VOCAB[command][3]
      when :autodash, :instantmsg, :animations
        add_command(YEA::SYSTEM::COMMAND_VOCAB[command][0], command)
        @help_descriptions[command] = YEA::SYSTEM::COMMAND_VOCAB[command][3]
      when :to_title, :shutdown, :joystick, :fullscreen, :fullscreen2, :screensize
        add_command(YEA::SYSTEM::COMMAND_VOCAB[command][0], command)
        @help_descriptions[command] = YEA::SYSTEM::COMMAND_VOCAB[command][3]
      else
        process_custom_switch(command)
        process_custom_variable(command)
      end
    end
  end
  
  #--------------------------------------------------------------------------
  # process_custom_switch
  #--------------------------------------------------------------------------
  def process_custom_switch(command)
    return unless YEA::SYSTEM::CUSTOM_SWITCHES.include?(command)
    name = YEA::SYSTEM::CUSTOM_SWITCHES[command][1]
    add_command(name, :custom_switch, true, command)
    @help_descriptions[command] = YEA::SYSTEM::CUSTOM_SWITCHES[command][4]
  end
  
  #--------------------------------------------------------------------------
  # process_custom_variable
  #--------------------------------------------------------------------------
  def process_custom_variable(command)
    return unless YEA::SYSTEM::CUSTOM_VARIABLES.include?(command)
    name = YEA::SYSTEM::CUSTOM_VARIABLES[command][1]
    add_command(name, :custom_variable, true, command)
    @help_descriptions[command] = YEA::SYSTEM::CUSTOM_VARIABLES[command][6]
  end
  
  #--------------------------------------------------------------------------
  # draw_item
  #--------------------------------------------------------------------------
  def draw_item(index)
    reset_font_settings
    rect = item_rect(index)
    contents.clear_rect(rect)
    case @list[index][:symbol]
    when :window_red, :window_grn, :window_blu
      draw_window_tone(rect, index, @list[index][:symbol])
    when :volume_bgm, :volume_bgs, :volume_sfx
      draw_volume(rect, index, @list[index][:symbol])
    when :autodash, :instantmsg, :animations
      draw_toggle(rect, index, @list[index][:symbol])
    when :to_title, :shutdown, :joystick, :fullscreen, :fullscreen2, :screensize
      draw_text(item_rect_for_text(index), command_name(index), 1)
    when :custom_switch
      draw_custom_switch(rect, index, @list[index][:ext])
    when :custom_variable
      draw_custom_variable(rect, index, @list[index][:ext])
    end
  end
  
  #--------------------------------------------------------------------------
  # draw_window_tone
  #--------------------------------------------------------------------------
  def draw_window_tone(rect, index, symbol)
    name = @list[index][:name]
    draw_text(0, rect.y, contents.width/2, line_height, name, 1)
    #---
    dx = contents.width / 2
    tone = $game_system.window_tone
    case symbol
    when :window_red
      rate = (tone.red + 255.0) / 510.0
      colour1 = Color.new(128, 0, 0)
      colour2 = Color.new(255, 0, 0)
      value = tone.red.to_i
    when :window_grn
      rate = (tone.green + 255.0) / 510.0
      colour1 = Color.new(0, 128, 0)
      colour2 = Color.new(0, 255, 0)
      value = tone.green.to_i
    when :window_blu
      rate = (tone.blue + 255.0) / 510.0
      colour1 = Color.new(0, 0, 128)
      colour2 = Color.new(0, 0, 255)
      value = tone.blue.to_i
    end
    draw_gauge(dx, rect.y, contents.width - dx - 48, rate, colour1, colour2)
    draw_text(dx, rect.y, contents.width - dx - 48, line_height, value, 2)
  end
  
  #--------------------------------------------------------------------------
  # draw_volume
  #--------------------------------------------------------------------------
  def draw_volume(rect, index, symbol)
    name = @list[index][:name]
    draw_text(0, rect.y, contents.width/2, line_height, name, 1)
    #---
    dx = contents.width / 2
    case symbol
    when :volume_bgm
      rate = $game_system.volume(:bgm)
    when :volume_bgs
      rate = $game_system.volume(:bgs)
    when :volume_sfx
      rate = $game_system.volume(:sfx)
    end
    colour1 = text_color(YEA::SYSTEM::COMMAND_VOCAB[symbol][1])
    colour2 = text_color(YEA::SYSTEM::COMMAND_VOCAB[symbol][2])
    value = sprintf("%d%%", rate)
    rate *= 0.01
    draw_gauge(dx, rect.y, contents.width - dx - 48, rate, colour1, colour2)
    draw_text(dx, rect.y, contents.width - dx - 48, line_height, value, 2)
  end
  
  #--------------------------------------------------------------------------
  # draw_toggle
  #--------------------------------------------------------------------------
  def draw_toggle(rect, index, symbol)
    name = @list[index][:name]
    draw_text(0, rect.y, contents.width/2, line_height, name, 1)
    #---
    dx = contents.width / 2
    case symbol
    when :autodash
      enabled = $game_system.autodash?
    when :instantmsg
      enabled = $game_system.instantmsg?
    when :animations
      enabled = $game_system.animations?
    end
    dx = contents.width/2
    change_color(normal_color, !enabled)
    option1 = YEA::SYSTEM::COMMAND_VOCAB[symbol][1]
    draw_text(dx, rect.y, contents.width/4, line_height, option1, 1)
    dx += contents.width/4
    change_color(normal_color, enabled)
    option2 = YEA::SYSTEM::COMMAND_VOCAB[symbol][2]
    draw_text(dx, rect.y, contents.width/4, line_height, option2, 1)
  end
  
  #--------------------------------------------------------------------------
  # cursor_right
  #--------------------------------------------------------------------------
  def draw_custom_switch(rect, index, ext)
    name = @list[index][:name]
    draw_text(0, rect.y, contents.width/2, line_height, name, 1)
    #---
    dx = contents.width / 2
    enabled = $game_switches[YEA::SYSTEM::CUSTOM_SWITCHES[ext][0]]
    dx = contents.width/2
    change_color(normal_color, !enabled)
    option1 = YEA::SYSTEM::CUSTOM_SWITCHES[ext][2]
    draw_text(dx, rect.y, contents.width/4, line_height, option1, 1)
    dx += contents.width/4
    change_color(normal_color, enabled)
    option2 = YEA::SYSTEM::CUSTOM_SWITCHES[ext][3]
    draw_text(dx, rect.y, contents.width/4, line_height, option2, 1)
  end
  
  #--------------------------------------------------------------------------
  # draw_custom_variable
  #--------------------------------------------------------------------------
  def draw_custom_variable(rect, index, ext)
    name = @list[index][:name]
    draw_text(0, rect.y, contents.width/2, line_height, name, 1)
    #---
    dx = contents.width / 2
    value = $game_variables[YEA::SYSTEM::CUSTOM_VARIABLES[ext][0]]
    colour1 = text_color(YEA::SYSTEM::CUSTOM_VARIABLES[ext][2])
    colour2 = text_color(YEA::SYSTEM::CUSTOM_VARIABLES[ext][3])
    minimum = YEA::SYSTEM::CUSTOM_VARIABLES[ext][4]
    maximum = YEA::SYSTEM::CUSTOM_VARIABLES[ext][5]
    rate = (value - minimum).to_f / [(maximum - minimum).to_f, 0.01].max
    dx = contents.width/2
#~     draw_gauge(dx, rect.y, contents.width - dx - 48, rate, colour1, colour2)
    draw_text(dx+20, rect.y, contents.width - dx - 48, line_height, value, 1)
    end
  
  #--------------------------------------------------------------------------
  # cursor_right
  #--------------------------------------------------------------------------
  def cursor_right(wrap = false)
    cursor_change(:right)
    super(wrap)
  end
  
  #--------------------------------------------------------------------------
  # cursor_left
  #--------------------------------------------------------------------------
  def cursor_left(wrap = false)
    cursor_change(:left)
    super(wrap)
  end
  
  #--------------------------------------------------------------------------
  # cursor_change
  #--------------------------------------------------------------------------
  def cursor_change(direction)
    case current_symbol
    when :window_red, :window_blu, :window_grn
      change_window_tone(direction)
    when :volume_bgm, :volume_bgs, :volume_sfx
      change_volume(direction)
    when :autodash, :instantmsg, :animations
      change_toggle(direction)
    when :custom_switch
      change_custom_switch(direction)
    when :custom_variable
      change_custom_variables(direction)
    end
  end
  
  #--------------------------------------------------------------------------
  # change_window_tone
  #--------------------------------------------------------------------------
  def change_window_tone(direction)
    Sound.play_cursor
    value = direction == :left ? -1 : 1
    value *= 10 if Input.press?(:A)
    tone = $game_system.window_tone.clone
    case current_symbol
    when :window_red; tone.red += value
    when :window_grn; tone.green += value
    when :window_blu; tone.blue += value
    end
    $game_system.window_tone = tone
    draw_item(index)
  end
  
  #--------------------------------------------------------------------------
  # change_window_tone
  #--------------------------------------------------------------------------
  def change_volume(direction)
    Sound.play_cursor
    value = direction == :left ? -1 : 1
    value *= 10 if Input.press?(:A)
    case current_symbol
    when :volume_bgm
      $game_system.volume_change(:bgm, value)
      RPG::BGM::last.play
    when :volume_bgs
      $game_system.volume_change(:bgs, value)
      RPG::BGS::last.play
    when :volume_sfx
      $game_system.volume_change(:sfx, value)
    end
    draw_item(index)
  end
  
  #--------------------------------------------------------------------------
  # change_toggle
  #--------------------------------------------------------------------------
  def change_toggle(direction)
    value = direction == :left ? false : true
    case current_symbol
    when :autodash
      current_case = $game_system.autodash?
      $game_system.set_autodash(value)
    when :instantmsg
      current_case = $game_system.instantmsg?
      $game_system.set_instantmsg(value)
    when :animations
      current_case = $game_system.animations?
      $game_system.set_animations(value)
    end
    Sound.play_cursor if value != current_case
    draw_item(index)
  end
  
  #--------------------------------------------------------------------------
  # change_custom_switch
  #--------------------------------------------------------------------------
  def change_custom_switch(direction)
    value = direction == :left ? false : true
    ext = current_ext
    current_case = $game_switches[YEA::SYSTEM::CUSTOM_SWITCHES[ext][0]]
    $game_switches[YEA::SYSTEM::CUSTOM_SWITCHES[ext][0]] = value
    Sound.play_cursor if value != current_case
    draw_item(index)
  end
  
  #--------------------------------------------------------------------------
  # change_custom_variables
  #--------------------------------------------------------------------------
  def change_custom_variables(direction)
    Sound.play_cursor
    value = direction == :left ? -1 : 1
    value *= 10 if Input.press?(:A)
    ext = current_ext
    var = YEA::SYSTEM::CUSTOM_VARIABLES[ext][0]
    minimum = YEA::SYSTEM::CUSTOM_VARIABLES[ext][4]
    maximum = YEA::SYSTEM::CUSTOM_VARIABLES[ext][5]
    $game_variables[var] += value
    $game_variables[var] = [[$game_variables[var], minimum].max, maximum].min
    draw_item(index)
  end
  
end # Window_SystemOptions

#==============================================================================
# â–  Scene_Menu
#==============================================================================

class Scene_Menu < Scene_MenuBase
  
  #--------------------------------------------------------------------------
  # overwrite method: command_game_end
  #--------------------------------------------------------------------------
  def command_game_end
    SceneManager.call(Scene_System)
  end
  
end # Scene_Menu

#==============================================================================
# â–  Scene_System
#==============================================================================

class Scene_System < Scene_MenuBase
  
  #--------------------------------------------------------------------------
  # start
  #--------------------------------------------------------------------------
  def start
    super
    create_help_window
    create_command_window
  end
  
  #--------------------------------------------------------------------------
  # create_command_window
  #--------------------------------------------------------------------------
  def create_command_window
    @command_window = Window_SystemOptions.new(@help_window)
    @command_window.set_handler(:cancel, method(:return_scene))
    @command_window.set_handler(:to_title, method(:command_to_title))
    @command_window.set_handler(:shutdown, method(:command_shutdown))
    @command_window.set_handler(:joystick, method(:command_joystick))
    @command_window.set_handler(:fullscreen, method(:command_fullscreen))
    @command_window.set_handler(:fullscreen2, method(:command_fullscreen2))
    @command_window.set_handler(:screensize, method(:command_screensize))
    end
  
  #--------------------------------------------------------------------------
  # command_to_title
  #--------------------------------------------------------------------------
  def command_to_title
    fadeout_all
    SceneManager.goto(Scene_Title)
  end
  
  #--------------------------------------------------------------------------
  # command_shutdown
  #--------------------------------------------------------------------------
  def command_shutdown
    fadeout_all
    SceneManager.exit
  end
  
  #--------------------------------------------------------------------------
  # custom commands
  #--------------------------------------------------------------------------
  def command_joystick

  end
  
  def command_fullscreen
    Graphics.toggle_fullscreen
    SceneManager.return
    SceneManager.call(Scene_System)
  end
  
  def command_fullscreen2
    Graphics.toggle_vx_fullscreen
    SceneManager.return
    SceneManager.call(Scene_System)
  end
  
  def command_screensize
    Graphics.toggle_ratio
    SceneManager.return
    SceneManager.call(Scene_System)
    end
  
end # Scene_System

#==============================================================================
# 
# â–¼ End of File
# 
#==============================================================================

My custom commands are right at the end of the script. The problem is what to put in the command_joystick command so the Game properties window opens when you select it. If I could make the game think that the player has pressed F1, then that would work, I suppose.

Share this post


Link to post
Share on other sites

I made a proto script for input configuration window a few weeks ago, but  it was intended for custom gameplay and might require some changes for the default gameplay and second it uses an input script from Cidiomar R. Dias Junior you can find on tsukihime website

 

 

 


class Scene_Title < Scene_Base
  
  alias input_create_command_window create_command_window
  def create_command_window
    input_create_command_window
    @command_window.set_handler(:options, method(:command_input))
  end
  
  def command_input    
    SceneManager.call(Scene_Input)
  end
  
end


class Window_TitleCommand < Window_Command  
  
  alias input_make_command_list make_command_list
  def make_command_list
    input_make_command_list
    add_command("Controls", :options,false)
  end
  
end


class Scene_Input < Scene_Base
  
  def start
    super
    create_window
  end
  
  def create_window
    @window = Window_Input.new
    @window.set_handler(:ok, method(:on_input_ok))
    @window.set_handler(:cancel, method(:return_scene))
    @window.activate
  end
  
  def update
    super
    if @window.wait_for_input
      array=[]
      Input::KEYMAP.each_key{ |key| array.push(key)}
      triggered = array.find_all{ |key| 
      a=Input::KEYMAP[key]     
      Input.triggered[a] == true
      }
      if triggered.size == 1  
        Input.change_key(@window.key,triggered[0])
        @window.refresh
        @window.activate
        @wait_sprite.bitmap.clear
      end    
      
    end
  end
  
  def on_input_ok
    @window.wait_for_input = true
   
    
    @wait_sprite=Sprite.new unless @wait_sprite
    @wait_sprite.x=Graphics.width-25
    @wait_sprite.y=Graphics.height-25
    @wait_sprite.z=500
    @wait_sprite.bitmap=Bitmap.new(25,25)
    @wait_sprite.bitmap.fill_rect(0,0,25,25,Colors::Red)

  end
end

class Window_Input < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  attr_accessor :wait_for_input
  def initialize
    super(0,0,Graphics.width,Graphics.height)
    @data = []
    @index = 0
    refresh
    
  end
  #--------------------------------------------------------------------------
  # * Get Number of Items
  #--------------------------------------------------------------------------
  def item_max
    @data ? @data.size : 1
  end
  #--------------------------------------------------------------------------
  # * Get Item
  #--------------------------------------------------------------------------
  def key
    @data && index >= 0 ? @data[index] : nil
  end
  
  def update
    super #unless @wait_for_input  
  end
  
  #--------------------------------------------------------------------------
  # * Create Item List
  #--------------------------------------------------------------------------
  def make_item_list
    @data = [:UP,:DOWN,:LEFT,:RIGHT]
  end  
  #--------------------------------------------------------------------------
  # * Draw Item
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    if item
      rect = item_rect(index)     
      draw_text( rect, vocab(item),0)
      key=Input.sym_keys[item]
      text=key[0]
      draw_text(rect, Input::REVERSE_KEYMAP[text],2)
    end
  end 
  
  def vocab(item)
    case item
    when :UP
      return "move up"
    when :DOWN
      return "move down"
    when :LEFT
      return "move left"
    when :RIGHT
      return "move right"
    end
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    @wait_for_input = false
    make_item_list
    create_contents
    draw_all_items
  end
end

 


I can't promise anything but you can try to fiddle with it

Edited by Shiggy
  • Like 1

Share this post


Link to post
Share on other sites

Thanks :) I'll experiment a little. So far I've gotten the menu to work, although the button configurations only seem to affect menu scenes and not the map scene (I guess that's because of the custom gameplay thing you mentioned) and the configuration is reset every time you close the game. I'm not sure how I should go about making it joypad-compatible, either. Still, it's a start - thank you. At least I'll have something to work with.

 

By the way, I took your modified version of Cidiomar's script from this post; the original was a bit different and didn't work with your script.

Share this post


Link to post
Share on other sites

 

 

By the way, I took your modified version of Cidiomar's script from this post; the original was a bit different and didn't work with your script.

 

Lol I may have modified stuff I don't remember about 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted