# Inventory System

**URL:** <https://forum.kirupa.com/t/inventory-system/264722>\
**Category:** programming\
**Created:** [June 29, 2008, 3:23pm UTC](https://forum.kirupa.com/t/inventory-system/264722 "2008-06-29T15:23:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gravity\_Chaser](https://avatars.discourse-cdn.com/v4/letter/g/a9adbd/32.png) [@Gravity\_Chaser](https://forum.kirupa.com/u/Gravity_Chaser)\
**Post date:** [June 29, 2008, 3:23pm UTC](https://forum.kirupa.com/t/inventory-system/264722/1 "2008-06-29T15:23:11Z")

</div>

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

[http://www.imgupload.co.uk/uploads/b1c3ea3656903e3f9ccd75915d6d483f1cbd0ade23def698be9c36d95764a4ef.swf](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](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?

---

<div class="post-metadata">

**Author:** ![sekasi](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sekasi](https://forum.kirupa.com/u/sekasi)\
**Post date:** [June 29, 2008, 5:38pm UTC](https://forum.kirupa.com/t/inventory-system/264722/2 "2008-06-29T17:38:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![nathan99](https://avatars.discourse-cdn.com/v4/letter/n/96bed5/32.png) [@nathan99](https://forum.kirupa.com/u/nathan99)\
**Post date:** [June 30, 2008, 2:20am UTC](https://forum.kirupa.com/t/inventory-system/264722/3 "2008-06-30T02:20:25Z")

</div>

[http://www.n99creations.com/vieweg.php?id=19](http://www.n99creations.com/vieweg.php?id=19)
