Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Author Topic: Managing multiple inventories  (Read 7701 times)

0 Members and 1 Guest are viewing this topic.

Jerrot

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 690
    • View Profile
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 inventory

inv_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 Paul

for(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
  • Addicted to WME forum
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 528
  • Fear me! I'm evil!
    • View Profile
    • Order of Dagon
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
  • Addicted to WME forum
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 690
    • View Profile
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!
 

Page created in 0.019 seconds with 24 queries.