| Gérer plusieurs inventaires | |
|
Auteur | Message |
---|
Zexion Administrateur
Messages postés : 6228 Date d'inscription : 04/01/2012 Jauge LPC :
| Sujet: Gérer plusieurs inventaires Sam 13 Juil 2013 - 23:36 | |
| Auteur : Fomar0153, merci de ne pas l'oublier dans vos crédits ! Ce script vous permet d'avoir plusieurs inventaires, de passer de l'un à l'autre à votre guise, mais aussi de les fusionner par exemple. Note : la quantité d'argent est également gérée dans ce système, et est rattachée à chaque inventaire. Le script : - Code:
-
=begin Multiple Inventories by Fomar0153 Version 1.1 ---------------------- Notes ---------------------- Allows you to easily handle multiple inventories in game. ---------------------- Instructions ---------------------- The default inventory is called "Main" you can change it below if you wish. To change inventory call: $game_party.change_inventory(name) To merge two inventories call: $game_party.merge_inventories(inv1, inv2) inv1 will recieve all the gold and items in inv2 If ERASE_WHEN_MERGE is set to true then inv2 will be erased after the merge. ---------------------- Change Log ---------------------- 1.0 -> 1.1 Updated a glitch causing gold not to change when you change inventory. ---------------------- Known bugs ---------------------- None =end class Game_Party < Game_Unit #-------------------------------------------------------------------------- # ● Set the name of your starting inventory here #-------------------------------------------------------------------------- START_INVENTORY = "Main" #-------------------------------------------------------------------------- # ● Set the name of your starting inventory here #-------------------------------------------------------------------------- ERASE_WHEN_MERGE = true #-------------------------------------------------------------------------- # ● Aliased #-------------------------------------------------------------------------- alias mi_initialize initialize def initialize mi_initialize @current_inventory = START_INVENTORY @gold = {} @gold[START_INVENTORY] = 0 @last_item = Game_BaseItem.new end #-------------------------------------------------------------------------- # ● New, example call $game_party.change_inventory(name) #-------------------------------------------------------------------------- def change_inventory(name) if @gold[name].nil? @gold[name] = 0 @items[name] = {} @weapons[name] = {} @armors[name] = {} end @current_inventory = name end #-------------------------------------------------------------------------- # ● New, example call $game_party.merge_inventories(inv1, inv2) #-------------------------------------------------------------------------- def merge_inventories(inv1, inv2) return if @gold[inv1].nil? or @gold[inv2].nil? @current_inventory = inv1 @gold[inv1] += @gold[inv2] @gold[inv2] = nil if ERASE_WHEN_MERGE for item in @items[inv2].keys gain_item($data_items[item.to_i], @items[inv2][item]) end @items[inv2] = nil if ERASE_WHEN_MERGE for weapon in @weapons[inv2].keys gain_item($data_weapons[weapon.to_i], @weapons[inv2][weapon]) end @weapons[inv2] = nil if ERASE_WHEN_MERGE for armor in @armors[inv2].keys gain_item($data_armors[armor.to_i], @armors[inv2][armor]) end @armors[inv2] = nil if ERASE_WHEN_MERGE end #-------------------------------------------------------------------------- # ● Aliased #-------------------------------------------------------------------------- alias mi_init_all_items init_all_items def init_all_items mi_init_all_items @items[START_INVENTORY] = {} @weapons[START_INVENTORY] = {} @armors[START_INVENTORY] = {} end #-------------------------------------------------------------------------- # ● New #-------------------------------------------------------------------------- def gold return @gold[@current_inventory] end #-------------------------------------------------------------------------- # ● Rewrites #-------------------------------------------------------------------------- def items @items[@current_inventory].keys.sort.collect {|id| $data_items[id] } end #-------------------------------------------------------------------------- # ● Rewrites #-------------------------------------------------------------------------- def weapons @weapons[@current_inventory].keys.sort.collect {|id| $data_weapons[id] } end #-------------------------------------------------------------------------- # ● Rewrites #-------------------------------------------------------------------------- def armors @armors[@current_inventory].keys.sort.collect {|id| $data_armors[id] } end #-------------------------------------------------------------------------- # ● Rewrites #-------------------------------------------------------------------------- def item_container(item_class) return @items[@current_inventory] if item_class == RPG::Item return @weapons[@current_inventory] if item_class == RPG::Weapon return @armors[@current_inventory] if item_class == RPG::Armor return nil end #-------------------------------------------------------------------------- # ● Rewrites #-------------------------------------------------------------------------- def gain_gold(amount) @gold[@current_inventory] = [[@gold[@current_inventory] + amount, 0].max, max_gold].min end end
Pour changer d'inventaire, utilisez la ligne de script : - Code:
-
$game_party.change_inventory(nom_de_l_inventaire) Remplacez "nom_de_l_inventaire" par le nom de l'inventaire à utiliser. Si cet inventaire n'existe pas encore, il sera créé. Le nom de l'inventaire de départ, au lancement du jeu, est "Main". Cela peut-être modifié à la ligne vers le début du script : - Code:
-
START_INVENTORY = "Main" Pour fusionner deux inventaires, utilisez la commande : - Code:
-
$game_party.merge_inventories(inv1, inv2) Où "inv1" et "inv2" sont le nom des deux inventaires à fusionner. Ils seront fusionnés dans "inv1", tandis que "inv2" sera supprimé. Bon making ! |
|
| |
Choco-sama Ancien staffeux
Messages postés : 3012 Date d'inscription : 19/10/2009 Jauge LPC :
| Sujet: Re: Gérer plusieurs inventaires Sam 13 Juil 2013 - 23:40 | |
| |
|
| |
Cataclysm Chevalier (niveau 4)
Messages postés : 121 Date d'inscription : 25/07/2011 Jauge LPC :
| Sujet: Re: Gérer plusieurs inventaires Lun 15 Juil 2013 - 14:06 | |
| J'utilsie ce script pour Noctis, il est très pratique ! Ca permet de gérer plusieurs personnages jouables alternativement (comme dans Noctis ^^) ! |
|
| |
mario5102 Paysan (niveau 4)
Messages postés : 36 Date d'inscription : 25/11/2013 Jauge LPC :
| Sujet: Re: Gérer plusieurs inventaires Lun 25 Nov 2013 - 17:43 | |
| salut ce script à vraiment l'air pas mal mais petit problème avec le script pour moi : Un moyen de régler ça ? :/ |
|
| |
Donchouwa Chevalier (niveau 2)
Messages postés : 88 Date d'inscription : 19/11/2013 Jauge LPC :
| Sujet: Re: Gérer plusieurs inventaires Lun 25 Nov 2013 - 18:05 | |
| Tu as enlevé le "=" avant le begin de la première ligne ? Et remplacé par "#" Le début de chaque ligne, mets un "#" jusqu'à =end, la aussi tu remplaces "=" par "#"
Je sais pas pourquoi mais, les scripts ne prennent plus en compte les "=" |
|
| |
mario5102 Paysan (niveau 4)
Messages postés : 36 Date d'inscription : 25/11/2013 Jauge LPC :
| Sujet: Re: Gérer plusieurs inventaires Lun 25 Nov 2013 - 18:40 | |
| donc j'ai remplacé ces 2 égales (les seuls en début de ligne ) et maintenant j'ai ça : |
|
| |
Donchouwa Chevalier (niveau 2)
Messages postés : 88 Date d'inscription : 19/11/2013 Jauge LPC :
| Sujet: Re: Gérer plusieurs inventaires Lun 25 Nov 2013 - 18:51 | |
| - Donchouwa a écrit:
Le début de chaque ligne, mets un "#" jusqu'à =end, la aussi tu remplaces "=" par "#"
Tu as oublié une étape |
|
| |
mario5102 Paysan (niveau 4)
Messages postés : 36 Date d'inscription : 25/11/2013 Jauge LPC :
| Sujet: Re: Gérer plusieurs inventaires Lun 25 Nov 2013 - 19:07 | |
| ça à l'air de marché donc en fait je doit bien avoir ça maintenant ? - Code:
-
#begin #Multiple Inventories # by Fomar0153 #Version 1.1 #---------------------- #Notes #---------------------- #Allows you to easily handle multiple inventories in game. #---------------------- #Instructions #---------------------- #The default inventory is called "Main" you can change it below #if you wish. #To change inventory call: #$game_party.change_inventory(name) #To merge two inventories call: #$game_party.merge_inventories(inv1, inv2) #inv1 will recieve all the gold and items in inv2 #If ERASE_WHEN_MERGE is set to true then inv2 will be erased after #the merge. #---------------------- #Change Log #---------------------- #1.0 -> 1.1 Updated a glitch causing gold not to change when you change inventory. #---------------------- #Known bugs #---------------------- #None #end class Game_Party < Game_Unit #-------------------------------------------------------------------------- # ● Set the name of your starting inventory here #-------------------------------------------------------------------------- START_INVENTORY = "Main" #-------------------------------------------------------------------------- # ● Set the name of your starting inventory here #-------------------------------------------------------------------------- ERASE_WHEN_MERGE = true #-------------------------------------------------------------------------- # ● Aliased #-------------------------------------------------------------------------- alias mi_initialize initialize def initialize mi_initialize @current_inventory = START_INVENTORY @gold = {} @gold[START_INVENTORY] = 0 @last_item = Game_BaseItem.new end #-------------------------------------------------------------------------- # ● New, example call $game_party.change_inventory(name) #-------------------------------------------------------------------------- def change_inventory(name) if @gold[name].nil? @gold[name] = 0 @items[name] = {} @weapons[name] = {} @armors[name] = {} end @current_inventory = name end #-------------------------------------------------------------------------- # ● New, example call $game_party.merge_inventories(inv1, inv2) #-------------------------------------------------------------------------- def merge_inventories(inv1, inv2) return if @gold[inv1].nil? or @gold[inv2].nil? @current_inventory = inv1 @gold[inv1] += @gold[inv2] @gold[inv2] = nil if ERASE_WHEN_MERGE for item in @items[inv2].keys gain_item($data_items[item.to_i], @items[inv2][item]) end @items[inv2] = nil if ERASE_WHEN_MERGE for weapon in @weapons[inv2].keys gain_item($data_weapons[weapon.to_i], @weapons[inv2][weapon]) end @weapons[inv2] = nil if ERASE_WHEN_MERGE for armor in @armors[inv2].keys gain_item($data_armors[armor.to_i], @armors[inv2][armor]) end @armors[inv2] = nil if ERASE_WHEN_MERGE end #-------------------------------------------------------------------------- # ● Aliased #-------------------------------------------------------------------------- alias mi_init_all_items init_all_items def init_all_items mi_init_all_items @items[START_INVENTORY] = {} @weapons[START_INVENTORY] = {} @armors[START_INVENTORY] = {} end #-------------------------------------------------------------------------- # ● New #-------------------------------------------------------------------------- def gold return @gold[@current_inventory] end #-------------------------------------------------------------------------- # ● Rewrites #-------------------------------------------------------------------------- def items @items[@current_inventory].keys.sort.collect {|id| $data_items[id] } end #-------------------------------------------------------------------------- # ● Rewrites #-------------------------------------------------------------------------- def weapons @weapons[@current_inventory].keys.sort.collect {|id| $data_weapons[id] } end #-------------------------------------------------------------------------- # ● Rewrites #-------------------------------------------------------------------------- def armors @armors[@current_inventory].keys.sort.collect {|id| $data_armors[id] } end #-------------------------------------------------------------------------- # ● Rewrites #-------------------------------------------------------------------------- def item_container(item_class) return @items[@current_inventory] if item_class == RPG::Item return @weapons[@current_inventory] if item_class == RPG::Weapon return @armors[@current_inventory] if item_class == RPG::Armor return nil end #-------------------------------------------------------------------------- # ● Rewrites #-------------------------------------------------------------------------- def gain_gold(amount) @gold[@current_inventory] = [[@gold[@current_inventory] + amount, 0].max, max_gold].min end end |
|
| |
shin Chevalier Dragon (niveau 1)
Messages postés : 726 Date d'inscription : 18/10/2011 Jauge LPC :
| Sujet: Re: Gérer plusieurs inventaires Lun 25 Nov 2013 - 19:13 | |
| Ou plus simplement collé le =begin et le =end au bord gauche cet à dire qu'il ne faut pas d'espace avant. |
|
| |
Donchouwa Chevalier (niveau 2)
Messages postés : 88 Date d'inscription : 19/11/2013 Jauge LPC :
| Sujet: Re: Gérer plusieurs inventaires Lun 25 Nov 2013 - 20:10 | |
| - mario5102 a écrit:
- ça à l'air de marché donc en fait je doit bien avoir ça maintenant ?
- Code:
-
#begin #Multiple Inventories # by Fomar0153 #Version 1.1 #---------------------- #Notes #---------------------- #Allows you to easily handle multiple inventories in game. #---------------------- #Instructions #---------------------- #The default inventory is called "Main" you can change it below #if you wish. #To change inventory call: #$game_party.change_inventory(name) #To merge two inventories call: #$game_party.merge_inventories(inv1, inv2) #inv1 will recieve all the gold and items in inv2 #If ERASE_WHEN_MERGE is set to true then inv2 will be erased after #the merge. #---------------------- #Change Log #---------------------- #1.0 -> 1.1 Updated a glitch causing gold not to change when you change inventory. #---------------------- #Known bugs #---------------------- #None #end class Game_Party < Game_Unit #-------------------------------------------------------------------------- # ● Set the name of your starting inventory here #-------------------------------------------------------------------------- START_INVENTORY = "Main" #-------------------------------------------------------------------------- # ● Set the name of your starting inventory here #-------------------------------------------------------------------------- ERASE_WHEN_MERGE = true #-------------------------------------------------------------------------- # ● Aliased #-------------------------------------------------------------------------- alias mi_initialize initialize def initialize mi_initialize @current_inventory = START_INVENTORY @gold = {} @gold[START_INVENTORY] = 0 @last_item = Game_BaseItem.new end #-------------------------------------------------------------------------- # ● New, example call $game_party.change_inventory(name) #-------------------------------------------------------------------------- def change_inventory(name) if @gold[name].nil? @gold[name] = 0 @items[name] = {} @weapons[name] = {} @armors[name] = {} end @current_inventory = name end #-------------------------------------------------------------------------- # ● New, example call $game_party.merge_inventories(inv1, inv2) #-------------------------------------------------------------------------- def merge_inventories(inv1, inv2) return if @gold[inv1].nil? or @gold[inv2].nil? @current_inventory = inv1 @gold[inv1] += @gold[inv2] @gold[inv2] = nil if ERASE_WHEN_MERGE for item in @items[inv2].keys gain_item($data_items[item.to_i], @items[inv2][item]) end @items[inv2] = nil if ERASE_WHEN_MERGE for weapon in @weapons[inv2].keys gain_item($data_weapons[weapon.to_i], @weapons[inv2][weapon]) end @weapons[inv2] = nil if ERASE_WHEN_MERGE for armor in @armors[inv2].keys gain_item($data_armors[armor.to_i], @armors[inv2][armor]) end @armors[inv2] = nil if ERASE_WHEN_MERGE end #-------------------------------------------------------------------------- # ● Aliased #-------------------------------------------------------------------------- alias mi_init_all_items init_all_items def init_all_items mi_init_all_items @items[START_INVENTORY] = {} @weapons[START_INVENTORY] = {} @armors[START_INVENTORY] = {} end #-------------------------------------------------------------------------- # ● New #-------------------------------------------------------------------------- def gold return @gold[@current_inventory] end #-------------------------------------------------------------------------- # ● Rewrites #-------------------------------------------------------------------------- def items @items[@current_inventory].keys.sort.collect {|id| $data_items[id] } end #-------------------------------------------------------------------------- # ● Rewrites #-------------------------------------------------------------------------- def weapons @weapons[@current_inventory].keys.sort.collect {|id| $data_weapons[id] } end #-------------------------------------------------------------------------- # ● Rewrites #-------------------------------------------------------------------------- def armors @armors[@current_inventory].keys.sort.collect {|id| $data_armors[id] } end #-------------------------------------------------------------------------- # ● Rewrites #-------------------------------------------------------------------------- def item_container(item_class) return @items[@current_inventory] if item_class == RPG::Item return @weapons[@current_inventory] if item_class == RPG::Weapon return @armors[@current_inventory] if item_class == RPG::Armor return nil end #-------------------------------------------------------------------------- # ● Rewrites #-------------------------------------------------------------------------- def gain_gold(amount) @gold[@current_inventory] = [[@gold[@current_inventory] + amount, 0].max, max_gold].min end end Voila c'est ça ^^ Shin => Il faut les coller les "=" ? |
|
| |
shin Chevalier Dragon (niveau 1)
Messages postés : 726 Date d'inscription : 18/10/2011 Jauge LPC :
| Sujet: Re: Gérer plusieurs inventaires Lun 25 Nov 2013 - 20:48 | |
| - Code:
-
=begin Multiple Inventories by Fomar0153 Version 1.1 ---------------------- Notes ---------------------- Allows you to easily handle multiple inventories in game. ---------------------- Instructions ---------------------- The default inventory is called "Main" you can change it below if you wish. To change inventory call: $game_party.change_inventory(name) To merge two inventories call: $game_party.merge_inventories(inv1, inv2) inv1 will recieve all the gold and items in inv2 If ERASE_WHEN_MERGE is set to true then inv2 will be erased after the merge. ---------------------- Change Log ---------------------- 1.0 -> 1.1 Updated a glitch causing gold not to change when you change inventory. ---------------------- Known bugs ---------------------- None =end class Game_Party < Game_Unit #-------------------------------------------------------------------------- # ? Set the name of your starting inventory here #-------------------------------------------------------------------------- START_INVENTORY = "Main" #-------------------------------------------------------------------------- # ? Set the name of your starting inventory here #-------------------------------------------------------------------------- ERASE_WHEN_MERGE = true #-------------------------------------------------------------------------- # ? Aliased #-------------------------------------------------------------------------- alias mi_initialize initialize def initialize mi_initialize @current_inventory = START_INVENTORY @gold = {} @gold[START_INVENTORY] = 0 @last_item = Game_BaseItem.new end #-------------------------------------------------------------------------- # ? New, example call $game_party.change_inventory(name) #-------------------------------------------------------------------------- def change_inventory(name) if @gold[name].nil? @gold[name] = 0 @items[name] = {} @weapons[name] = {} @armors[name] = {} end @current_inventory = name end #-------------------------------------------------------------------------- # ? New, example call $game_party.merge_inventories(inv1, inv2) #-------------------------------------------------------------------------- def merge_inventories(inv1, inv2) return if @gold[inv1].nil? or @gold[inv2].nil? @current_inventory = inv1 @gold[inv1] += @gold[inv2] @gold[inv2] = nil if ERASE_WHEN_MERGE for item in @items[inv2].keys gain_item($data_items[item.to_i], @items[inv2][item]) end @items[inv2] = nil if ERASE_WHEN_MERGE for weapon in @weapons[inv2].keys gain_item($data_weapons[weapon.to_i], @weapons[inv2][weapon]) end @weapons[inv2] = nil if ERASE_WHEN_MERGE for armor in @armors[inv2].keys gain_item($data_armors[armor.to_i], @armors[inv2][armor]) end @armors[inv2] = nil if ERASE_WHEN_MERGE end #-------------------------------------------------------------------------- # ? Aliased #-------------------------------------------------------------------------- alias mi_init_all_items init_all_items def init_all_items mi_init_all_items @items[START_INVENTORY] = {} @weapons[START_INVENTORY] = {} @armors[START_INVENTORY] = {} end #-------------------------------------------------------------------------- # ? New #-------------------------------------------------------------------------- def gold return @gold[@current_inventory] end #-------------------------------------------------------------------------- # ? Rewrites #-------------------------------------------------------------------------- def items @items[@current_inventory].keys.sort.collect {|id| $data_items[id] } end #-------------------------------------------------------------------------- # ? Rewrites #-------------------------------------------------------------------------- def weapons @weapons[@current_inventory].keys.sort.collect {|id| $data_weapons[id] } end #-------------------------------------------------------------------------- # ? Rewrites #-------------------------------------------------------------------------- def armors @armors[@current_inventory].keys.sort.collect {|id| $data_armors[id] } end #-------------------------------------------------------------------------- # ? Rewrites #-------------------------------------------------------------------------- def item_container(item_class) return @items[@current_inventory] if item_class == RPG::Item return @weapons[@current_inventory] if item_class == RPG::Weapon return @armors[@current_inventory] if item_class == RPG::Armor return nil end #-------------------------------------------------------------------------- # ? Rewrites #-------------------------------------------------------------------------- def gain_gold(amount) @gold[@current_inventory] = [[@gold[@current_inventory] + amount, 0].max, max_gold].min end end Voila l'indentation est parfaite. compare les deux begin le mien n'a pas d'espace avant le "=". |
|
| |
Contenu sponsorisé
| Sujet: Re: Gérer plusieurs inventaires | |
| |
|
| |
|