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.

menu add-on, simular to item screen.(xp)

i am making an acheivement system(for xp) and i wanted a menu item like the item screen, only it would contain all of the possible acheivements.

ok that doesnt make scense does it? what i want is when i click acheivements on my menu(i have allready added this) it goes to a screen that is just like the Scene_Item only it contains my acheivements, i want them all to show at the beginning and the color changes when u unlock them. aka red to start and green when u unlock them, it would also be amazing if you could click on one and see how to get it(a short description).


xm4t3c.jpg

rw76dg.jpg

like the second image only with out the quantity.
thanks :)

p.s did i forget anything?
 
nope, it just means be patient. this should be a pretty easy edit of the item scene, with a structure for the achievements.

It would also be an easy edit to any one of the many Journal / Quest systems out there. (Have you looked at them?)

I don't have time for this right now, but if no one jumps on it, I'll do it for you.

Be Well
 
Ok, I wanted to test out Seph's Data structure classes...

Paste the following 3 scripts above Main...

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

# ** Window_Goals

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

#  This window displays goals.

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

 

class Window_Goals < Window_Selectable

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

  # * Object Initialization

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

  def initialize

    super(0, 64, 640, 416)

    @column_max = 2

    refresh

    self.index = 0

  end

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

  # * Get Item

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

  def item

    return @data[self.index]

  end

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

  # * Refresh

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

  def refresh

    if self.contents != nil

      self.contents.dispose

      self.contents = nil

    end

    @data = []

    # Add goals

    for i in 1...$data_goals.size

        @data.push($data_goals[i])

    end

    # If item count is not 0, make a bit map and draw all items

    @item_max = @data.size

    if @item_max > 0

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

      for i in 0...@item_max

        draw_item(i)

      end

    end

  end

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

  # * Draw Item

  #     index : item number

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

  def draw_item(index)

    item = @data[index]

    if $game_system.goal_status[item.id]

      self.contents.font.color = Color.new(64, 255, 64)

    else

      self.contents.font.color = Color.new(255, 64, 64)

    end

    x = 4 + index % 2 * (288 + 32)

    y = index / 2 * 32

    self.contents.draw_text(x, y, 212, 32, item.name, 0)

  end

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

  # * Help Text Update

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

  def update_help

    @help_window.set_text(self.item == nil ? "" : self.item.desc)

  end

end

 

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

# ** Scene_Goals

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

#  This class performs goal screen processing.

#  To return to your menu with a specific index, edit the (0) in line 61

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

 

class Scene_Goals

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

  # * Main Processing

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

  def main

    # Make help window, item window

    @help_window = Window_Help.new

    @item_window = Window_Goals.new

    # Associate help window

    @item_window.help_window = @help_window

    # 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

    @help_window.dispose

    @item_window.dispose

  end

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

  # * Frame Update

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

  def update

    # Update windows

    @help_window.update

    @item_window.update

    # If item window is active: call update_item

    if @item_window.active

      update_item

      return

    end

  end

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

  # * Frame Update (when item window is active)

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

  def update_item

    # 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(0)

      return

    end

  end

end

 

RPG::Goals
Code:
 #==============================================================================

# ** RPG::Goal   10Feb09 - Brew

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

#  This is the data structure to hold the goals.

#

#  Enter your goals starting on line 62

#

#  To set a goal to active, use:

#

#    $game_system.goal_status[x] = true

#

#    where x is the goal id (number)

#

#  This will also save your Goal structure to Data\Goals.rxdata

#  On line 54, set the if statement to false once you have a stable

#  data structure. (it's not going to change.)

#  If you need to add / change goals, set it back to true & play test once,

#  then set it back to false. Set it to false when you release your game.

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

 

# we put the goal statuses in game_system so they get saved & loaded

class Game_System

  alias goal_init initialize

  attr_accessor :goal_status

  def initialize

    goal_init

    @goal_status = []

    @goal_status[0] = nil

    for i in 1..$data_goals.size

      @goal_status[i] = false

    end

  end

end

 

RPG::Goal = Struct.new(:name, :desc)

 

class RPG::Goal

  attr_accessor :id

  alias_method :goal_init, :initialize

  def initialize(*struct_args)

    # Calls our struct initialize method

    goal_init(*struct_args)

    # Set @id to be the size of our $data_treasures list

    @id = $data_goals.size

    @active = false

    # Put our object automatically into the list

    $data_goals[@id] = self

  end

end

 

# Make this true if no rxdata file exist or if you have changed anything between

# this line and the save_data line. Make sure you change 'true' to 'false' when 

# you release your game.

if true

 

  $data_goals = [nil]

 

####################################################

# This is where you add you goal objects.

####################################################

 

  RPG::Goal.new('Get Chicken', 'Try looking at a farm')

  RPG::Goal.new('goal 2', 'desc 2')

  RPG::Goal.new('goal 3', 'desc 3')

  RPG::Goal.new('goal 4', 'desc 4')

 

####################################################

  # This saves our data into a rxdata file called "Goals.rxdata"

  save_data($data_goals, "Data/Goals.rxdata")

 

# If we have not modified the list above and Goals.rxdata exist

else

  # Load our data like our default data objects in Scene_Title

  $data_goals = [nil]

  $data_goals = load_data("Data/Goals.rxdata")

end

 


Instructions are at the top of the scripts

To call this from your menu:

$scene = Scene_Goals.new
 
oh wow, i freaking love you brew thanks again for like the ka-millionth time!!!!!

edit: i do have one question when you are saying you want me to set it to false when im done do you mean thisl ine?
$data_goals = [nil]

edit2: now that i re-read your note, i think you meant the "if" line
so did you mean change "if true" to "If false"
 
Nope, the line above it

if true

just change 'true' to 'false' and it will read the rxdata file. But, you have to set it to true to save the rxdata file, so anytime you change the contents of the data, you need to set it back to true to resave the rxdata file.
Also, any time you add / change the data, your old savefiles won't work because the goal data won't match.
You can leave it on true when you're developing, but it will save the rxdata file everytime.

dig?
 

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