Hey guys, I could really use some help with this script as I really want to implement it to my project. Unfortunately I don't have any scripting experience and am having issues getting this script working on a blank project. The error is "line 131 nomethoderror occurred. undefined method scan for nil nil class." This happens as soon as I load the game after tagging an armor with <seal atype: 7>. As soon as I delete the tag, the blank project works fine.
Here's the script I found that I would like to use.
#===============================================================================
#
# Seal by Weapon/Armor Type v1.0
# by Shad3Light
#
# 2014/03/06
# URL: http://shad3light.blogspot.com/2014/03/seal-by-eq-type.html
#===============================================================================
=begin
================================================================================
Description
By default, VX Ace does not offer equipment restriction by weapon or armor
types, only equipment slots can be sealed. This script tries to rectify that
so we can prohibit equipping a specific weapon/armor types.
--------------------------------------------------------------------------------
History
v1.0 - Initial Release (2014/03/06)
--------------------------------------------------------------------------------
Terms of Use
- You are free to use this script for non-commercial projects.
- For commercial projects, at least contact me first.
- This script is provided as-is. Don't expect me to give support.
- Reported bug will be fixed, but no guarantee on requested features.
- No guarantee either for compatibility fixes.
- Give credit to Shad3Light (me), and do not delete this header.
--------------------------------------------------------------------------------
Installation
Put this script below Бе Materials and above Бе Main Process.
If there are scripts that overwrite the aliased methods below,
put this script below said script.
--------------------------------------------------------------------------------
Usage
To make an actor, class, enemy (even though it does not make sense),
equipment, or state to seal a specific weapon or armor types, use
these notetag:
<seal wtype: x>
<seal atype: x>
This will make the weapon/armor with specified types cannot be equipped.
You can also specify more than one types in the notetag:
<seal wtype: x, y, z>
<seal atype: x, y, z>
Example:
<seal wtype: 1>
This will make Axe-type weapons unequippable for the battler.
================================================================================
=end
if $imported && $imported[:SHD_SealByWAType]
msgbox "Warning: Seal by Weapon/Armor Type script is imported twice."
else
$imported = {} if $imported.nil?
$imported[:SHD_SealByWAType] = true
module SHD
#===============================================================================
# Configuration Module
#
# None
#
# Configuration Module End
#===============================================================================
#===============================================================================
# Code Start
# Configuration ends here. Edit what's below at your own risk.
#-------------------------------------------------------------------------------
# Aliased methods:
# DataManager
# self.load_database
# Game_BattlerBase
# equippable?
#
# New methods:
# DataManager
# self.load_notetags_shd_eqt_rest
# RPG::BaseItem
# load_notetags_shd_eqt_rest
# wtype_seal
# atype_seal
# Game_BattlerBase
# wtype_sealed?
# atype_sealed?
#===============================================================================
module REGEXP
RESTRICT_WTYPE = /<seal wtype:[ ]*(?:\d+(\s*,\s*\d+)*)>/i
RESTRICT_ATYPE = /<seal atype:[ ]*(?:\d+(\s*,\s*\d+)*)>/i
end
end
module DataManager
class <<self; alias :load_database_shd_eqt_rest :load_database; end
def self.load_database
load_database_shd_eqt_rest
load_notetags_shd_eqt_rest
end
def self.load_notetags_shd_eqt_rest
for i in $data_actors+$data_classes+$data_enemies+$data_weapons+$data_armors+$data_states
next if i.nil?
i.load_notetags_shd_eqt_rest
end
end
end
class RPG::BaseItem
def load_notetags_shd_eqt_rest
@wtype_seal = []
@atype_seal = []
self.note.split(/\r\n/).each do |line|
case line
when SHD::REGEXP::RESTRICT_WTYPE
$1.scan(/\d+/).each { |n| @wtype_seal << n.to_i }
when SHD::REGEXP::RESTRICT_ATYPE
$1.scan(/\d+/).each { |n| @atype_seal << n.to_i }
end
end
end
def wtype_seal(id)
return @wtype_seal.include?(id)
end
def atype_seal(id)
return @atype_seal.include?(id)
end
end
class Game_BattlerBase
def wtype_sealed?(wtype_id)
feature_objects.each { |o| return true if o.wtype_seal(wtype_id) }
return false
end
def atype_sealed?(atype_id)
feature_objects.each { |o| return true if o.atype_seal(atype_id) }
return false
end
alias :shd_eqt_rest_equippable? :equippable?
def equippable?(item)
return false unless shd_eqt_rest_equippable?(item)
return false if item.is_a?(RPG::Weapon) && wtype_sealed?(item.wtype_id)
return false if item.is_a?(RPG::Armor) && atype_sealed?(item.atype_id)
return true
end
end
end #if $imported
Here's the script I found that I would like to use.
#===============================================================================
#
# Seal by Weapon/Armor Type v1.0
# by Shad3Light
#
# 2014/03/06
# URL: http://shad3light.blogspot.com/2014/03/seal-by-eq-type.html
#===============================================================================
=begin
================================================================================
Description
By default, VX Ace does not offer equipment restriction by weapon or armor
types, only equipment slots can be sealed. This script tries to rectify that
so we can prohibit equipping a specific weapon/armor types.
--------------------------------------------------------------------------------
History
v1.0 - Initial Release (2014/03/06)
--------------------------------------------------------------------------------
Terms of Use
- You are free to use this script for non-commercial projects.
- For commercial projects, at least contact me first.
- This script is provided as-is. Don't expect me to give support.
- Reported bug will be fixed, but no guarantee on requested features.
- No guarantee either for compatibility fixes.
- Give credit to Shad3Light (me), and do not delete this header.
--------------------------------------------------------------------------------
Installation
Put this script below Бе Materials and above Бе Main Process.
If there are scripts that overwrite the aliased methods below,
put this script below said script.
--------------------------------------------------------------------------------
Usage
To make an actor, class, enemy (even though it does not make sense),
equipment, or state to seal a specific weapon or armor types, use
these notetag:
<seal wtype: x>
<seal atype: x>
This will make the weapon/armor with specified types cannot be equipped.
You can also specify more than one types in the notetag:
<seal wtype: x, y, z>
<seal atype: x, y, z>
Example:
<seal wtype: 1>
This will make Axe-type weapons unequippable for the battler.
================================================================================
=end
if $imported && $imported[:SHD_SealByWAType]
msgbox "Warning: Seal by Weapon/Armor Type script is imported twice."
else
$imported = {} if $imported.nil?
$imported[:SHD_SealByWAType] = true
module SHD
#===============================================================================
# Configuration Module
#
# None
#
# Configuration Module End
#===============================================================================
#===============================================================================
# Code Start
# Configuration ends here. Edit what's below at your own risk.
#-------------------------------------------------------------------------------
# Aliased methods:
# DataManager
# self.load_database
# Game_BattlerBase
# equippable?
#
# New methods:
# DataManager
# self.load_notetags_shd_eqt_rest
# RPG::BaseItem
# load_notetags_shd_eqt_rest
# wtype_seal
# atype_seal
# Game_BattlerBase
# wtype_sealed?
# atype_sealed?
#===============================================================================
module REGEXP
RESTRICT_WTYPE = /<seal wtype:[ ]*(?:\d+(\s*,\s*\d+)*)>/i
RESTRICT_ATYPE = /<seal atype:[ ]*(?:\d+(\s*,\s*\d+)*)>/i
end
end
module DataManager
class <<self; alias :load_database_shd_eqt_rest :load_database; end
def self.load_database
load_database_shd_eqt_rest
load_notetags_shd_eqt_rest
end
def self.load_notetags_shd_eqt_rest
for i in $data_actors+$data_classes+$data_enemies+$data_weapons+$data_armors+$data_states
next if i.nil?
i.load_notetags_shd_eqt_rest
end
end
end
class RPG::BaseItem
def load_notetags_shd_eqt_rest
@wtype_seal = []
@atype_seal = []
self.note.split(/\r\n/).each do |line|
case line
when SHD::REGEXP::RESTRICT_WTYPE
$1.scan(/\d+/).each { |n| @wtype_seal << n.to_i }
when SHD::REGEXP::RESTRICT_ATYPE
$1.scan(/\d+/).each { |n| @atype_seal << n.to_i }
end
end
end
def wtype_seal(id)
return @wtype_seal.include?(id)
end
def atype_seal(id)
return @atype_seal.include?(id)
end
end
class Game_BattlerBase
def wtype_sealed?(wtype_id)
feature_objects.each { |o| return true if o.wtype_seal(wtype_id) }
return false
end
def atype_sealed?(atype_id)
feature_objects.each { |o| return true if o.atype_seal(atype_id) }
return false
end
alias :shd_eqt_rest_equippable? :equippable?
def equippable?(item)
return false unless shd_eqt_rest_equippable?(item)
return false if item.is_a?(RPG::Weapon) && wtype_sealed?(item.wtype_id)
return false if item.is_a?(RPG::Armor) && atype_sealed?(item.atype_id)
return true
end
end
end #if $imported