Ogłoszenie 

Uwaga! To forum jest w trybie offline.
Wszelką pomoc uzyskasz pod adresem
forum.ultimateam.pl


Administracja Forum


Poprzedni temat «» Następny temat
Zamknięty przez: Angius
Sro 29 Cze, 2011 13:09
Kategorie przedmiotów
Autor Wiadomość
Angius 

Nie wkurzać



Preferowany:
RPG Maker VX

Pomógł: 104 razy
Dołączył: 30 Paź 2010
Posty: 1276
Skąd: wROCK
Wysłany: Czw 23 Cze, 2011 12:42
Kategorie przedmiotów
Znalazłem skrypt na kategorie przedmiotów, podział na "broń", "pancerze", etc. Kategorii było za dużo, więc kilka powywalałem, przetłumaczyłem ich nazwy, pododawałem notatki do broni, ale niestety wywala syntax przy linijce z nazwą tagu. Jakby ktoś mógł opisać jak zmieniać tu kategorie, dodawać je i usuwać, byłbym niezmiernie wdzięczny. Oto skrypt (oryginał)
Spoiler:

Kod:
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_
#_/ ◆ Item Categorization - KGC_CategorizeItem ◆ VX ◆
#_/ ◇ Last update : 2008/04/10 ◇
#_/ ◇ Translated by Mr. Anonymous ◇
#_/ ◆ http://ytomy.sakura.ne.jp/ ◆
#_/-----------------------------------------------------------------------------
#_/ 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 to the
#_/ notes on the specified item.
#_/ EX. A Potion would be listed as and a Sword would be
#_/ listed as , provided you use the default terminology.
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_

$data_system = load_data("Data/System.rvdata") if $data_system == nil

#==============================================================================#
# ★ Customization ★ #
#==============================================================================#

module KGC
module 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 = [
"Goods", # Consumable items (potion)
"Combat", # Battle-only items (fire bomb)
"Weapons", # Weapons
"Shields", # Shields
"Helmets", # Head Gear / Helmets
"Armor", # Body Gear / Armor
"Accessories", # Accessories / Rings, Necklaces, etc
"Valuables", # Treasures and the like
"Special Items", # AKA Plot Devices. Special keys, etc.
"All Items", # All Items
]

# ◆ Default Catagory Display ◆
# Not hard to figure this one out.
ITEM_DEFAULT_CATEGORY = "Inventory"

# ◆ 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 = [
"Goods",
"Combat",
Vocab.weapon, # Weapons
Vocab.armor1, # Shields
"#{Vocab.armor2}", # Head Gear
"#{Vocab.armor3}", # Body Gear
Vocab.armor4, # Accessories
"Valuables",
"Special",
"All",
]

# ◆ Descriptive Text ◆
# Must be arranged in the same order as CATAGORY_IDENTIFIER
CATEGORY_DESCRIPTION = [
"Viewing #{Vocab.item}.",
"Viewing Combat #{Vocab.item}. For use during battle.",
"Viewing #{Vocab.weapon}s.",
"Viewing #{Vocab.armor1}s.",
"Viewing #{Vocab.armor2}s.",
"Viewing #{Vocab.armor3}s.",
"Viewing #{Vocab.armor4}.",
"Viewing Valuables.",
"Viewing Special #{Vocab.item}. A.K.A. Plot Devices.",
"Viewing All #{Vocab.item}.",
]

# ◆ Coordinates of item description window. [ x, y ]
CATEGORY_WINDOW_POSITION = [1, 48]
# ◆ Number of rows in the item description window.
CATEGORY_WINDOW_COLUMNS = 10
# ◆ Item description window column line width.
CATEGORY_WINDOW_COL_WIDTH = 50
# ◆ item description window column spacer width.
CATEGORY_WINDOW_COL_SPACE = 1
end
end

#------------------------------------------------------------------------------#

$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 = {
"All Items" => CATEGORY_IDENTIFIER.index("All Items"),
"Valuables" => CATEGORY_IDENTIFIER.index("Valuables"),
"Weapons" => CATEGORY_IDENTIFIER.index("Weapons"),
"Gear" => CATEGORY_IDENTIFIER.index("Gear"),
"Shields" => CATEGORY_IDENTIFIER.index("Shields"),
"Helmets" => CATEGORY_IDENTIFIER.index("Helmets"),
"Armor" => CATEGORY_IDENTIFIER.index("Armor"),
"Accessories" => CATEGORY_IDENTIFIER.index("Accessories")
}

# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * #
# 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 exp​ression Definition
module Regexp
# Base Item Module
module BaseItem
# Category tag string
CATEGORY = /^<(?:CATEGORY|classification|category?)[ ]*(.*)>/i
end
end
end

#==============================================================================
# &#9632; RPG::BaseItem
#==============================================================================

class RPG::BaseItem
#--------------------------------------------------------------------------
#     &#12450;&#12452;&#12486;&#12512;&#20998;&#39006;&#12398;&#12461;&#12515;&#12483;&#12471;&#12517;&#65533;"&#65533;&#25104;
#--------------------------------------------------------------------------
def create_categorize_item_cache
if @__item_category == nil || !KGC::CategorizeItem::ENABLE_AUTO_CATEGORIZE
@__item_category = []
else
@__item_category.compact!
end

self.note.split(/[\r\n]+/).each { |line|
if line =~ KGC::CategorizeItem::Regexp::BaseItem::CATEGORY
# &#12459;&#12486;&#12468;&#12522;
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
# &#26368;&#24460;&#12395;&#25351;&#23450;&#12375;&#12383;&#12459;&#12486;&#12468;&#12522;&#12395;&#37197;&#32622;
@__item_category = [@__item_category.pop]
end
end
#--------------------------------------------------------------------------
#     &#12450;&#12452;&#12486;&#12512;&#12398;&#12459;&#12486;&#12468;&#12522;
#--------------------------------------------------------------------------
def item_category
create_categorize_item_cache if @__item_category == nil
return @__item_category
end
end

#==================================End Class===================================#

#==============================================================================
# &#9632; RPG::UsableItem
#==============================================================================

class RPG::UsableItem < RPG::BaseItem
#--------------------------------------------------------------------------
#     &#12450;&#12452;&#12486;&#12512;&#20998;&#39006;&#12398;&#12461;&#12515;&#12483;&#12471;&#12517;&#65533;"&#65533;&#25104;
#--------------------------------------------------------------------------
def create_categorize_item_cache
@__item_category = []
if self.price == 0
@__item_category << KGC::CategorizeItem::RESERVED_CATEGORY_INDEX["Valuables"]
end
super
end
end

#==================================End Class===================================#

#==============================================================================
# &#9632; RPG::Weapon
#==============================================================================

class RPG::Weapon < RPG::BaseItem
#--------------------------------------------------------------------------
#     &#12450;&#12452;&#12486;&#12512;&#20998;&#39006;&#12398;&#12461;&#12515;&#12483;&#12471;&#12517;&#65533;"&#65533;&#25104;
#--------------------------------------------------------------------------
def create_categorize_item_cache
@__item_category = []
@__item_category << KGC::CategorizeItem::RESERVED_CATEGORY_INDEX["Weapon"]
super
end
end

#==================================End Class===================================#

#==============================================================================
# &#9632; RPG::Armor
#==============================================================================

class RPG::Armor < RPG::BaseItem
#--------------------------------------------------------------------------
#     &#12450;&#12452;&#12486;&#12512;&#20998;&#39006;&#12398;&#12461;&#12515;&#12483;&#12471;&#12517;&#65533;"&#65533;&#25104;
#--------------------------------------------------------------------------
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
end
end

#==================================End Class===================================#

#==============================================================================
# &#9632; Window_Item
#==============================================================================

class Window_Item < Window_Selectable
#--------------------------------------------------------------------------
# &#9679; &#20844;&#38283;&#12452;&#12531;&#12473;&#12479;&#12531;&#12473;&#22793;&#25968;
#--------------------------------------------------------------------------
attr_reader :category # &#12459;&#12486;&#12468;&#12522;
#--------------------------------------------------------------------------
# &#9679; &#12458;&#12502;&#12472;&#12455;&#12463;&#12488;&#21021;&#26399;&#21270;
# x : &#12454;&#12451;&#12531;&#12489;&#12454;&#12398; X &#24231;&#27161;
# y : &#12454;&#12451;&#12531;&#12489;&#12454;&#12398; Y &#24231;&#27161;
# width : &#12454;&#12451;&#12531;&#12489;&#12454;&#12398;&#24133;
# height : &#12454;&#12451;&#12531;&#12489;&#12454;&#12398;&#39640;&#12373;
#--------------------------------------------------------------------------
alias initialize_KGC_CategorizeItem initialize
def initialize(x, y, width, height)
@category = 0

initialize_KGC_CategorizeItem(x, y, width, height)
end
#--------------------------------------------------------------------------
#     &#12459;&#12486;&#12468;&#12522;&#35373;&#23450;
#--------------------------------------------------------------------------
def category=(value)
@category = value
refresh
end
#--------------------------------------------------------------------------
# &#9679; &#12450;&#12452;&#12486;&#12512;&#65533;'&#12522;&#12473;&#12488;&#12395;&#21547;&#12417;&#12427;&#12363;&#12393;&#12358;&#12363;
# item : &#12450;&#12452;&#12486;&#12512;
#--------------------------------------------------------------------------
alias include_KGC_CategorizeItem? include?
def include?(item)
return false if item == nil

# &#12300;&#20840;&#31278;&#12301;&#12394;&#12425;&#28961;&#26465;&#20214;&#12391;&#21547;&#12417;&#12427;
if @category == KGC::CategorizeItem::RESERVED_CATEGORY_INDEX["All Items"]
return true
end

result = include_KGC_CategorizeItem?(item)

unless result
# &#20351;&#65533;"&#65533;&#21487;&#33021;&#12394;&#12425;&#36861;&#21152;&#20505;&#35036;&#12392;&#12377;&#12427;
if $imported["UsableEquipment"] && $game_party.item_can_use?(item)
result = true
end
end
# &#25126;&#38360;&#22806;&#12394;&#12425;&#12459;&#12486;&#12468;&#12522;&#19968;&#33268;&#21028;&#23450;
unless $game_temp.in_battle
result &= (item.item_category.include?(@category))
end

return result
end
end

#==================================End Class===================================#

#==============================================================================
# &#9633; Window_ItemCategory
#------------------------------------------------------------------------------
# &#12288;&#12450;&#12452;&#12486;&#12512;&#65533;"&#65533;&#38754;&#12391;&#12459;&#12486;&#12468;&#12522;&#36984;&#25246;&#65533;'&#34892;&#12358;&#12454;&#12451;&#12531;&#12489;&#12454;&#12391;&#12377;&#12290;
#==============================================================================

class Window_ItemCategory < Window_Command
#--------------------------------------------------------------------------
# &#9679; &#12458;&#12502;&#12472;&#12455;&#12463;&#12488;&#21021;&#26399;&#21270;
#--------------------------------------------------------------------------
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
#--------------------------------------------------------------------------
# &#9679; &#12504;&#12523;&#12503;&#12486;&#12461;&#12473;&#12488;&#26356;&#26032;
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(KGC::CategorizeItem::CATEGORY_DESCRIPTION[self.index])
end
end

#==================================End Class===================================#

#==============================================================================
# &#9632; Scene_Item
#==============================================================================

class Scene_Item < Scene_Base
#--------------------------------------------------------------------------
# &#9679; &#38283;&#22987;&#20966;&#29702;
#--------------------------------------------------------------------------
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
#--------------------------------------------------------------------------
# &#9679; &#32066;&#20102;&#20966;&#29702;
#--------------------------------------------------------------------------
alias terminate_KGC_CategorizeItem terminate
def terminate
terminate_KGC_CategorizeItem

@category_window.dispose
end
#--------------------------------------------------------------------------
# &#9679; &#12501;&#12524;&#12540;&#12512;&#26356;&#26032;
#--------------------------------------------------------------------------
alias update_KGC_CategorizeItem update
def update
@category_window.update

update_KGC_CategorizeItem

if @category_window.active
update_category_selection
end
end
#--------------------------------------------------------------------------
#     &#12459;&#12486;&#12468;&#12522;&#36984;&#25246;&#12398;&#26356;&#26032;
#--------------------------------------------------------------------------
def update_category_selection
unless @category_activated
@category_activated = true
return
end

# &#36984;&#25246;&#12459;&#12486;&#12468;&#12522;&#12540;&#22793;&#26356;
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:: 
Sound.play_cancel
return_scene
elsif Input.trigger?(Input::C)
Sound.play_decision
hide_category_window
end
end
#--------------------------------------------------------------------------
# &#9679; &#12450;&#12452;&#12486;&#12512;&#36984;&#25246;&#12398;&#26356;&#26032;
#--------------------------------------------------------------------------
alias update_item_selection_KGC_CategorizeItem update_item_selection
def update_item_selection
if Input.trigger?(Input:: 
Sound.play_cancel
show_category_window
return
end

update_item_selection_KGC_CategorizeItem
end
#--------------------------------------------------------------------------
#     &#12459;&#12486;&#12468;&#12522;&#12454;&#12451;&#12531;&#12489;&#12454;&#12398;&#34920;&#31034;
#--------------------------------------------------------------------------
def show_category_window
@category_window.open
@category_window.active = true
@item_window.active = false
end
#--------------------------------------------------------------------------
#     &#12459;&#12486;&#12468;&#12522;&#12454;&#12451;&#12531;&#12489;&#12454;&#12398;&#38750;&#34920;&#31034;
#--------------------------------------------------------------------------
def hide_category_window
@category_activated = false
@category_window.close
@category_window.active = false
@item_window.active = true
# &#12450;&#12452;&#12486;&#12512;&#12454;&#12451;&#12531;&#12489;&#12454;&#12398;&#12452;&#12531;&#12487;&#12483;&#12463;&#12473;&#65533;'&#35519;&#25972;
if @item_window.index >= @item_window.item_max
@item_window.index = [@item_window.item_max - 1, 0].max
end
end
end

#==================================End Class===================================#

#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_
#_/ The original untranslated version of this script can be found here:
# http://f44.aaa.livedoor.jp/~ytomy/tkool/rp...categorize_item
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_

________________________
"Na trolla pewne są tylko dwie pewne metody, jedna samopowtarzalna i druga, wymagająca przeładowania ręcznego."


 
 
mazik 



Preferowany:
RPG Maker VX

Dołączył: 21 Cze 2011
Posty: 17
Wysłany: Czw 23 Cze, 2011 14:06
Która linijka ?
________________________
Mazik ;)
 
 
 
mazik 



Preferowany:
RPG Maker VX

Dołączył: 21 Cze 2011
Posty: 17
Wysłany: Czw 23 Cze, 2011 14:07
Bo mam kumpla programiste to morze cos z tym skryptem zrobi...
________________________
Mazik ;)
 
 
 
Angius 

Nie wkurzać



Preferowany:
RPG Maker VX

Pomógł: 104 razy
Dołączył: 30 Paź 2010
Posty: 1276
Skąd: wROCK
Wysłany: Czw 23 Cze, 2011 16:54
Masz taki sprytny guziczek nad postem , używaj go.

A syntax przy linijce z nazwą tagu, tak jak pisałem. To była bodaj 26
________________________
"Na trolla pewne są tylko dwie pewne metody, jedna samopowtarzalna i druga, wymagająca przeładowania ręcznego."


 
 
mazik 



Preferowany:
RPG Maker VX

Dołączył: 21 Cze 2011
Posty: 17
Wysłany: Czw 23 Cze, 2011 17:13
ok to na jutro albo troszke pozniej juz bedzie przerobiony ale nie obiecuje a co do kumpla to powinien umiec poprawic ten skrypt
________________________
Mazik ;)
 
 
 
Angius 

Nie wkurzać



Preferowany:
RPG Maker VX

Pomógł: 104 razy
Dołączył: 30 Paź 2010
Posty: 1276
Skąd: wROCK
Wysłany: Sro 29 Cze, 2011 13:09
Zamykam, dało radę...
________________________
"Na trolla pewne są tylko dwie pewne metody, jedna samopowtarzalna i druga, wymagająca przeładowania ręcznego."


 
 
Wyświetl posty z ostatnich:   
Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi
Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Nie możesz załączać plików na tym forum
Możesz ściągać załączniki na tym forum
Dodaj temat do Ulubionych
Wersja do druku

Skocz do:  

Powered by phpBB modified by Przemo © 2003 phpBB Group | Template Klam by Ayene