Partagez
Aller en bas
Joeypixel
Joeypixel
Membre

Nombre de messages : 172
Distinction : aucune
Date d'inscription : 09/04/2008

"Banque" d'objets Empty "Banque" d'objets

le Mer 9 Sep 2009 - 12:20
Salut à tous !
J'étais depuis un moment à la recherche d'un script me permettant de stocker des objets dans une sorte de "banque" mais je n'en ai pas trouvé (du moins, pas qui me convienne). J'en ai trouvé un sur un autre site de making. Il est de "Breadlord" (n'oubliez pas de le citer dans vos crédits !!!) et je voulais le partager avec vous.

Utilisation :

A mettre au dessus de "Main".

Quand vous voulez appeler ce script, vous faites un événement en deux onglets.


onglet 1 : Pas de conditions
Appeler script :
"$stores['Pantry2'] = Store.new({3 => 5, 4=>
2},{},{},5,3)
$store = 'Pantry2'
$scene = Scene_Store.new"
Interrupteur local A activé

onglet 2 : Condition : Interrupteur local A activé
Appeler script :
"$store = 'Pantry2'
$scene = Scene_Store.new"

(Merci à Dricc pour les explications...)

Voici le code :

Code:

####################### Breadlord's Item storage Script ########################
## This script allows the player to store and remove items (and weapons and ##
## armours) in stores you set up in events. You set up a store in this format ##
## : $stores['store name'] = Store.new({items allready stored}, {Weapons ##
## allready stored}), {armours allready stored}, max items, [tag1, tag2, ect] ##
## ,[anti tag 1, anti tag 2, ect). For items and weapons allready stored ect ##
## use the format {id => amount, id => amount , ect}. For max items, put the ##
## maximum items you can store, you can leave this blank or put -1 to have ##
## unlimited storage. For the tags you can put whatever you like, if you ##
## enter tags then it will only let items with those tags in ther notes be ##
## stored. Anti tags are the opisite of tags, if you put them in they will ##
## disalow all items with Item Exclude>anti tag in there notes To put the ##
## tags in the items notes, put Item Type>tag in the notes field. Note, you ##
## can leave all the feilds blank. To call up the item storage scene use ##
## $store = 'name of store' then $scene = Scene_Store.new, were name of store ##
## is the name of the item store you want the player to access. ##
################################################################################
############################## Do not edit #####################################
################################################################################

class Window_party_title < Window_Base

def initialize

super(0, 0, 544, 64)
self.contents.font.color = normal_color
if $stores[$store].max == -1
self.contents.draw_text(0, 0, 272, 32, "Party Items", 1)
self.contents.draw_text(272, 0, 272, 32, $store, 1)
else
a = $stores[$store].max
a = a.to_s
self.contents.draw_text(0, 0, 272, 32, "Party Items", 1)
self.contents.draw_text(272, 0, 272, 32, $store + ', Max = ' + a, 1)
end

end

end


class Window_Item_Number < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
# x : window X coordinate
# y : window Y coordinate
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y, 304, 100)
@item = nil
@max = 1
@number = 1
end
#--------------------------------------------------------------------------
# * Set Items, Max Quantity, and Price
#--------------------------------------------------------------------------
def set(item, max)
@item = item
@max = max
@number = 1
refresh
end
#--------------------------------------------------------------------------
# * Set Inputted Quantity
#--------------------------------------------------------------------------
def number
return @number
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
y = 25
self.contents.clear
draw_item_name(@item, 0, y)
self.contents.font.color = normal_color
self.contents.draw_text(160, y, 20, WLH, "")
self.contents.draw_text(208, y, 20, WLH, @number, 2)
self.cursor_rect.set(208, y, 28, WLH)
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
if self.active
last_number = @number
if Input.repeat?(Input::RIGHT) and @number < @max
@number += 1
end
if Input.repeat?(Input::LEFT) and @number > 1
@number -= 1
end
if Input.repeat?(Input::UP) and @number < @max
@number = [@number + 10, @max].min
end
if Input.repeat?(Input::DOWN) and @number > 1
@number = [@number - 10, 1].max
end
if @number != last_number
Sound.play_cursor
refresh
end
end
end
end



class Window_Help_New < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(x,y,w,l)
super(x, y, w, l)
@type = type
end
#--------------------------------------------------------------------------
# * Set Text
# text : character string displayed in window
# align : alignment (0..flush left, 1..center, 2..flush right)
#--------------------------------------------------------------------------
def set_text(text, align = 0, item = nil)
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)
if item != nil
draw_icon(item.icon_index, 4, WLH*2)
a = $game_party.item_number(item)
a = a.to_s
self.contents.draw_text(26, WLH*2, self.width - 40, WLH, ': ' + a)
a = A3D.gnd( item, 'Item Type', true )
if a == ''
a = 'None'
end
draw_icon(item.icon_index, 4, WLH*4)
self.contents.draw_text(26, WLH*4, self.width - 40, WLH, ': ' + a)
draw_icon(71, 4, WLH*6)
a = item.price
a = a.to_s
self.contents.draw_text(26, WLH*6, self.width - 40, WLH, ': ' + a)
end
@text = text
@align = align
end
end
end



class Window_Help_New2 < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(x,y,w,l)
super(x, y, w, l)
@type = type
end
#--------------------------------------------------------------------------
# * Set Text
# text : character string displayed in window
# align : alignment (0..flush left, 1..center, 2..flush right)
#--------------------------------------------------------------------------
def set_text(text, align = 0, item = nil)
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)
if item != nil
draw_icon(item.icon_index, 4, WLH*2)
a = $stores[$store].item_number(item)
a = a.to_s
b = $stores[$store].stack
b = b.to_s
self.contents.draw_text(26, WLH*2, self.width - 40, WLH, ': ' + a + ' / ' + b)
a = A3D.gnd( item, 'Item Type', true )
if a == ''
a = 'None'
end
draw_icon(item.icon_index, 4, WLH*4)
self.contents.draw_text(26, WLH*4, self.width - 40, WLH, ': ' + a)
draw_icon(71, 4, WLH*6)
a = item.price
a = a.to_s
self.contents.draw_text(26, WLH*6, self.width - 40, WLH, ': ' + a)
end
@text = text
@align = align
end
end
end





class Window_Item_show < Window_Selectable

def initialize(x, y, width, height, column_max = 2, index = 0)
super(x, y, width, height)
@column_max = column_max
self.index = index
refresh
end

#--------------------------------------------------------------------------
# * Get Item
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# * Whether or not to include in item list
# item : item
#--------------------------------------------------------------------------
def include?(item)
return false if item == nil
if $game_temp.in_battle
return false unless item.is_a?(RPG::Item)
end
return true
end
#--------------------------------------------------------------------------
# * Whether or not to display in enabled state
# item : item
#--------------------------------------------------------------------------
def enable?(item)
a = A3D.gnd( item, 'Item Type', true )
c = A3D.gnd( item, 'Exclude Type', true )
b = $stores[$store].tags
d = $stores[$store].anti_tags
zz = false
if !(b == false)
for i in 0..b.size - 1
for jj in 0..d.size - 1
if a == b[i] and !(a == nil) and c != d[jj] and
zz = true
end
end
end
if zz
return true
else
return false
end
else
return true
end
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
@data = []
for item in $game_party.items
next unless include?(item)
@data.push(item)
if item.is_a?(RPG::Item) and item.id == $game_party.last_item_id
self.index = @data.size - 1
end
end
@data.push(nil) if include?(nil)
@item_max = @data.size
create_contents
for i in 0...@item_max
draw_item(i)
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
item = @data[index]
if item != nil
number = $game_party.item_number(item)
enabled = enable?(item)
rect.width -= 4
draw_item_name(item, rect.x, rect.y, enabled)
self.contents.draw_text(rect, sprintf(":%2d", number), 2)
end
end
#--------------------------------------------------------------------------
# * Update Help Text
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(item == nil ? "" : item.description, 1, item)
end
end



class Scene_Store < Scene_Base

def start
super
create_menu_background
@item_window = Window_Item_show.new(0,64,272,352, 1)
@storage_window = Window_Storage.new(272,64,272,352,$store)
@number_window = Window_Item_Number.new( 120, 153)
@item_help = Window_Help_New.new(272, 208, 272, 208)
@store_help = Window_Help_New2.new(0, 208, 272, 208)
@item_help.z = 200
@store_help.z = 200
@item_window.help_window = @item_help
@storage_window.help_window = @store_help
@store_help.visible = false
@party_title = Window_party_title.new
@number_window.z = 300
@number_window.visible = false
@number_window.active = false
@item_window.active = true
@storage_window.active = false
end

def enable?(item)
a = A3D.gnd( item, 'Item Type', true )
c = A3D.gnd( item, 'Exclude Type', true )
b = $stores[$store].tags
d = $stores[$store].anti_tags
zz = false
if !(b == false)
for i in 0..b.size - 1
for jj in 0..d.size - 1
if a == b[i] and !(a == nil) and c != d[jj] and
zz = true
end
end
end
if zz
return true
else
return false
end
else
return true
end
end

def update
super
update_menu_background
@item_window.update
@storage_window.update
if Input.trigger?(Input:: B) and @number_window.active == false
Sound.play_cancel
@item_window.dispose
@party_title.dispose
@storage_window.dispose
@number_window.dispose
@item_help.dispose
@store_help.dispose
$scene = Scene_Map.new
elsif @item_window.active
@item_help.visible = true
@store_help.visible = false
@item_help.update
update_item_window
elsif @storage_window.active
@store_help.update
@store_help.visible = true
@item_help.visible = false
update_store_window
elsif @number_window.active
@number_window.update
update_number_window
end
end

def update_number_window
if Input.trigger?(Input:: B)
Sound.play_cancel
@number_window.visible = false
@item_window.active = true
@storage_window.active = false
@number_window.active = false
elsif Input.trigger?(Input::C)
Sound.play_decision
if @from == 'item'
$game_party.gain_item(@item_window.item, -@number_window.number)
$stores[$store].gain_item(@item_window.item, @number_window.number)
@number_window.visible = false
index = @item_window.index
@item_window.dispose
@storage_window.dispose
@item_window = Window_Item_show.new(0,64,272,352, 1, index)
@storage_window = Window_Storage.new(272,64,272,352,$store)
@item_window.active = true
@storage_window.active = false
@number_window.active = false
@item_help.dispose
@store_help.dispose
@item_help = Window_Help_New.new(272, 208, 272, 208)
@store_help = Window_Help_New2.new(0, 208, 272, 208)
@item_help.z = 200
@store_help.z = 200
@item_window.help_window = @item_help
@storage_window.help_window = @store_help
else
$stores[$store].gain_item(@storage_window.item,-@number_window.number)
$game_party.gain_item(@storage_window.item, @number_window.number)
@number_window.visible = false
index = @storage_window.index
@item_window.dispose
@storage_window.dispose
@item_window = Window_Item_show.new(0,64,272,352, 1)
@storage_window = Window_Storage.new(272,64,272,352,$store, index)
@item_window.active = false
@storage_window.active = true
@number_window.active = false
@item_help.dispose
@store_help.dispose
@item_help = Window_Help_New.new(272, 208, 272, 208)
@store_help = Window_Help_New2.new(0, 208, 272, 208)
@item_help.z = 200
@store_help.z = 200
@item_window.help_window = @item_help
@storage_window.help_window = @store_help
end
end
end

def update_item_window
if Input.trigger?(Input::RIGHT)
Sound.play_cursor
@item_window.active = false
@storage_window.active = true
elsif Input.trigger?(Input::LEFT)
Sound.play_cursor
@item_window.active = false
@storage_window.active = true
elsif Input.trigger?(Input::C)
item = @item_window.item
if $stores[$store].max == -1 or $stores[$store].max - 1 > $stores[$store].all.size - 1 and $stores[$store].item_number(item) < $stores[$store].stack
if !(item == nil) and enable?(item)
@from = 'item'
num = $stores[$store].item_number(item)
max_stack = $stores[$store].stack
max = max_stack - num
if $game_party.item_number(item) < max
max = $game_party.item_number(item)
end
@number_window.set(item, max)
@number_window.visible = true
@item_window.active = false
@storage_window.active = false
@number_window.active = true
Sound.play_decision
else
Sound.play_buzzer
end
else
Sound.play_buzzer
end
end
end

def update_store_window
if Input.trigger?(Input::LEFT)
Sound.play_cursor
@item_window.active = true
@storage_window.active = false
elsif Input.trigger?(Input::RIGHT)
Sound.play_cursor
@item_window.active = true
@storage_window.active = false
elsif Input.trigger?(Input::C)
item = @storage_window.item
if !(item == nil) and enable?(item)
@from = 'store'
max = $stores[$store].item_number(item)
@number_window.set(item, max)
@number_window.visible = true
@item_window.active = false
@storage_window.active = false
@number_window.active = true
Sound.play_decision
else
Sound.play_buzzer
end
end
end

end






class Store

attr_accessor :items, :weapons, :armors, :max, :stack, :tags, :anti_tags

def initialize(items = {}, weapons = {}, armors = {}, max = -1, stack = 99999999, tags = [false], anti_tags = [])
@items = {}
@weapons = {}
@armors = {}
@all = []
@max = max
@stack = stack

if tags[0] == false
@tags = false
else
@tags = tags
end

if anti_tags[0] == false
@anti_tags = false
else
@anti_tags = anti_tags
end

for i in items.keys
@items[i] = items[i]
end

for i in weapons.keys
@weapons[i] = weapons[i]
end

for i in armors.keys
@armors[i] = armors[i]
end

end

def all
com = []
for i in @items.keys.sort
com.push($data_items[i]) if @items[i] > 0
end
for i in @weapons.keys.sort
com.push($data_weapons[i]) if @weapons[i] > 0
end
for i in @armors.keys.sort
com.push($data_armors[i]) if @armors[i] > 0
end
return com
end

def item_number(item)
case item
when RPG::Item
number = @items[item.id]
when RPG::Weapon
number = @weapons[item.id]
when RPG::Armor
number = @armors[item.id]
end
return number == nil ? 0 : number
end

def gain_item(item, n)
number = item_number(item)
case item
when RPG::Item
@items[item.id] = [[number + n, 0].max, 99].min
when RPG::Weapon
@weapons[item.id] = [[number + n, 0].max, 99].min
when RPG::Armor
@armors[item.id] = [[number + n, 0].max, 99].min
end
n += number
end

end




#==============================================================================
# ** Window_Item
#------------------------------------------------------------------------------
# This window displays a list of inventory items for the item screen, etc.
#==============================================================================

class Window_Storage < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
# x : window x-coordinate
# y : window y-coordinate
# width : window width
# height : window height
#--------------------------------------------------------------------------
def initialize(x, y, width, height, store, index = 0)
super(x, y, width, height)
@column_max = 1
self.index = index
@store = store
refresh
end
#--------------------------------------------------------------------------
# * Get Item
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# * Whether or not to include in item list
# item : item
#--------------------------------------------------------------------------
def include?(item)
return false if item == nil
if $game_temp.in_battle
return false unless item.is_a?(RPG::Item)
end
return true
end
#--------------------------------------------------------------------------
# * Whether or not to display in enabled state
# item : item
#--------------------------------------------------------------------------
def enable?(item)
a = A3D.gnd( item, 'Item Type', true )
c = A3D.gnd( item, 'Exclude Type', true )
b = $stores[$store].tags
d = $stores[$store].anti_tags
zz = false
if !(b == false)
for i in 0..b.size - 1
for jj in 0..d.size - 1
if a == b[i] and !(a == nil) and c != d[jj] and
zz = true
end
end
end
if zz
return true
else
return false
end
else
return true
end
end

#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
@data = []
for item in $stores[$store].all
next unless include?(item)
@data.push(item)
if item.is_a?(RPG::Item) and item.id == $game_party.last_item_id
self.index = @data.size - 1
end
end
@data.push(nil) if include?(nil)
@item_max = @data.size
create_contents
for i in 0...@item_max
draw_item(i)
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
item = @data[index]
if item != nil
number = $stores[@store].item_number(item)
enabled = enable?(item)
rect.width -= 4
draw_item_name(item, rect.x, rect.y, enabled)
self.contents.draw_text(rect, sprintf(":%2d", number), 2)
end
end
#--------------------------------------------------------------------------
# * Update Help Text
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(item == nil ? "" : item.description, 1, item)
end
end







class Scene_Title < Scene_Base

alias new_game command_new_game

def command_new_game
$stores = {}
new_game
end

end



class Scene_File < Scene_Base

alias save write_save_data
alias load read_save_data

def write_save_data(file)
save(file)
Marshal.dump($stores, file)
end

def read_save_data(file)
load(file)
$stores = Marshal.load(file)
end

end










#===========================================================================
# A3D's Get Note Data
#
# << Version >>
# : 1.2
#
# << Useful >>
# allow you to set-up your new data in note area
# it will make your data in each item unlimitable
#
# << General Command >>
# : A3D.gnd( [/type, /id], /code, /string )
# : A3D.gnd( /item , /code, /string )
# /type = type of your item
# (1 = skill, 2 = item , 3 = weapon,
# (4 = armor, 5 = enemy, 6 = state)
# /id = id of your item
# /code = code to call your data
# /string = if you're expect an alphabet data (not number), set it true
# /item = $data object of your item (not $game)
#
# << How to Use >>
# in "note" area in each "item", write your code & data in this format
# : your_code>your_data
# example, second enemy in enemy's database, you have
# : AP>10
# : WD>SLASH
# you can pick-up each data by the following command
# : A3D.gnd([5,2], "AP")
# : A3D.gnd([5,2], "WD", true)
# or : enemy = $data_enemies[2]
# : A3D.gnd(enemy, "AP")
# : A3D.gnd(enemy, "WD", true)
#
# << Note >>
# this script is for non-commercial use only, give credit if use
#
# << Contact >>
# A3D (hyper_s@hotmail.com)
#===========================================================================

module A3D
#--------------------------------------------------------------------------
# * Get Note Data
#--------------------------------------------------------------------------
def A3D.gnd(item, code, string = false)
if item.is_a?(Array)
case item[0]
when 1 then item = $data_skills[item[1]]
when 2 then item = $data_items[item[1]]
when 3 then item = $data_weapons[item[1]]
when 4 then item = $data_armors[item[1]]
when 5 then item = $data_enemies[item[1]]
when 6 then item = $data_states[item[1]]
end
end
item.note.split(/[\r\n]+/).each do |line|
if line.split(/[>]/)[0] == code
data = line.split(/[>]/)[1]
return string ? data : data.to_i
end
end
return string ? "" : 0
end

end








Dernière édition par Joeypixel le Jeu 10 Sep 2009 - 14:03, édité 1 fois
dricc
dricc
Membre

Nombre de messages : 2757
Localisation : Lille
Distinction : Altruiste - Incarnation de la Patience [Mist']
Date d'inscription : 10/08/2009

"Banque" d'objets Empty Re: "Banque" d'objets

le Mer 9 Sep 2009 - 13:26
Je connais le script shopoholic qui fait ce que tu veux :
http://www.rpgrevolution.com/forums/index.php?showtopic=14016&hl=shopoholic
Dans les magasins , y'a une banque et dans cette banque , on peux stocker des objets . on peux meme acheter des slots pour stocker plus , moi ,je trouve ça trés bien .

Ton script , je l'ai trouvé aussi sur le meme forum .
Et y'a une capture d'écran qui explique comment ça marche :
"Banque" d'objets Editorsnap

Et mieux , y'a une démo :
http://www.mediafire.com/download.php?jtmnozkgzmj
Joeypixel
Joeypixel
Membre

Nombre de messages : 172
Distinction : aucune
Date d'inscription : 09/04/2008

"Banque" d'objets Empty Re: "Banque" d'objets

le Mer 9 Sep 2009 - 13:58
Ah ben ok, en fait c'était assez simple... Merci pour les précisions ^^
Batman
Batman
Membre

Nombre de messages : 4
Distinction : aucune
Date d'inscription : 01/09/2009

"Banque" d'objets Empty Re: "Banque" d'objets

le Mer 9 Sep 2009 - 16:46
Ce script est bien mais il y a un probleme. Je place des objets dans la banque, ça c'est ok mais quand je veux aller les recherché ils ne sont plus là !
dricc
dricc
Membre

Nombre de messages : 2757
Localisation : Lille
Distinction : Altruiste - Incarnation de la Patience [Mist']
Date d'inscription : 10/08/2009

"Banque" d'objets Empty Re: "Banque" d'objets

le Mer 9 Sep 2009 - 16:54
T'as raison , ça le fait meme sur la démo !

se rabattre sur le "shopoholic" me semble mieux ...

EDIT : bon aprés étude du code , j'ai trouvé .
La démo est foireuse Smile

Donc , l'event de votre coffre , a 2 onglets :
1 : Pas de conditions
Appeler script :
"$stores['Pantry2'] = Store.new({3 => 5, 4=>
2},{},{},5,3)
$store = 'Pantry2'
$scene = Scene_Store.new"
Interrupteur local A activé
2 : Interrupteur local A activé
Appeler script :
"$store = 'Pantry2'
$scene = Scene_Store.new"

Et ça marche !
Batman
Batman
Membre

Nombre de messages : 4
Distinction : aucune
Date d'inscription : 01/09/2009

"Banque" d'objets Empty Re: "Banque" d'objets

le Mer 9 Sep 2009 - 17:12
Waaah! Merci ça marche !!
Yoshi-Dragon
Yoshi-Dragon
Membre

Nombre de messages : 752
Age : 23
Localisation : J'ai peur.
Distinction : aucune
Date d'inscription : 19/06/2009
http://smashbrosbrawl.e-monsite.com

"Banque" d'objets Empty Re: "Banque" d'objets

le Mer 9 Sep 2009 - 18:40
Olala que dire si ce n'est que je suis ravi !!!
Ton script est vraiment cool j'ai plus qu'a l'essaye aussi !!
Joeypixel
Joeypixel
Membre

Nombre de messages : 172
Distinction : aucune
Date d'inscription : 09/04/2008

"Banque" d'objets Empty Re: "Banque" d'objets

le Jeu 10 Sep 2009 - 14:11
Yoshi-Dragon : Ce script n'est pas de moi (je suis une huître en codage ) mais de Breadlord.
dricc : Merci pour ton aide, j'ai édité le premier message pour y mettre l'utilisation...
Contenu sponsorisé

"Banque" d'objets Empty Re: "Banque" d'objets

Revenir en haut
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum