Inventory System

Ok Im making a RPG game: (Here it is in development) (arrow keys to move)

http://www.imgupload.co.uk/uploads/b1c3ea3656903e3f9ccd75915d6d483f1cbd0ade23def698be9c36d95764a4ef.swf

In the frame I have:

currentslotnum = 1;
stop ();
function addToslot (item) {
if (!item.found) {
item._x = eval (“itemSlot” + currentslotnum)._x;
item._y = eval (“itemSlot” + currentslotnum)._y;
item.found = true;
currentslotnum++;
}

Among other stuff - and on items which can be picked up I have:

onClipEvent (enterFrame) {
if (_root.character.hitTest (this)) {
_root.addToslot (this);
}
}

  • Yay that works fine. But now when I try to Have it so you click a “Inventory” button the inventory pops up - I get this:
http://www.imgupload.co.uk/uploads/ebd58110e66ceef4473c16c2f298675703c43da988f2e0cb933da55d05bdde1e.swf

Code on the Items:

onClipEvent (enterFrame) {
if (_root.character.hitTest (this)) {
_root.inventory.addToslot (this);
}
}

Code on the two frames of the inventory MC:

currentslotnum = 1;
stop ();
function addToslot (item) {
if (!item.found) {
item._x = eval (“itemSlot” + currentslotnum)._x;
item._y = eval (“itemSlot” + currentslotnum)._y;
item.found = true;
currentslotnum++;
}
}

I now longer have that script on the main page. And the two Items are inside the inventory MC

What should happen?
Upon touching the two items - they should both go into inventory whenever its popped up or closed. (and you can turn the inventory off and on without it messing up)

What Happens:
Touching the two items with the invent closed does nothing - if you turn it on then and touch them - nothing happens.
But if you touch the items for the first time with the inventory open - they go into the invent - but they dont close when the inventory closes.

I think part of it is to do with the mc inventory having two frames - with the script on both frames - presumably I could use attachMC which Im new at.

Making the items disspear with the inventory when closed could be solve (i think_ with just _root.item = false; or something.

Help please?

If you’re serious about making a game, move away from Actionscript 1 and ‘on movieclip code’ and step up to a class based AS2 project. Or even better, AS3.

Your type of project code will quickly become impossible to manage.

http://www.n99creations.com/vieweg.php?id=19