12-24-2016, 03:13 AM
(This post was last modified: 09-02-2024, 05:25 PM by DerVVulfman.)
VX ICON PASSWORDS 1.0
By: Ixfuru
Original Script: September 2014
INTRODUCTION
FEATURESs
HOW TO USE
SCREENSHOTS
CODE
CREDITS
By: Ixfuru
Original Script: September 2014
INTRODUCTION
Content Hidden
This script creates a small scene where something in the game can require a password. The passwords are a series of icons. The player then selects through a set list of icons and attempts to gain access to some hidden part of the game.
FEATURESs
Content Hidden
-creates a scene for user password input
-custom selected sound effects
-unlimited passwords, called by IDs
-link passwords to switches
-link passwords to transfers
-link passwords to self-switches
-custom selected sound effects
-unlimited passwords, called by IDs
-link passwords to switches
-link passwords to transfers
-link passwords to self-switches
HOW TO USE
Content Hidden
Copy the 'CODE' below and paste it in the script editor of your project, below 'Materials' and above 'Main'. There are instructions in the module portion of the script that go into great detail on how to implement the script. The system is basically set up in the module and then called through a script call (3rd page of an event):
Replace the 'password_id' in parentheses with the ID of the password you set up in the module.
Code:
$scene = Scene_IconPassword.new(password_id)
Replace the 'password_id' in parentheses with the ID of the password you set up in the module.
SCREENSHOTS
Content Hidden
CODE
Content Hidden
Code:
################################################################################
# VX Icon Passwords
# By: Ixfuru
################################################################################
# The idea of the script was introduced to me by 'new' of RPGMakerVX.net and is
# an RGSS2 version of the Icon Passwords script written in RGSS3 by efeberk.
# Therefor, above all else, if you use this script, you must credit both the
# aforementioned people as well as me. I took the scripts idea from them,
# but I just sort of implemented it in my own way.
#===============================================================================
# The script creates 'passwords' that you set by entering the id icons from the
# Graphics/System/Iconset image. When the scene is called with:
#
# $scene = Scene_IconPassword.new(password_id)
#
# The player is shown selectable windows, each containing selectable icons (which
# you provide of course. The object of the scene is to input the correct the
# icons (via their ids) with the correct icons of the password. If there is a
# match, a switch (which you provide) will be turned on, allowing the creator
# to make something happen immediately when the password is correct.
#
# To set up the passwords, use this formula:
#
# password_id => {:all_icons => [icon_ids],
# :correct_icons => [icons_ids],
# :switch_id => game_switch_id,
# :header_string => display_string,
# :transfer => [map_id, x, y, direction],
# :self_switch => [map_id, event_id, switch_id]},
#
# all_icons : This is an array of icon_ids from the Iconset that contain the ids
# of all the icons the player can choose from. I recommend keeping
# it to about 8-10 icon ids, that way the player isn't having to
# come up with a seemingly impossible mission of figuring out a code
# out of hundreds of possible icons.
#
# correct_icons : This is the array of the order in which the icons must be input
# in the scene to trigger the switch. This IS the password.
# If you place [7, 21, 18, 19] as the :correct_icons array, the
# player will have to input those icons in that order to
# trigger the switch. Since the scene creates a separate window
# for each correct icon and centers it on the screen, you shouldn't
# use more than about 10 icons for the password, since the windows
# will be created out of the screen if you do. Also, it IS
# okay to repeat icon_ids within the array.
#
# [6, 7, 7, 7 , 6]
#
# That's perfectly legal!
#
# Just keep in mind that you can't place an id in the :correct_icons
# array that doesn't appear in the :all_icons array, or you will
# render the password impossible.
#
# switch_id : This is the ID of the database switch you want to trigger if the code
# is correct. The system automaticall turns the switch off when
# called and if the password is correct, immediately exits the scene
# and returns to the map scene where the player can 'make something
# happen.
#
# header_string : This is the string, ( or words ), which will be displayed in the
# window above the icon windows used for the code. This should
# be one line long and used as a hint, or a simple "enter the code"
# message to the player. You DO NOT HAVE TO have a header string.
# You can omit the header string entry in the hash if you would
# rather, and the header will display the DEFAULT_HEADER_STRING
# you provide below instead.
#
# :header_string => "Code Entry",
# :header_string => "Enter the Right Code",
# :header_string => "Do you know the password?",
#
# All of the above examples are fine. As long as your string
# has double-quotes and is about one line long, any message will
# work.
#
# transfer : This is a four-element array [map_id, x, y, direction]. It's used
# to call about an instant map transfer when the code is a match.
# For 'direction' use 2 for down, 4 for left, 6 for right, 8 for up.
# This will be the direction the player is facing once he/she is
# transferred.
#
# self_switch : This allows you to set the Password to turn on a self switch
# when it's entered correctly. Just place the map_id, the event's id and
# the switch_id ("A", "B", "C" or "D") that you want to turn on
# or you can leave it empty if you don't want to use it.
#
################################################################################
# Calling the Scene
#
# All you have to do is place this in the 3rd page of event commands script call:
#
# $scene = Scene_IconPassword.new(password_id)
#
# Just exchange 'password_id' with the ID you create in the PASSWORDS hash below.
################################################################################
# CREDITS
#
# Again, you can use this script how you like, but you MUST credit both 'new' and
# 'efeberk' along with me if you use it.
################################################################################
module Ixfuru
module IconPasswords
PASSWORDS = { # <<<Don't delete this!
0 => {:all_icons => [96, 97, 98, 99, 100, 101, 102, 103],
:correct_icons => [101, 96, 100], #green, white, blue
:switch_id => 25,
:header_string => "Unlock the Chest",
:transfer => [],
:self_switch => [1, 4, "A"]},
}
NO_MATCH_SE = ["Buzzer2", 80, 100] # Sound played when code doesn't match
MATCH_SE = ["Chime2", 80, 100] # Sound played when code matches
WINDOW_CONTROL_SE = ["Switch1", 80, 100] # Sound played when moving from icon to icon
DEFAULT_HEADER_STRING = "Enter the Password" # Default string to display over password
end
end
#===============================================================================
# ICON PASSWORD
#===============================================================================
class IconPassword
attr_accessor :icons
attr_accessor :password_id
attr_reader :all_icons
attr_reader :code
attr_accessor :header_string
attr_reader :transfer
def initialize(password_id)
@password_id = password_id
@all_icons = Ixfuru::IconPasswords::PASSWORDS[@password_id][:all_icons]
@code = Ixfuru::IconPasswords::PASSWORDS[@password_id][:correct_icons]
if Ixfuru::IconPasswords::PASSWORDS[@password_id].has_key?(:header_string)
@header_string = Ixfuru::IconPasswords::PASSWORDS[@password_id][:header_string]
else
@header_string = Ixfuru::IconPasswords::DEFAULT_HEADER_STRING
end
@transfer = Ixfuru::IconPasswords::PASSWORDS[@password_id][:transfer]
@icons = []
end
#-----------------------------------------------------------------------------
# Get All Icons
#-----------------------------------------------------------------------------
def get_all_icons
return @all_icons
end
#-----------------------------------------------------------------------------
# Match?
#-----------------------------------------------------------------------------
def match?
return true if @icons == @code
return false
end
end
#===============================================================================
# WINDOW PASSWORD HEADER
#===============================================================================
class Window_PasswordHeader < Window_Base
attr_accessor :string
def initialize(string)
super(100, 108, 344, 56)
@string = string
refresh
end
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(0, 0, self.width - 32, WLH, @string, 1)
end
end
#===============================================================================
# WINDOW PASSWORD INSTRUCTIONS
#===============================================================================
class Window_PasswordInstructions < Window_Base
def initialize
super(100, 220, 344, 56)
@instructions = "< > : Next Window, SPC : Try, X : Exit"
refresh
end
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(0, 0, self.width - 32, WLH, @instructions, 1)
end
end
#===============================================================================
# WINDOW ICON
#===============================================================================
class Window_Icon < Window_Selectable
attr_accessor :icons
def initialize(password_id, x)
super(x, 164, 56, 56)
@icons = Ixfuru::IconPasswords::PASSWORDS[password_id][:all_icons]
@item_max = @icons.size
refresh
self.active = false
self.index = 0
end
def icon_id
return @icons[self.index]
end
def refresh
create_contents
for i in 0...@item_max
draw_each(i)
end
end
def draw_each(index)
rect = item_rect(index)
draw_icon(@icons[index], rect.x, rect.y, activated?)
end
def activated?
self.active
end
end
#===============================================================================
# SCENE ICON PASSWORD
#===============================================================================
class Scene_IconPassword < Scene_Base
def initialize(password_id)
$game_switches[Ixfuru::IconPasswords::PASSWORDS[password_id][:switch_id]] = false
@password_id = password_id
@comparitor = IconPassword.new(@password_id)
@win_index = 0
@win_max = @comparitor.code.size
@windows = []
end
#-----------------------------------------------------------------------------
# Start
#-----------------------------------------------------------------------------
def start
super
create_menu_background
@win_header = Window_PasswordHeader.new(@comparitor.header_string)
@win_instructions = Window_PasswordInstructions.new
start_x = window_start_x
for i in 0...@win_max
window = Window_Icon.new(@password_id, start_x + (i * 56))
@windows.push(window)
end
end
#-----------------------------------------------------------------------------
# Window Start X
#-----------------------------------------------------------------------------
def window_start_x
x = 272 - (@win_max * 28)
return x
end
#-----------------------------------------------------------------------------
# Return Scene
#-----------------------------------------------------------------------------
def return_scene
$scene = Scene_Map.new
end
#-----------------------------------------------------------------------------
# Update Code
#-----------------------------------------------------------------------------
def update_code
icons = []
for window in @windows
icons.push(window.icon_id)
end
@comparitor.icons = icons
end
#-----------------------------------------------------------------------------
# Update
#-----------------------------------------------------------------------------
def update
super
update_code
deactivate_windows
update_comparitor
update_window
end
#-----------------------------------------------------------------------------
# DeActivate Windows
#-----------------------------------------------------------------------------
def deactivate_windows
for window in @windows
window.active = false
end
@windows[@win_index].active = true
for window in @windows
window.refresh
end
end
#-----------------------------------------------------------------------------
# Play Code Match
#-----------------------------------------------------------------------------
def play_code_match
se = Ixfuru::IconPasswords::MATCH_SE
RPG::SE.new(se[0], se[1], se[2]).play
end
#-----------------------------------------------------------------------------
# Play No Match
#-----------------------------------------------------------------------------
def play_no_match
se = Ixfuru::IconPasswords::NO_MATCH_SE
RPG::SE.new(se[0], se[1], se[2]).play
end
#-----------------------------------------------------------------------------
# Play New Window
#-----------------------------------------------------------------------------
def play_new_window
se = Ixfuru::IconPasswords::WINDOW_CONTROL_SE
RPG::SE.new(se[0], se[1], se[2]).play
end
#-----------------------------------------------------------------------------
# Update Comparitor
#-----------------------------------------------------------------------------
def update_comparitor
if Input.trigger?(Input::C)
if @comparitor.match?
play_code_match
unless $game_switches[Ixfuru::IconPasswords::PASSWORDS[@password_id][:switch_id]] == 0
$game_switches[Ixfuru::IconPasswords::PASSWORDS[@password_id][:switch_id]] = true
end
ss_base = Ixfuru::IconPasswords::PASSWORDS[@password_id][:self_switch]
unless ss_base.empty?
key = [ss_base[0], ss_base[1], ss_base[2]]
$game_self_switches[key] = true
$game_map.refresh
end
unless @comparitor.transfer.empty?
m = @comparitor.transfer[0]
x = @comparitor.transfer[1]
y = @comparitor.transfer[2]
dir = @comparitor.transfer[3]
$game_player.reserve_transfer(m, x, y, dir)
end
return_scene
else
play_no_match
end
elsif Input.trigger?(Input::B)
Sound.play_cancel
return_scene
end
end
#-----------------------------------------------------------------------------
# Update Window
#-----------------------------------------------------------------------------
def update_window
@windows[@win_index].update
if Input.trigger?(Input::LEFT)
play_new_window
if @win_index == 0
@win_index = @win_max - 1
else
@win_index -= 1
end
elsif Input.trigger?(Input::RIGHT)
play_new_window
if @win_index == @win_max - 1
@win_index = 0
else
@win_index += 1
end
end
end
#-----------------------------------------------------------------------------
# Terminate
#-----------------------------------------------------------------------------
def terminate
super
dispose_menu_background
@win_header.dispose
@win_instructions.dispose
for window in @windows
window.dispose
end
end
end
CREDITS
Content Hidden
You can use this however you want, commercial or non-commercial. You must, however, give credit to Ixfuru if you do. Also, you cannot share or post this script anywhere else with Ixfuru's knowledge. The script was inspired by 'efemerk' and his VX Ace script. You would do well to credit him for this script as well. Both 'neosky' and 'new' also deserve credit for giving me ideas in some form or another in regards to the scripts features.