Stamp Collector

RPG Maker Forums
Stamp Collector v1.3
By piejamas

Introduction
Sometimes in a game, you will have great places to hide chests, but maybe have nothing to put in them. This script lets you create items that the player can collect, and view on a collection screen. This script is not just for stamps, it can be used for anything from artefacts to easter eggs.

This is pretty much my first script and before a few weeks ago, I had never scripted before in my life, so expect pretty messy script wink.gif

v1.0 Features

  1. Have up to 25 collectable items
  2. Each item has a name, icon and description
  3. Able to view how many collectables the player has out of the total
  4. Highly customisable

v1.1 Features

  1. Able to disable descriptions
  2. Removed option about whether it should be included in the menu (for compatibility reasons)
  3. Made stamp data save with the game

v1.2 Features

  1. Menu option removed (for compatibility reasons)
  2. 'Show description anyway' option included
  3. Increased saving compatibility

v1.3 Features

  1. Description box changes size depending on description lines
  2. Fixed the scrolling issue (finally!!)
  3. Able to choose how many stamps in a row on the collection screen
Screenie1.jpg
Screenie2.jpg

Note: there is no longer a 25 stamp limit. I fixed it smile.gif

Stamp Collector v1.3
By piejamas

Introduction
Sometimes in a game, you will have great places to hide chests, but maybe have nothing to put in them. This script lets you create items that the player can collect, and view on a collection screen. This script is not just for stamps, it can be used for anything from artefacts to easter eggs.

This is pretty much my first script and before a few weeks ago, I had never scripted before in my life, so expect pretty messy script wink.gif

v1.0 Features

  1. Have up to 25 collectable items
  2. Each item has a name, icon and description
  3. Able to view how many collectables the player has out of the total
  4. Highly customisable

v1.1 Features

  1. Able to disable descriptions
  2. Removed option about whether it should be included in the menu (for compatibility reasons)
  3. Made stamp data save with the game

v1.2 Features

  1. Menu option removed (for compatibility reasons)
  2. 'Show description anyway' option included
  3. Increased saving compatibility

v1.3 Features

  1. Description box changes size depending on description lines
  2. Fixed the scrolling issue (finally!!)
  3. Able to choose how many stamps in a row on the collection screen

Screenshots
Spoiler:

How To Use
Get a stamp:
CODE
$stamp.get(stamp number)

A stamp is set up like this (in the section in customisation):

CODE
ITEM[number] = ["item name", icon index, "Description lines", "separated by commas (3 lines max)"]


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

  1. ** Stamp Collector VX

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

  1. By piejamas
  2. v1.3

#===============================================================================
=begin

*
* Please Note *
*

Before you go gawking at how messy this is, please remember that this is my
first script. Thank you.

With this script, you can collect items and view them on the collection screen
This screen is called by using:

$scene = Collection_Screen.new

And for the player to aquire a collectable item, use this script call:

$stamp.get(number in collectable items list)

=end

  1. *
  2. *Customisation*
  3. *

module Stamp # Don't touch

# Item Name
# This is the name of the collectable item
ITEM_NAME = "Stamps"

# Title text
# This is the text that appears at the top
TITLE = "piejamas' Stamps"

# Collectable Items
# To make a collectable item, lay it out like this:
#
# ITEM[number] = ["item name", icon index, "Description lines,
# "separated by commas"]
#
# 'number' is what you put in the brackets in $stamp.get()
#

ITEM = [] # Don't touch

ITEM[0] = ["Stamp 1", 1, "A stamp o.o"]
ITEM[1] = ["Stamp 2", 5, "Another stamp? o.o"]
ITEM[2] = ["Stamp 3", 10, "Example of multiple lines", "o.o"]
ITEM[3] = ["Stamp 4", 30, "You can",
"do it like",
"this o.o"]

# DONT_HAVE_TEXT = The text to display if you don't have the stamp
# DONT_HAVE_ICON = The icon to display if you don't have the stamp

DONT_HAVE_TEXT = "???"

DONT_HAVE_ICON = 227

# Disable Description
# If set to true, item descriptions will not be shown.

DISABLE_DESCRIPTION = false

# Reward
# This is a common event to execute when you obtain all the items

REWARD = 1

# Show Description Anyway
# If true, shows item description even if you don't have the item.

SHOW_ANYWAY = false

# Number of stamps in a row
# Works up to about 10

STAMPS_IN_ROW = 2

# Show stamp names
# if true, stamp names will be shown in the stamp collection screen

SHOW_STAMP_NAMES = true

################################################################################
## CUSTOMISATION END ##
################################################################################

class Get_Stamp
def initialize
end
def get(stamp)
$game_system.stamps_held[stamp] = true
if $game_system.stamps_held.nitems == Stamp::ITEM.size
$game_temp.common_event_id = Stamp::REWARD
end
end
end

$stamp = Get_Stamp.new

end

class Game_System
attr_accessor :stamps_held
alias base_game_system_initialize initialize unless $@
def initialize
base_game_system_initialize
@stamps_held = []
end
end

class Window_TotalStamp < Window_Base
def initialize
@total_stamps = Stamp::ITEM.size
super(0, 0, 128, 56)
update
end

def update
self.contents.clear
self.contents.draw_text(0, 0, 96, WLH, "#{$game_system.stamps_held.nitems} / #{@total_stamps} #{Stamp::ITEM_NAME}", 1)
end
end

class Collection_Screen < Scene_Base
def initialize(indx = 0, from_menu = false)
@indx = indx
@from_menu = from_menu
end

def start
super
create_menu_background
@top_window = Window_Top.new
@top_window.set_text(Stamp::TITLE, 1)
@window_totalstamp = Window_TotalStamp.new
@viewport = Viewport.new(0, 0, 544, 416)
$stamp_window = Icon_Display.new(@indx)
$stamp_window.viewport = @viewport
end

def update
super
update_menu_background
$stamp_window.update
$stamp_window.update_cursor
if Input.trigger?(Input::B)
exit
end
if Input.trigger?(Input::C)
unless $game_system.stamps_held[$stamp_window.index] == nil or Stamp::DISABLE_DESCRIPTION and Stamp::SHOW_ANYWAY == false
Sound.play_decision
$scene = Scene_Description.new($stamp_window.index)
else
Sound.play_buzzer unless Stamp::DISABLE_DESCRIPTION
end
end
end

def exit
@top_window.dispose
@window_totalstamp.dispose
$stamp_window.dispose
if @from_menu
$scene = Scene_Menu.new(4)
else
$scene = Scene_Map.new
end
end
end

class Icon_Display < Window_Selectable
def initialize(indx = 1)
super(0, 56, 544, 360)
@column_max = Stamp::STAMPS_IN_ROW
@item_max = Stamp::ITEM.size
self.index = indx
self.active = true
refresh
end

def refresh
@icon_max = Stamp::ITEM.size
self.contents = Bitmap.new(self.contents.width, @item_max * WLH)
for i in 0…@icon_max
draw_item(i)
end
end

def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
item = $game_system.stamps_held[index]
if item != nil
icon = Stamp::ITEM[index][1]
text = Stamp::ITEM[index][0]
else
icon = Stamp::DONT_HAVE_ICON
text = Stamp::DONT_HAVE_TEXT
end
rect.width -= 4
self.contents.draw_text(rect.x + 32, rect.y, 172, WLH, text, 1) if Stamp::SHOW_STAMP_NAMES
self.draw_icon(icon, rect.x, rect.y)
end
end

class Window_Description < Window_Base
def initialize(number)
height = WLH * Stamp::ITEM[number].size
super(0, 144, 544, height + 32)
@number = number
refresh
end

def refresh
self.contents.clear
self.draw_icon(Stamp::ITEM[@number][1], 32, 0)
self.contents.font.color = text_color(3)
self.contents.draw_text(64, 0, 480, WLH, Stamp::ITEM[@number][0])
self.contents.font.color = normal_color
for i in 0…3
array_thing = i + 2
y = i * WLH + 32
unless array_thing == nil
self.contents.draw_text(32, y, 480, WLH, Stamp::ITEM[@number][array_thing])
end
end
end
end

class Scene_Description < Scene_Base
def initialize(number)
@number = number
end
def start
super
create_menu_background
@window_description = Window_Description.new(@number)
end

def update
super
update_menu_background
if Input.trigger?(Input::B)
Sound.play_cancel
@window_description.dispose
$stamp_window.dispose
$scene = Collection_Screen.new(@number)
end
end
end

class Window_Top < Window_Base
def initialize
super(128, 0, 416, WLH + 32)
end

def set_text(text, align = 0)
if text != @text or align != @align
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, self.width - 40, WLH, text, align)
@text = text
@align = align
end
end
end