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.

List Division Script

Let's see... I'm looking for one of two things: Either a script that allows someone to create conditional branches in a 'choices' panel, (Ie. Showing an item in a selectable list only if you have it, or if a switch is on, monster encountered, etc.) -OR- a script that will do that sort of thing for you; very much like a beastiery... but with something other than monsters, like items or switches.

If someone comes up with something else, my major reason for this is my jukebox system: Throughout the game you'll be able to find, buy, win, and in some cases steal Albums (items). Back at your home is a jukebox - you can insert any album you have (I need the script so that an album will only appear in the 'insert?' selection if you have it... it would take an enormous chain of conditional branches to do it otherwise) or you can listen to any albums you've previously inserted. (I need the script here so that an album will only show up in the list if you've inserted it, based on a switch being off or on)


If there are any questions, don't hesitate to ask. Anyone who solves this will recieve full credit.
 
Uh why dont you just use a conditional branch before the choice and have it so if a switch or something is turned on that it shows one set of choices, and in the else section of the conditional branch have it with the other set?
 
That's what I initially said, and this can be done, however it creates an ENORMOUS chain of conditional branches that
1) Put a lot of pressure on the game engine, and
2) Are an enormous pain in the ass to create

For instance, say my game onlly had 5 albums. The condition branch system would first make a choice whether you have Album 1 in the machine or not. Then on both the 'yes' and 'no' variables, you would have branches for album 2. In each of those 4 you'd have the conditions for Album 3. That's 8 so far. In all those 8, you'd need a branch for Album 4. 16. In each of THOSE you'd have a final branch for Album 5, leaving you with 32 different selections to sort through and create depending on what's in. Now try doing that sort of system with twenty-five albums. Needless to say, that's a LOT of conditional branches. And that's just the play feature - you have to do ANOTHER, equally-large system for inserting albums.

I used that sort of system in the first shop, which has an inventory that changes depending whether you've found various items or not. I only did 3 or 4 variations and ended up with over 250, maybe 300 lines of event processing.

What I'm looking for more precisely is... some sort of script that will define whether a selection should appear in a choices panel based on a switch, item, variable, or monster. Say we use switches - if the switch is on, the selection will show up with whatever others are in the list. If it is off, then it wil be removed from the list and any below it will be moved up to take its place.

Soo... this isn't to make something simply possible... just to make it less impossible. :) Thanks for the support though, gorechild.
 

OS

Sponsor

Dude. If you know anything about scripting then you should look at the Window_Item class. To be honest, this is a very simple script. I'll make it real quick.

Here it is:
Code:
#==============================================================================
# ** Window_Album
#------------------------------------------------------------------------------
#  This window displays albums that the player has.
#==============================================================================
ALBUMS = [1,2,3,4,5]
class Window_Album < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 64, 640, 416)
    @column_max = 2
    @albums = ALBUMS
    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 item
    for i in 0..@albums.size - 1
      if $game_party.item_number(i) > 0
        @data.push($data_items[i])
      end
    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]
    case item
    when RPG::Item
      number = $game_party.item_number(item.id)
    when RPG::Weapon
      number = $game_party.weapon_number(item.id)
    when RPG::Armor
      number = $game_party.armor_number(item.id)
    end
    if item.is_a?(RPG::Item) and
       $game_party.item_can_use?(item.id)
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = 4 + index % 2 * (288 + 32)
    y = index / 2 * 32
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(item.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
    self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
    self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  end
  #--------------------------------------------------------------------------
  # * Help Text Update
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(self.item == nil ? "" : self.item.description)
  end
end

This is the Window. I didn't make the Scene. You'll have to find someone else to do that, or try yourself. Hope this is helpful.

~OS
 
Please - I need either some instructions as to what this is or does, the rest of the script, or whatever is needed... without this, I'm going to need 2 event chains, each with over a million exits just to accomodate my 20 albums.

As before - any help would be GREATLY appreciated. ;/
 

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