Help - Search - Members - Calendar
Full Version: Collectables Menu
RPG RPG Revolution Forums > Scripting > Script Development and Support > RGSS2
jet10985
Collectable's Menu
By Jet


Introduction


Hello my people. Thought I'd just throw this thing out there and all. It was a quick script but i figured it's more useful than a snippet so, here it is. It's a menu for specific items you can specify as "collectable", Nifty eh? No? I don't think so either xD

Screenshot



Features

- A whole new scene
- Keeps collectables out of the item's menu
- Built-in optional menu option
- Easy to use
- Have no access to the menu to have hidden items
- And more...

Script

Script Here

Credit

Jet10985/Jet
Samurai Kadaj
I, for one, think it's nifty. No RPG is complete without a host of hidden collectables. This could also be used to keep story-related key items seperate from the regular inventory thumbsup.gif
dracoseeker1
QUOTE (Samurai Kadaj @ Jul 5 2011, 02:48 PM) *
I, for one, think it's nifty. No RPG is complete without a host of hidden collectables. This could also be used to keep story-related key items seperate from the regular inventory thumbsup.gif


i agree. that is a great idea. I would either use it for that or to keep medals from my hunt system. Either way, great work, dude
domjarre
I keep getting an error when I try to access the item window.

Script 'Collectables' line 80: NoMethodError occured.
undefined method `collectable?' for nil:NilClass

The collectable window works fine and my collectable items show in there, but I get the error when I click on the regular item window.
meta-blade
QUOTE (domjarre @ Sep 14 2011, 03:28 PM) *
I keep getting an error when I try to access the item window.

Script 'Collectables' line 80: NoMethodError occured.
undefined method `collectable?' for nil:NilClass

The collectable window works fine and my collectable items show in there, but I get the error when I click on the regular item window.


I get exactly the same problem pinch.gif
Rakasch
I had the same problem, plus the script put EVERY item in the new page.
I don't know Ruby, but since I learned Java a few years ago I found some errors and corrected them.
Works for me now :)

here's the edited code

#===============================================================================
# Collectables Menu
# By Jet10985 (Jet)
# Some code by: Woratana
#===============================================================================
# This script will allow you to specify items to be "collectable".
# These items will not show up in the Items menu, and will only be shown
# in the Collectables menu.
# This script has: 3 customization option.
#===============================================================================
# Overwritten Methods:
# None
#-------------------------------------------------------------------------------
# Aliased methods:
# Window_Item: include?
# Scene_Menu: create_command_window, update_command_window,
# update_actor_selection
# Window_Command: initialize, draw_item
#===============================================================================
=begin
How to make an item collectable:

to make an item be considered as "collectable", place this in the item's notebox

<collectable>
--------------------------------------------------------------------------------
How to call the collectable menu:

if you choose not to have this as a menu option, you can call the collectables
menu with this code in an event "Script..." command:

$scene = Scene_Collectable.new
=end

module JetCollectableScene

# Do you want the collectables menu to be accessed by the menu?
# Put false if you have some sort of custom menu option thing.
USE_MENU_OPTION = true

# If the baove is true, what is the menu option called?
COLLECTABLE_MENU_OPTION_NAME = "Quest Items"

# What index will the option have in the menu?
COLLECTABLE_MENU_INDEX = 1

end

#===============================================================================
# DON'T EDIT FURTHER UNLESS YOU KNOW WHAT TO DO.
#===============================================================================
module Jet

def self.check_note_tags(obj, tag)
obj.note.each_line { |notetag|
if notetag.chomp.eql? tag
return true
end
}
return false
end
end

class RPG::BaseItem

def collectable?
if @collectable.nil?
txt = Jet.check_note_tags(self, '<collectable>')
@collectable = txt.nil? ? false : txt
end
return @collectable
end
end

class Window_Item

alias jet6547_include? include? unless $@
def include?(item)
return false if item == nil
return false if item.collectable?
jet6547_include?(item)
end
end

class Window_Collectable < Window_Item

def initialize(x, y, width, height)
super(x, y, width, height)
end

def include?(item)
return false if item == nil
return false unless item.collectable?
return true
end

def enable?(item)
return true
end

def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
item = @data[index]
if item != nil
enabled = enable?(item)
rect.width -= 4
draw_item_name(item, rect.x, rect.y, enabled)
end
end
end

class Scene_Collectable < Scene_Base

include JetCollectableScene

def initialize
@came_from = $scene.class.to_s
end

def start
super
create_menu_background
@help_window = Window_Help.new
@relic_window = Window_Collectable.new(0, 56, 544, 360)
@relic_window.help_window = @help_window
end

def terminate
super
dispose_menu_background
@help_window.dispose
@relic_window.dispose
end

def dummy_method
end

def update
super
update_menu_background
@help_window.update
@relic_window.update
if Input.trigger?(Input::B)
Sound.play_cancel
eval("$scene = #{@came_from}.new(
#{@came_from == "Scene_Menu" ? COLLECTABLE_MENU_INDEX.to_s : dummy_method})")
end
end
end

if JetCollectableScene::USE_MENU_OPTION
class Window_Command < Window_Selectable
alias jet4569_initialize initialize unless $@
alias jet9374_draw_item draw_item unless $@

def initialize(*args)
@disabled_commands = []
jet4569_initialize(*args)
end

def draw_item(*args)
jet9374_draw_item(*args)
@disabled_commands[args[0]] = args[1].nil? || args[1] ? nil : true
end

def ins_command(index, text)
@commands.insert(index, text)
@disabled_commands.insert(index, nil)
old_disabled_commands = @disabled_commands.dup
self.height = (@commands.size + @column_max - 1) / @column_max * WLH + 32
@item_max = @commands.size
create_contents
refresh
old_disabled_commands.each_index do |i|
if !old_disabled_commands[i].nil?
draw_item(i, false)
end
end
end

def add_command(text)
ins_command(@commands.size, text)
end
end

class Scene_Menu < Scene_Base

include JetCollectableScene

def sort_newcommand
@sorted_command ||= []
newcommand = @newcommand - @sorted_command
newcommand.sort.each {|i| @menu_index += 1 if @menu_index >= i }
@command_window.index = @menu_index
@sorted_command = @sorted_command + @newcommand
end

alias jet6993_create_command_window create_command_window unless $@
def create_command_window(*args)
jet6993_create_command_window(*args)
@command_window.ins_command(COLLECTABLE_MENU_INDEX,
COLLECTABLE_MENU_OPTION_NAME)
@newcommand ||= []
@newcommand << COLLECTABLE_MENU_INDEX
sort_newcommand
end

alias jet3943_update_command_selection update_command_selection unless $@
def update_command_selection(*args)
@menucomorpg_change = false
if Input.trigger?(Input::C) && @command_window.index ==
COLLECTABLE_MENU_INDEX
Sound.play_decision
$scene = Scene_Collectable.new
else
if Input.trigger?(Input::C) && @command_window.index >
COLLECTABLE_MENU_INDEX
@command_window.index -= 1
@menucomorpg_change = true
end
jet3943_update_command_selection(*args)
end
@command_window.index += 1 if @menucomorpg_change
end

alias jet3446_update_actor_selection update_actor_selection unless $@
def update_actor_selection(*args)
@menucomorpg_change = false
if Input.trigger?(Input::C) && @command_window.index >
COLLECTABLE_MENU_INDEX
@command_window.index -= 1
@menucomorpg_change = true
end
jet3446_update_actor_selection(*args)
@command_window.index += 1 if @menucomorpg_change
end
end
end

unless $engine_scripts.nil?
$engine_scripts["Collectable Menu"] = 1
end

for those interested, I marked the changes in red font.
grullborg
QUOTE (Rakasch @ Sep 21 2011, 09:36 PM) *
I had the same problem, plus the script put EVERY item in the new page.
I don't know Ruby, but since I learned Java a few years ago I found some errors and corrected them.
Works for me now smile.gif

here's the edited code

#===============================================================================
# Collectables Menu
# By Jet10985 (Jet)
# Some code by: Woratana
#===============================================================================
# This script will allow you to specify items to be "collectable".
# These items will not show up in the Items menu, and will only be shown
# in the Collectables menu.
# This script has: 3 customization option.
#===============================================================================
# Overwritten Methods:
# None
#-------------------------------------------------------------------------------
# Aliased methods:
# Window_Item: include?
# Scene_Menu: create_command_window, update_command_window,
# update_actor_selection
# Window_Command: initialize, draw_item
#===============================================================================
=begin
How to make an item collectable:

to make an item be considered as "collectable", place this in the item's notebox

<collectable>
--------------------------------------------------------------------------------
How to call the collectable menu:

if you choose not to have this as a menu option, you can call the collectables
menu with this code in an event "Script..." command:

$scene = Scene_Collectable.new
=end

module JetCollectableScene

# Do you want the collectables menu to be accessed by the menu?
# Put false if you have some sort of custom menu option thing.
USE_MENU_OPTION = true

# If the baove is true, what is the menu option called?
COLLECTABLE_MENU_OPTION_NAME = "Quest Items"

# What index will the option have in the menu?
COLLECTABLE_MENU_INDEX = 1

end

#===============================================================================
# DON'T EDIT FURTHER UNLESS YOU KNOW WHAT TO DO.
#===============================================================================
module Jet

def self.check_note_tags(obj, tag)
obj.note.each_line { |notetag|
if notetag.chomp.eql? tag
return true
end
}
return false
end
end

class RPG::BaseItem

def collectable?
if @collectable.nil?
txt = Jet.check_note_tags(self, '<collectable>')
@collectable = txt.nil? ? false : txt
end
return @collectable
end
end

class Window_Item

alias jet6547_include? include? unless $@
def include?(item)
return false if item == nil
return false if item.collectable?
jet6547_include?(item)
end
end

class Window_Collectable < Window_Item

def initialize(x, y, width, height)
super(x, y, width, height)
end

def include?(item)
return false if item == nil
return false unless item.collectable?
return true
end

def enable?(item)
return true
end

def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
item = @data[index]
if item != nil
enabled = enable?(item)
rect.width -= 4
draw_item_name(item, rect.x, rect.y, enabled)
end
end
end

class Scene_Collectable < Scene_Base

include JetCollectableScene

def initialize
@came_from = $scene.class.to_s
end

def start
super
create_menu_background
@help_window = Window_Help.new
@relic_window = Window_Collectable.new(0, 56, 544, 360)
@relic_window.help_window = @help_window
end

def terminate
super
dispose_menu_background
@help_window.dispose
@relic_window.dispose
end

def dummy_method
end

def update
super
update_menu_background
@help_window.update
@relic_window.update
if Input.trigger?(Input::cool.gif
Sound.play_cancel
eval("$scene = #{@came_from}.new(
#{@came_from == "Scene_Menu" ? COLLECTABLE_MENU_INDEX.to_s : dummy_method})")
end
end
end

if JetCollectableScene::USE_MENU_OPTION
class Window_Command < Window_Selectable
alias jet4569_initialize initialize unless $@
alias jet9374_draw_item draw_item unless $@

def initialize(*args)
@disabled_commands = []
jet4569_initialize(*args)
end

def draw_item(*args)
jet9374_draw_item(*args)
@disabled_commands[args[0]] = args[1].nil? || args[1] ? nil : true
end

def ins_command(index, text)
@commands.insert(index, text)
@disabled_commands.insert(index, nil)
old_disabled_commands = @disabled_commands.dup
self.height = (@commands.size + @column_max - 1) / @column_max * WLH + 32
@item_max = @commands.size
create_contents
refresh
old_disabled_commands.each_index do |i|
if !old_disabled_commands[i].nil?
draw_item(i, false)
end
end
end

def add_command(text)
ins_command(@commands.size, text)
end
end

class Scene_Menu < Scene_Base

include JetCollectableScene

def sort_newcommand
@sorted_command ||= []
newcommand = @newcommand - @sorted_command
newcommand.sort.each {|i| @menu_index += 1 if @menu_index >= i }
@command_window.index = @menu_index
@sorted_command = @sorted_command + @newcommand
end

alias jet6993_create_command_window create_command_window unless $@
def create_command_window(*args)
jet6993_create_command_window(*args)
@command_window.ins_command(COLLECTABLE_MENU_INDEX,
COLLECTABLE_MENU_OPTION_NAME)
@newcommand ||= []
@newcommand << COLLECTABLE_MENU_INDEX
sort_newcommand
end

alias jet3943_update_command_selection update_command_selection unless $@
def update_command_selection(*args)
@menucomorpg_change = false
if Input.trigger?(Input::C) && @command_window.index ==
COLLECTABLE_MENU_INDEX
Sound.play_decision
$scene = Scene_Collectable.new
else
if Input.trigger?(Input::C) && @command_window.index >
COLLECTABLE_MENU_INDEX
@command_window.index -= 1
@menucomorpg_change = true
end
jet3943_update_command_selection(*args)
end
@command_window.index += 1 if @menucomorpg_change
end

alias jet3446_update_actor_selection update_actor_selection unless $@
def update_actor_selection(*args)
@menucomorpg_change = false
if Input.trigger?(Input::C) && @command_window.index >
COLLECTABLE_MENU_INDEX
@command_window.index -= 1
@menucomorpg_change = true
end
jet3446_update_actor_selection(*args)
@command_window.index += 1 if @menucomorpg_change
end
end
end

unless $engine_scripts.nil?
$engine_scripts["Collectable Menu"] = 1
end

for those interested, I marked the changes in red font.

Thanks a billion! biggrin.gif happy.gif laugh.gif
grullborg
Question: I made some weapons and armor collectable. they show up, but I can't equip them. Is there some way to fix this?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.