Jump to content
Rpg²S Forum
  • 0

Categorize Item


SimonRPG
 Share

Question

Ciao a tutti :rovatfl:

Ho un piccolo problema con questo script :

 

 

 

 

#Adds a function to the Items screen which allows the player to display #items by catagory.#To assign a category to an item, you must add <category IDENTIFIER> to the#notes on the specified item.#EX. A Potion would be listed as <category Goods> and a Sword would be#listed as <category Weapons>, provided you use the default terminology. $data_system = load_data("Data/System.rvdata") if $data_system == nil #==============================================================================##							 ★ Customization ★								#		 #==============================================================================# module KGCmodule CategorizeItem  #				  ◆ Automatically Catagorize Items ◆  ENABLE_AUTO_CATEGORIZE = true   #				   ◆ Duplicate Category Entries. ◆  #  Set to false, items can have multiple categories.  #  Set to true, items will be classified under the last tag (In the item  #  database "Notes")  NOT_ALLOW_DUPLICATE = true   #					  ◆ Category Identifier ◆  #  Arrange names in order to identify a category with the category identifier.  #  These are the default item catagories translated for future reference.  #  "Goods", "Combat", "Weapons", "Shields", "Helmets", "Armor",   #  "Accessories", "Valuables", "Special Items", "All Items"  CATEGORY_IDENTIFIER = [	"Cibo",		   # Consumable items (potion)	"Battaglia",	  # Battle-only items (fire bomb)	"Armi",		   # Weapons	"Vestiti",		# Shields	"Access.1",		# Head Gear / Helmets	"Scarpe",		  # Body Gear / Armor	"Access.2",  # Accessories / Rings, Necklaces, etc	"Speciali",  # AKA Plot Devices. Special keys, etc.	"Tutto",	  # All Items  ]   #				   ◆ Default Catagory Display ◆  #  Not hard to figure this one out.  ITEM_DEFAULT_CATEGORY = "Cibo"   #				   ◆ Item Screen Category Name ◆  #  Shows what current category is selected in the item description window.  #  Must be arranged in the same order as CATAGORY_IDENTIFIER.  CATEGORY_NAME = [	"Cibo",	"Battaglia",	Vocab.weapon,				# Weapons	Vocab.armor1,				# Shields	"#{Vocab.armor2}",		   # Head Gear	"#{Vocab.armor3}",		   # Body Gear	Vocab.armor4,				# Accessories	"Speciali",	"Tutto",  ]   #					   ◆ Descriptive Text ◆  #  Must be arranged in the same order as CATAGORY_IDENTIFIER  CATEGORY_DESCRIPTION = [	"Tutto ciò che aiuta a recupare HP e MP",	"Questi oggetti puoi usarli solo in battaglia",	"Lista delle #{Vocab.weapon}.",	"Lista dei #{Vocab.armor1}.",	"Prima lista di accessori .",	"Lista delle #{Vocab.armor3}.",	"Seconda lista di accessori .",	"Oggetti chiave .",	"Tutto ciò che ho",  ]   # ◆ Coordinates of item description window. [ x, y ]  CATEGORY_WINDOW_POSITION  = [1, 360]  # ◆ Number of rows in the item description window.  CATEGORY_WINDOW_COLUMNS   = 9  # ◆ Item description window column line width.  CATEGORY_WINDOW_COL_WIDTH = 56  # ◆ item description window column spacer width.  CATEGORY_WINDOW_COL_SPACE = 1endend #------------------------------------------------------------------------------# $imported = {} if $imported == nil$imported["CategorizeItem"] = true module KGC::CategorizeItem  #						◆ Item Index ◆  ITEM_DEFAULT_CATEGORY_INDEX = CATEGORY_IDENTIFIER.index(ITEM_DEFAULT_CATEGORY)   #					 ◆ Reserved Category Index ◆  #  To be honest I'm not entirely sure what this affects.  RESERVED_CATEGORY_INDEX = {  	"Cibo"	 => CATEGORY_IDENTIFIER.index("Cibo"),	"Battaglia"	 => CATEGORY_IDENTIFIER.index("Battaglia"),	"Armi"	   => CATEGORY_IDENTIFIER.index("Armi"),	"Vestiti"   => CATEGORY_IDENTIFIER.index("Vestiti"),	"Access.1" => CATEGORY_IDENTIFIER.index("Access.1"),	"Scarpe"   => CATEGORY_IDENTIFIER.index("Scarpe"),	"Access.2"   => CATEGORY_IDENTIFIER.index("Access.2"),	"Speciali"	 => CATEGORY_IDENTIFIER.index("Speciali"),      } # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ##  Unless you know what you're doing, it's best not to alter anything beyond  ##  this point, as this only affects the tags used for "Notes" in database.	## * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ##  Whatever word(s) are after the separator ( | ) in the following lines are #   what are used to determine what is searched for in the "Notes" section.   # Regular Expression Definition   module Regexp	# Base Item Module	module BaseItem	  # Category tag string	  CATEGORY = /^<(?:CATEGORY|classification|category?)[ ]*(.*)>/i	end  endend #==============================================================================# ■ RPG::BaseItem#============================================================================== class RPG::BaseItem  #--------------------------------------------------------------------------  # ○ アイテム分類のキャッシュ生成  #--------------------------------------------------------------------------  def create_categorize_item_cache	if @__item_category == nil || !KGC::CategorizeItem::ENABLE_AUTO_CATEGORIZE	  @__item_category = []	else	  @__item_category.compact!	end 	self.note.split(/[&#092;r\n]+/).each { |line|	  if line =~ KGC::CategorizeItem::Regexp::BaseItem::CATEGORY		# カテゴリ		c = KGC::CategorizeItem::CATEGORY_IDENTIFIER.index($1)		@__item_category << c if c != nil	  end	}	if @__item_category.empty?	  @__item_category << KGC::CategorizeItem::ITEM_DEFAULT_CATEGORY_INDEX	elsif KGC::CategorizeItem::NOT_ALLOW_DUPLICATE	  # 最後に指定したカテゴリに配置	  @__item_category = [@__item_category.pop]	end  end  #--------------------------------------------------------------------------  # ○ アイテムのカテゴリ  #--------------------------------------------------------------------------  def item_category	create_categorize_item_cache if @__item_category == nil	return @__item_category  endend #==================================End Class===================================# #==============================================================================# ■ RPG::UsableItem#============================================================================== class RPG::UsableItem < RPG::BaseItem  #--------------------------------------------------------------------------  # ○ アイテム分類のキャッシュ生成  #--------------------------------------------------------------------------  def create_categorize_item_cache	@__item_category = []	if self.price == 0	  @__item_category << KGC::CategorizeItem::RESERVED_CATEGORY_INDEX["Valuables"]	end	super  endend #==================================End Class===================================# #==============================================================================# ■ RPG::Weapon#============================================================================== class RPG::Weapon < RPG::BaseItem  #--------------------------------------------------------------------------  # ○ アイテム分類のキャッシュ生成  #--------------------------------------------------------------------------  def create_categorize_item_cache	@__item_category = []	@__item_category << KGC::CategorizeItem::RESERVED_CATEGORY_INDEX["Weapon"]	super  endend #==================================End Class===================================# #==============================================================================# ■ RPG::Armor#============================================================================== class RPG::Armor < RPG::BaseItem  #--------------------------------------------------------------------------  # ○ アイテム分類のキャッシュ生成  #--------------------------------------------------------------------------  def create_categorize_item_cache	@__item_category = []	@__item_category << KGC::CategorizeItem::RESERVED_CATEGORY_INDEX["Armor"]	type = nil	case self.kind	when 0	  type = "Shields"	when 1	  type = "Head Gear"	when 2	  type = "Body Gear"	when 3	  type = "Accessories"	end	if type != nil	  @__item_category << KGC::CategorizeItem::RESERVED_CATEGORY_INDEX[type]	end	super  endend #==================================End Class===================================# #==============================================================================# ■ Window_Item#============================================================================== class Window_Item < Window_Selectable  #--------------------------------------------------------------------------  # ● 公開インスタンス変数  #--------------------------------------------------------------------------  attr_reader   :category				 # カテゴリ  #--------------------------------------------------------------------------  # ● オブジェクト初期化  #	 x	  : ウィンドウの X 座標  #	 y	  : ウィンドウの Y 座標  #	 width  : ウィンドウの幅  #	 height : ウィンドウの高さ  #--------------------------------------------------------------------------  alias initialize_KGC_CategorizeItem initialize  def initialize(x, y, width, height)	@category = 0 	initialize_KGC_CategorizeItem(x, y, width, height)  end  #--------------------------------------------------------------------------  # ○ カテゴリ設定  #--------------------------------------------------------------------------  def category=(value)	@category = value	refresh  end  #--------------------------------------------------------------------------  # ● アイテムをリストに含めるかどうか  #	 item : アイテム  #--------------------------------------------------------------------------  alias include_KGC_CategorizeItem? include?  def include?(item)	return false if item == nil 	# 「全種」なら無条件で含める	if @category == KGC::CategorizeItem::RESERVED_CATEGORY_INDEX["All Items"]	  return true	end 	result = include_KGC_CategorizeItem?(item) 	unless result	  # 使用可能なら追加候補とする	  if $imported["UsableEquipment"] && $game_party.item_can_use?(item)		result = true	  end	end	# 戦闘外ならカテゴリ一致判定	unless $game_temp.in_battle	  result &= (item.item_category.include?(@category))	end 	return result  endend #==================================End Class===================================# #==============================================================================# □ Window_ItemCategory#------------------------------------------------------------------------------#  アイテム画面でカテゴリ選択を行うウィンドウです。#============================================================================== class Window_ItemCategory < Window_Command  #--------------------------------------------------------------------------  # ● オブジェクト初期化  #--------------------------------------------------------------------------  def initialize	cols = KGC::CategorizeItem::CATEGORY_WINDOW_COLUMNS	width = KGC::CategorizeItem::CATEGORY_WINDOW_COL_WIDTH * cols + 32	width += (cols - 1) * KGC::CategorizeItem::CATEGORY_WINDOW_COL_SPACE	commands = KGC::CategorizeItem::CATEGORY_NAME	super(width, commands, cols, 0,	  KGC::CategorizeItem::CATEGORY_WINDOW_COL_SPACE)	self.x = KGC::CategorizeItem::CATEGORY_WINDOW_POSITION[0]	self.y = KGC::CategorizeItem::CATEGORY_WINDOW_POSITION[1]	self.z = 1000	self.index = 0  end  #--------------------------------------------------------------------------  # ● ヘルプテキスト更新  #--------------------------------------------------------------------------  def update_help	@help_window.set_text(KGC::CategorizeItem::CATEGORY_DESCRIPTION[self.index])  endend #==================================End Class===================================# #==============================================================================# ■ Scene_Item#============================================================================== class Scene_Item < Scene_Base  #--------------------------------------------------------------------------  # ● 開始処理  #--------------------------------------------------------------------------  alias start_KGC_CategorizeItem start  def start	start_KGC_CategorizeItem 	@category_window = Window_ItemCategory.new	@category_window.help_window = @help_window	show_category_window  end  #--------------------------------------------------------------------------  # ● 終了処理  #--------------------------------------------------------------------------  alias terminate_KGC_CategorizeItem terminate  def terminate	terminate_KGC_CategorizeItem 	@category_window.dispose  end  #--------------------------------------------------------------------------  # ● フレーム更新  #--------------------------------------------------------------------------  alias update_KGC_CategorizeItem update  def update	@category_window.update 	update_KGC_CategorizeItem 	if @category_window.active	  update_category_selection	end  end  #--------------------------------------------------------------------------  # ○ カテゴリ選択の更新  #--------------------------------------------------------------------------  def update_category_selection	unless @category_activated	  @category_activated = true	  return	end 	# 選択カテゴリー変更	if @last_category_index != @category_window.index	  @item_window.category = @category_window.index	  @item_window.refresh	  @last_category_index = @category_window.index	end 	if Input.trigger?(Input::B)	  Sound.play_cancel	  return_scene	elsif Input.trigger?(Input::C)	  Sound.play_decision	  hide_category_window	end  end  #--------------------------------------------------------------------------  # ● アイテム選択の更新  #--------------------------------------------------------------------------  alias update_item_selection_KGC_CategorizeItem update_item_selection  def update_item_selection	if Input.trigger?(Input::B)	  Sound.play_cancel	  show_category_window	  return	end 	update_item_selection_KGC_CategorizeItem  end  #--------------------------------------------------------------------------  # ○ カテゴリウィンドウの表示  #--------------------------------------------------------------------------  def show_category_window	@category_window.open	@category_window.active = true	@item_window.active = false  end  #--------------------------------------------------------------------------  # ○ カテゴリウィンドウの非表示  #--------------------------------------------------------------------------  def hide_category_window	@category_activated = false	@category_window.close	@category_window.active = false	@item_window.active = true	# アイテムウィンドウのインデックスを調整	if @item_window.index >= @item_window.item_max	  @item_window.index = [@item_window.item_max - 1, 0].max	end  endend

 

 

Me li divide in categorie , ma dovrebbe anche visualizzarmeli nella voce "Tutti", cosa che invece non accade.

Qualcuno riesce mica a darmi una mano?

 

:wink:

Edited by SimonRPG

Screen Contest

 

 

 

http://img825.imageshack.us/img825/4307/sccontest3oct.gif X 2

 

Progetti

 

Gioco in sviluppo: Decay.

Team: http://img230.imageshack.us/img230/3668/decasoft1.png

( MasterSion,Mercury,SimonRPG )

Direct Link:Decay-project

 

 

Tool : RpgMaker VX

http://img189.imageshack.us/img189/6131/bannnova.jpg

 

Titolo : Nova Planet

Status : Lento

In cerca di un qualsiasi tipo di aiuto per dividere il lavoro

 

in gemellaggio con :

http://img21.imageshack.us/img21/5763/banner10p.png

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0
UP

Screen Contest

 

 

 

http://img825.imageshack.us/img825/4307/sccontest3oct.gif X 2

 

Progetti

 

Gioco in sviluppo: Decay.

Team: http://img230.imageshack.us/img230/3668/decasoft1.png

( MasterSion,Mercury,SimonRPG )

Direct Link:Decay-project

 

 

Tool : RpgMaker VX

http://img189.imageshack.us/img189/6131/bannnova.jpg

 

Titolo : Nova Planet

Status : Lento

In cerca di un qualsiasi tipo di aiuto per dividere il lavoro

 

in gemellaggio con :

http://img21.imageshack.us/img21/5763/banner10p.png

Link to comment
Share on other sites

  • 0

Prova ad inserire alla riga 108 dello script che hai postato

	"All Items"	 => CATEGORY_IDENTIFIER.index("Tutto")

 


SCRIPT RGSS (RPG Maker XP) VINTAGE LIBRARY [2018+]


Breaking (in ogni senso) News: "Treno deraglia per via del seno di Sakurai Aoi . . ." - Info nello spoiler !!

 


http://afantasymachine.altervista.org/_altervista_ht/NOOOOOOOOOilMIOtreninooooo_500.gif


Non riesco a smettere di essere affascinato da immagini come questa . . .

http://anime.vl-vostok.ru/art/photos2011/17/78049800/wall_VladAnime_WWA_1885-1680x1050.jpg


Alcuni wallpapers che faccio ruotare sul mio vecchio PC . . .


http://afantasymachine.altervista.org/_altervista_ht/gits_window.jpg

http://afantasymachine.altervista.org/_altervista_ht/madoka_group01.jpg
http://afantasymachine.altervista.org/_altervista_ht/arisu_picipici_01.jpg
http://afantasymachine.altervista.org/_altervista_ht/phantom_wp01_einzwei.jpg


La parte più spassosa della mia vita è quando gli altri cercano di spiegarmi i miei pensieri . . .


BBCode Testing


Typeface & Size



Link to comment
Share on other sites

  • 0
Prova ad inserire alla riga 108 dello script che hai postato

	"All Items"	 => CATEGORY_IDENTIFIER.index("Tutto")

 

Non ci credo...ti stavo rispondendo che ci avevo già provato ma evidentemento mi era sfuggito qualcosa

Grazie mille ora funziona :rovatfl:

A presto :blink:

Screen Contest

 

 

 

http://img825.imageshack.us/img825/4307/sccontest3oct.gif X 2

 

Progetti

 

Gioco in sviluppo: Decay.

Team: http://img230.imageshack.us/img230/3668/decasoft1.png

( MasterSion,Mercury,SimonRPG )

Direct Link:Decay-project

 

 

Tool : RpgMaker VX

http://img189.imageshack.us/img189/6131/bannnova.jpg

 

Titolo : Nova Planet

Status : Lento

In cerca di un qualsiasi tipo di aiuto per dividere il lavoro

 

in gemellaggio con :

http://img21.imageshack.us/img21/5763/banner10p.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...