Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

need help with this script [Resolved]

Ok firstly I edited this script from the original and took out the
Font Color, Sound test, Music test, Music Volume, Sound Volume, Bars
and added a minimap option to change which corner the minimap shows at:
@corner = [["Top Left", 1], ["Top Right", 2], ["Bottom Left", 3], ["Bottom Right", 4]]
But when i ran the script.. i got disappointed after hours of just fixing the script to show those options
on screen. For some reason when selecting either top left..etc it wouldn't change the position of the minimap.
So to see if the right number was being selected when i choose the command i inserted a print command here:
Code:
  def update_optionz

    case @option_window.index 

    when 0

      @help_window.update("Select a corner")

      @optionz_window.refresh(@option_window.index)

      if Input.trigger?(Input::C)

        corner = @option_window.options2

                

        print corner <--- line 469

        

        $scene = Scene_Option.new(0)

        $game_system.se_play($data_system.decision_se)

      end

    end

And to my disappointment when i ran the script to see if the number would show "1,2,3, or 4" it showed up as nil.. here's a screenie to show you
damn.png



here's the full code:

Code:
#===================================

#  Leon's Option Menu v2.0

#===================================

=begin

DESCRIPTION:

This is an option menu script that gives the user 8 options:

Font

Windowskin

Font Color

Sound test

Music test

Music Volume

Sound Volume

Bars

 

CREDITS:  

I credit SephirothSpawn for the draw_bars.  I learned from his tutoral, so every time I

use the bar designs, I credit him.  Also, thanks to Jabicho and italianstal1ion for feature ideas.

 

Features:

8 options (listed above)

 

INSTRUCTIONS:

You can make them so they have to be unlocked through events.  To add

these through events, use:

For Fonts:

$game_party.font_name.push(["Then name as it will appear in the game", "The font's real name"])

 

Windowskins:

$game_party.window_skin.push(["As it appears in the game", "True Name"])

 

Sound Test

$game_party.sound_effect.push(["Name as it appears", "true name", pitch])

 

Music Test:

$game_party.music.push(["Name as it appears in the game", "True_Name", pitch])

 

=end

 

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#  Game_System

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

class Game_System

  

  alias leon_gamesystem_optionmenu_initialize initialize

  

  

  def update  

    if Kboard.keyboard($R_Key_1)

      $scene = Scene_Option.new

      return

    end

  end

  

  

  

  def initialize

    leon_gamesystem_optionmenu_initialize

    

  end

  

  

  

  

end

 

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#  Game_Party

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

class Game_Party

  

  attr_accessor    :font_name

  attr_accessor    :window_skin

  attr_accessor    :corner

  attr_accessor    :minimap

  

  alias leon_gp_option_initialize initialize

  

  def initialize

    leon_gp_option_initialize

    

    #[Printed Name, real name], etc

    @font_name = [["Tahoma", "Tahoma"], ["Arial", "Arial"], ["Monotype Corsiva", "Monotype Corsiva"]

    ]

    @window_skin = [

    ["ffx 2", "ffx 2"], ["plainpearl_blue", "plainpearl_blue"],

    ["window_gris-cursor", "window_gris-cursor"], ["Windowskin-003-handcursor_bw", "Windowskin-003-handcursor_bw"]

    ]

    @minimap = [["Display", corner]]

    @corner = [["Top Left", 1], ["Top Right", 2], ["Bottom Left", 3], ["Bottom Right", 4]]

    

    

    

  end

end

 

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#  Window_Base

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

#----------------------------------------------------------------------

#  Window_Optionhelp

#----------------------------------------------------------------------

class Window_Optionhelp < Window_Base

  def initialize

    super(0, 0, 640, 64)

    self.contents = Bitmap.new(width - 32, height - 32)

    self.contents.font.name = $defaultfonttype

    self.contents.font.size = $defaultfontsize

  end

  

  def update(option_help)

    self.contents.clear

    self.contents.draw_text(0, 0, 618, 32, option_help)

  end

end

 

#----------------------------------------------------------------------

#  Window_Optionmenu

#----------------------------------------------------------------------

class Window_Optionmenu < Window_Selectable

  def initialize

    super(0, 64, 180, 320)

    @commands = [ "MiniMap", "Font", "Window Skin"]

    

    @item_max = @commands.size

    self.contents = Bitmap.new(width - 32, height - 32)

    self.contents.font.name = $defaultfonttype

    self.contents.font.size = $defaultfontsize

    self.index = 0

    refresh

  end

  

  def refresh

    self.contents.clear

    for i in [email=0...@commands.size]0...@commands.size[/email]

      x = 4

      y = i * 32

      self.contents.draw_text(x, y, 148, 32, @commands[i])

    end

  end

  

  def update_cursor_rect

    y = index * 32

    self.cursor_rect.set(0, y, self.width - 32, 32)

  end

  

end

 

#----------------------------------------------------------------------

#  Window_Optionextend

#----------------------------------------------------------------------

class Window_Optionextend < Window_Selectable

  def initialize(option_index)

    super(180, 64, 150, 64)

    @option_index = option_index

    self.contents = Bitmap.new(width - 32, height - 32)

    self.contents.font.name = $defaultfonttype

    self.contents.font.size = $defaultfontsize

    self.active = false

    self.visible = false

    self.index = -1

  end

  

  def options

    if @data != nil

      return @data[index]

    end

  end

  

  def options2

    if @data1 != nil

      return @data1[index]

    end

  end

  

  def options3

    if @data2 != nil

      return @data2[index]

    end

  end

  

  def refresh(option_index)

    if self.contents != nil

      self.contents.dispose

      self.contents = nil

    end

    @data = []

    @data1 = []

    @data2 = []

    case option_index

    when 0

      self.width = 180

      self.height = $game_party.minimap.size * 32 + 32

      @column_max = 1

      for i in 0...$game_party.minimap.size

        @data.push($game_party.minimap[i][0])

        @data1.push($game_party.minimap[i][1])

      end

    when 1

      self.width = 180

      self.height = $game_party.font_name.size * 32 + 32

      @column_max = 1

      for i in 0...$game_party.font_name.size

        @data.push($game_party.font_name[i][0])

        @data1.push($game_party.font_name[i][1])

      end

    when 2

      self.width = 180

      self.height = $game_party.window_skin.size * 32 + 32

      @column_max = 1

      for i in 0...$game_party.window_skin.size

        @data.push($game_party.window_skin[i][0])

        @data1.push($game_party.window_skin[i][1])

      end

    

      

    end

    @item_max = @data.size

    if @item_max > 0

      self.contents = Bitmap.new(width - 32, row_max * 32)

      self.contents.font.name = $defaultfonttype

      self.contents.font.size = $defaultfontsize

      for i in 0...@item_max

        draw_item(i, option_index)

      end

    end

  end

  

  def draw_item(index, option_index)

    option = @data[index]

    case option_index

    when 0

      x = 4

      y = index * 32

    when 1

      x = 4

      y = index * 32

    when 2

      x = 4 + (index % 2) * (self.width /  2)

      y = index / 2 * 32

    when 3

      x = 4 + (index % 2) * (self.width /  2)

      y = index / 2 * 32

    end

    self.contents.draw_text(x, y, 140, 32, option)

  end

end

 

#----------------------------------------------------------------------

#  Window_Optionextendd

#----------------------------------------------------------------------

class Window_Optionextendd < Window_Selectable

  def initialize(option_index)

    super(360, 64, 150, 64)

    @option_index = option_index

    self.contents = Bitmap.new(width - 32, height - 32)

    self.contents.font.name = $defaultfonttype

    self.contents.font.size = $defaultfontsize

    self.active = false

    self.visible = false

    self.index = -1

  end

  

  def options

    if @data != nil

      return @data[index]

    end

  end

  

  def options2

    if @data1 != nil

      return @data1[index]

    end

  end

  

  def options3

    if @data2 != nil

      return @data2[index]

    end

  end

  

  def refresh(option_index)

    if self.contents != nil

      self.contents.dispose

      self.contents = nil

    end

    @data = []

    @data1 = []

    @data2 = []

    case option_index

    when 0

      self.width = 180

      self.height = $game_party.corner.size * 32 + 32

      @column_max = 1

      for i in 0...$game_party.corner.size

        @data.push($game_party.corner[i][0])

        @data1.push($game_party.corner[i][1])

        @data2.push($game_party.corner[i][2])

      end

    end

    @item_max = @data.size

    if @item_max > 0

      self.contents = Bitmap.new(width - 32, row_max * 32)

      self.contents.font.name = $defaultfonttype

      self.contents.font.size = $defaultfontsize

      for i in 0...@item_max

        draw_item(i, option_index)

      end

    end

  end

  

  def draw_item(index, option_index)

    option = @data[index]

    case option_index

    when 0

      x = 4

      y = index * 32

    when 1

      x = 4

      y = index * 32

    when 2

      x = 4 + (index % 2) * (self.width /  2)

      y = index / 2 * 32

    when 3

      x = 4 + (index % 2) * (self.width /  2)

      y = index / 2 * 32

    end

    self.contents.draw_text(x, y, 140, 32, option)

  end

end

 

 

 

#----------------------------------------------------------------------

#  Scene_Option

#----------------------------------------------------------------------

class Scene_Option

  def initialize(menu_index = 0)

    @menu_index = menu_index

  end

  

  def main

    @help_window = Window_Optionhelp.new

    @menu_window = Window_Optionmenu.new

    @option_window = Window_Optionextend.new(@menu_window.index)

    @optionz_window = Window_Optionextendd.new(@option_window.index)

    

    @menu_window.index = @menu_index

    

    Graphics.transition

    loop do

      Graphics.update

      Input.update

      update

      if $scene != self

        break

      end

    end

    Graphics.freeze

    

    @help_window.dispose

    @menu_window.dispose

    @option_window.dispose

    @optionz_window.dispose

    

  end

  

  def update

    @help_window.update("Select an option")

    @menu_window.update

    @option_window.update

    @optionz_window.update

    

    if @menu_window.active

      update_menu

      return

    end

    

    if @option_window.active

      update_option

      return

    end

    

    if @optionz_window.active

      update_optionz

      return

    end

    

  end

  

  def update_menu

    @help_window.update("Select an option")

    if @menu_window.index < 4

      if Input.trigger?(Input::C)

        $game_system.se_play($data_system.decision_se)

        @option_window.refresh(@menu_window.index)

        @menu_window.active = false

        @option_window.visible = true

        @option_window.active = true

        @optionz_window.visible = false

        @optionz_window.active = false

        @option_window.index = 0

        @optionz_window.index = 0

        

      end

    

    end

    

    

    if Input.trigger?(Input::B)

      $game_system.se_play($data_system.cancel_se)

      $scene = Scene_Map.new

    end

  end

  

  def update_option

    case @menu_window.index

    when 0

      @help_window.update("MiniMap.")

      if Input.trigger?(Input::C)

        $game_system.se_play($data_system.decision_se)

        @option_window.refresh(@menu_window.index)

        @menu_window.active = false

        @option_window.visible = true

        @option_window.active = false

        @optionz_window.visible = true

        @optionz_window.active = true

        @option_window.index = 0

        @optionz_window.index = 0

      end

    when 1

      @help_window.update("Select a font.")

      if Input.trigger?(Input::C)

        $defaultfonttype = @option_window.options2

        $scene = Scene_Option.new(0)

        $game_system.se_play($data_system.decision_se)

      end

    when 2

      @help_window.update("Select a window skin.")

      if Input.trigger?(Input::C)

        $game_system.windowskin_name = @option_window.options2

        $scene = Scene_Option.new(1)

        $game_system.se_play($data_system.decision_se)

      end

    

    end

 

    if Input.trigger?(Input::B)

      $game_system.bgm_play($game_system.bgm_memorize)

      @menu_window.active = true

      @option_window.active = false

      @option_window.visible = false

      @optionz_window.active = false

      @optionz_window.visible = false

      @option_window.index = -1

      @optionz_window.index = 0

    end

  end

  

  def update_optionz

    case @option_window.index 

    when 0

      @help_window.update("Select a corner")

      @optionz_window.refresh(@option_window.index)

      if Input.trigger?(Input::C)

        corner = @option_window.options2

                

        print corner

        

        $scene = Scene_Option.new(0)

        $game_system.se_play($data_system.decision_se)

      end

    end

    

 

    if Input.trigger?(Input::B)

      $game_system.bgm_play($game_system.bgm_memorize)

      @menu_window.active = false

      @option_window.active = true

      @option_window.visible = true

      @optionz_window.visible = false

      @optionz_window.active = false

      @option_window.index = 0

      @optionz_window.index = -1

    end

  end

end

class Scene_Save < Scene_File

  alias write_save_data_leon_font write_save_data

  def write_save_data(file)

    write_save_data_leon_font(file)

    Marshal.dump([$defaultfonttype, $defaultfontsize], file)

  end

end

class Scene_Load < Scene_File

  alias read_save_data_leon_font read_save_data

  def read_save_data(file)

    read_save_data_leon_font(file)

    font_array = Marshal.load(file)

    $defaultfonttype, $defaultfontsize = font_array[0], font_array[1]

  end

end

Any help would be greatly appreciated :blank: if you need anymore info just ask

hmm... amazing what 10 min of a break can do.. I fixed the problem.

changed this:
Code:
  def update_optionz

    case @option_window.index 

    when 0

      @help_window.update("Select a corner")

      @optionz_window.refresh(@option_window.index)

      if Input.trigger?(Input::C)

        corner = @option_window.options2

                

        print corner <--- line 469

        

        $scene = Scene_Option.new(0)

        $game_system.se_play($data_system.decision_se)

      end

    end


To this:
Code:
def update_optionz

    case @option_window.index 

    when 0

      @help_window.update("Select a corner")

      @optionz_window.refresh(@option_window.index)

      if Input.trigger?(Input::C)

        if @optionz_window.index == 0

          $game_party.corner = 1

          $game_system.se_play($data_system.decision_se)

        elsif @optionz_window.index == 1

          $game_party.corner = 2

          $game_system.se_play($data_system.decision_se)

        elsif @optionz_window.index == 2

          $game_party.corner = 3

          $game_system.se_play($data_system.decision_se)

        elsif @optionz_window.index == 3

          $game_party.corner = 4

          $game_system.se_play($data_system.decision_se)

        end

        

        

      print $game_party.corner

        $scene = Scene_Option.new(0)

        

      end

    end
 
Two things I can find
In "def update_optionz", on the line where you assign the corner (467) you used "corner = @option_window.options2" instead of "corner = @optionz_window.options2"

Then on line 89
[rgss]@minimap = [["Display", corner]]
@corner = [["Top Left", 1], ["Top Right", 2], ["Bottom Left", 3], ["Bottom Right", 4]]
[/rgss]
should be
[rgss]@corner = [["Top Left", 1], ["Top Right", 2], ["Bottom Left", 3], ["Bottom Right", 4]]
@minimap = [["Display", corner]]
[/rgss]
Initializing @corner seems to need to go first.
"corner" might also be better as "@corner", but I don't know for sure.
 
Thx for the info BwdYeti but i got it working though had to change a couple more things.. so i wouldn't get a size error.

changed this:
Code:
 @corner = [["Top Left", 1], ["Top Right", 2], ["Bottom Left", 3], ["Bottom Right", 4]]

to this:
Code:
@minicorner = [["Top Left", 1], ["Top Right", 2], ["Bottom Left", 3], ["Bottom Right", 4]]
added these above that
Code:
attr_accessor    :minicorner
Code:
@corner = 1

changed this:
Code:
when 0

       self.width = 180

       self.height = $game_party.corner.size * 32 + 32

       @column_max = 1

       for i in 0...$game_party.corner.size

         @data.push($game_party.corner[i][0])

         @data1.push($game_party.corner[i][1])

         @data2.push($game_party.corner[i][2])

       end

     end
to this:
Code:
when 0

      self.width = 180

      self.height = $game_party.minicorner.size * 32 + 32

      @column_max = 1

      for i in 0...$game_party.minicorner.size

        @data.push($game_party.minicorner[i][0])

        @data1.push($game_party.minicorner[i][1])

        @data2.push($game_party.minicorner[i][2])

      end

    end
and now it works and all i got left to put in this menu now is a full screen option :biggrin:
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top