﻿ Managing multiple inventories
• August 16, 2018, 05:43:56 AM
• Welcome, Guest

### News:

Forum rules - please read before posting, it can save you a lot of time.

Pages: [1]

### AuthorTopic: Managing multiple inventories  (Read 4289 times)

0 Members and 1 Guest are viewing this topic.

#### Jerrot

• Global Moderator
• Karma: 0
• Offline
• Gender:
• Posts: 688
##### Managing multiple inventories
« on: December 19, 2003, 03:10:19 PM »

Hiya,

this question came several times and although it will be implemented in a future version of WME, the script solution is quite easy.

I'll write it quite "straight", of course you can create a far more comfortable function of it. In this example we have two inventories - for Peter and Paul. And of course you have to make those internal inventories (inv_Peter / inv_Paul) global !

Code: [Select]
`// We need some variables...var counter, counter2, amount;var inv_Peter = new Array();var inv_Paul = new Array();// Peter is the current actor, so this becomes his inventory:Game.TakeItem("book1");Game.TakeItem("book2");Game.TakeItem("book3");Game.TakeItem("book4");// And this will be the default inventory for Paul, assuming// we didn't play with him yet.inv_Paul[0] = "book5";inv_Paul[1] = "book6";inv_Paul[2] = "book7";inv_Paul[3] = "book8";// okay, now we switch from Peter to Paul.// let's truncate the internal inventory of Peter,// fill it with the current items and clear the// current game inventoryinv_Peter = null;amount = Game.NumItems;for(counter=0; counter<(amount); counter=counter+1) {  inv_Peter[counter] = Game.GetItem(0);  Game.DropItem(inv_Peter[counter]);}// now we just fill up the (currently empty) game inventory with the// internal inventory of Paulfor(counter2=0; counter2<counter; counter2=counter2+1){  Game.TakeItem(inv_Paul[counter2]);}// done.`
Not too beauty, but should work fine.

Jerrot.
« Last Edit: December 19, 2003, 03:13:20 PM by Jerrot »
Logged
Mooh!

#### Nihil

• Supporter
• Karma: 0
• Offline
• Posts: 528
• Fear me! I'm evil!
##### Re:Managing multiple inventories
« Reply #1 on: December 19, 2003, 03:13:44 PM »

Thanks!

I hope I can manage to try it out this weekend.

PS: You forgot Mary in your example

#### Jerrot

• Global Moderator
• Karma: 0
• Offline
• Gender:
• Posts: 688
##### Re:Managing multiple inventories
« Reply #2 on: December 19, 2003, 03:22:53 PM »

PS: You forgot Mary in your example

Well, she lost all her items when she did a job acting as "Wilma" in some Tetris game, so I had no use for her anymore...
Logged
Mooh!
Pages: [1]

Page created in 0.146 seconds with 22 queries.