|
Post by scottyboy123 on Apr 6, 2004 0:17:36 GMT -5
I have got everything else in my RPG working except this. How can I get a good inventory system? I need it so when you collide with an object (eg sword) a corresponding object (eg inv_sword) is added to your inventory. The inventory is in a different room, so something will probable have to be stored in an array so it can create all the objects when you go into the inventory room. I need it to create an object in the inventory room because I want to be able to click on it and make a menu pop up. (IsmAvatar, I've tried your examples but they're not quite what I need) So, can anyone help?
|
|
|
Post by megamushroom on Apr 6, 2004 10:36:08 GMT -5
hm, have a persistant object called inven. If you colide with, say a sword, its adds it to inven. Depeding on how you are displaying your items, here how you can do it.
if you are doing it like this:
item[0,0]="Blah" item[0,1]=amount item[1,0]="Blah" item[1,1]=amount then when you collide, you shoud use this:
for (t=0;t<=1;t+=1){ if item[t,0]=0{ item[t,0]="Sword" item[t,1]=1 exit;} else {if item[t,0]="Sword"{ item[t,1]+=1 exit;} }
If you already have set ares for item, like this:
sword=amount potion=amount rune=amount
then just use the +=1 when you collde with it.
for the making an object, this is tricky! if you are using the first method, use this:
you have to add some new arrays, so it looks like this:
item[0,0]="Blah" item[0,1]=amount item[0,2]=10 item[0,3]=10
item[1,0]="Blah" item[1,1]=amount item[1,2]=20 item[1,3]=20
the new arrays are positionings.
put this in the creation event of the inventory rooom.
for (t=0;t<=1;t+=1){ if [t,0]="Sword"{ create_instance(item[t,2],item[t,3],potion}}
then, in the potion object, make a menu when you click it. there is a good show_menu function you can use, look in the manual for more help.
Hope this helps
megamushroom
|
|
|
Post by IsmAvatar on Apr 6, 2004 12:14:29 GMT -5
You Obviously haven't looked around these forums yet. I have 2 useful inventory examples on my site, along with a tutorial on loops and arrays for those of you who can't understand the inventory examples. For my site to see the inventory examples, look in my sig
|
|
|
Post by scottyboy123 on Apr 7, 2004 1:22:55 GMT -5
Thanks megamushroom. Do you know how I can set it so certain objects are stackable (and stack when you put them in the inventory, obviously) and some aren't?
|
|
|
Post by megamushroom on Apr 7, 2004 11:25:29 GMT -5
how do you mean stack? as in add up? didnt i already say how to do that? look at isms tutorials anyway, they are good to learn off.
|
|
|
Post by IsmAvatar on Apr 7, 2004 12:16:29 GMT -5
|
|
|
Post by scottyboy123 on Apr 7, 2004 23:17:09 GMT -5
I meant that only some items can be stacked. But don't worry, I'll just add another array (item[t,2]) and check to see if it equals true. If not, the item won't stack.
|
|