The Daily Click ::. Forums ::. Klik Coding Help ::. im making an RPG but i dont know how to save items into an inventory
 

Post Reply  Post Oekaki 
 

Posted By Message

DistantJ [FZ Games]



Registered
  02/08/2004
Points
  855
17th March, 2005 at 19:45:30 -

Yeah well said.

 
http://www.fzgames.com

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
18th March, 2005 at 20:57:35 -

I had a good theory about sorting and inventory (by which i mean moving all the empty spaces so you dont leave gaps when you use an item),
if there was an empty space it would become the item below it and the one below would be emptied.
it worked once but when i tried to repeat it for all the inventory slots it messed up. Shame because it was a good idea.

 
.

SculptureOfSoul



Registered
  14/03/2005
Points
  52
19th March, 2005 at 08:14:45 -

Most sorting routines use a loop and an index variable. The loop iterates through as many steps as there are current inventory slots (this includes the empty ones.) Lets say you have 100 inventory slots...1-50 have items..51-99 are empty and then 100 has an item. Have the loop iterate 100 times, and for each iteration check that inventory slot. If it has an item, increment the Index variable by 1. If not, don't touch the index variable. Also, make sure you check if the current item slot being checked is == to the index variable. If not, then copy the current item slot into the slot # of the index variable.

Using the numbers above, the index would increase by 1 for the first 50 slots...then while the loop is iterating through the empty slots 51-99, the index variable won't be touched and it'll still be 50. When it gets to item 100, it checks the index variable to see if that is at the same slot that the loop is at...since it isn't it copies the item at the current loop iteration to the slot referenced by the index variable. Then you need to increment the index variable by 1.


 
Current Project: Undertaking the design of my mammoth RPG. Utilizing all of the knowledge gained while coding the now defunct "Shadow Reign".

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
19th March, 2005 at 08:23:25 -

AndyUK: a better way is the way SNES RPGs all used to do it. There are a number of memory positions each corresponding to an item, with the value being the number of that item in your posession. Then there was a similar array of items, only each value represted the position in the inventory of that item. The cheap way to move items up would then be to not move them up, instead simply having "ITEM x 0" as some games did it, otherwise shifting the array values only when the last instance of an item has been consumed.

Some games, however, lacked the second array. Instead each item had a specific position in the inventory, but when you had zero, they aren't displayed and the next item is moved up (when the list is generated, not its actual position).

Edit:
SoS may have covered some of that, bud damned if I'm reading that essay of his.

Image Edited by the Author.

 
n/a

SculptureOfSoul



Registered
  14/03/2005
Points
  52
19th March, 2005 at 08:40:03 -

Hehe, yeah sorry about that. If it's true what they say that "brevity is the soul of wit"...well, I must be a moron.

 
Current Project: Undertaking the design of my mammoth RPG. Utilizing all of the knowledge gained while coding the now defunct "Shadow Reign".

c-jayf



Registered
  06/07/2003
Points
  274
20th March, 2005 at 00:21:42 -

-Make an INI object, call it "inventory:

-whip out a text file to remind you of what everything would be, example:

-I want my
Severed Big Toe to be item # 1

Severed Big Toe - 1

Big Whackin' Shoe - 2

Lysol - 3

Bucket of Shrimp - 4

(after you figure out everything you want in the game, give it a number. Get it?)

-After that go

Cond.
o Start of level
Even.
o Load INI to filename "inventory"

-Make your guy get something now... like a Severed Big Toe!

Cond.
o Player presses whatever wherever to get big toe
Even.
o Set INI group to "items"
o Set INI item to whatever number you wrote severed big toe down as in your writing file... (remember it was 1)
o Set INI value to "1" (1 means you have it)(which means when u didnt have the toe,
it's value was 0)(Get it so far?)

This is you getting the toe, then it is loading the toe thru INI, then by setting it to 1, it's saying you picked it up.

Theres a start. But I Just Realized That This Would Only Work For An RPG With A Certain Amount Of Items. Like Unlocking Items. I Play Too Much Zelda. Crap.

 
I hate witty signatures.

Johan Hargne (Wartagon)

Lover Of Circys

Registered
  15/06/2003
Points
  1289

Game of the Week WinnerCROBASOFTVIP MemberPS3 OwnerWii OwnerMushroom
20th March, 2005 at 05:03:39 -

Guys, GUYS!! Did you know that it isn't a crime to write an article ?

 
Music Composer.
http://johan.hargne.se

Crobasoft
www.crobasoft.com

SculptureOfSoul



Registered
  14/03/2005
Points
  52
23rd March, 2005 at 03:30:57 -

I'd be willing to write a book article covering many different inventory systems and possible implementation methods if there is some serious interest. Anyone?



Image Edited by the Author.

 
Current Project: Undertaking the design of my mammoth RPG. Utilizing all of the knowledge gained while coding the now defunct "Shadow Reign".

c-jayf



Registered
  06/07/2003
Points
  274
23rd March, 2005 at 03:49:50 -

I am if you'll write it.

Image Edited by the Author.

 
I hate witty signatures.

c-jayf



Registered
  06/07/2003
Points
  274
23rd March, 2005 at 03:52:15 -

its 3 now, Im goin to bed.

 
I hate witty signatures.

SculptureOfSoul



Registered
  14/03/2005
Points
  52
23rd March, 2005 at 08:23:31 -

I will write it Jay, but after thinking about it for a while I'm going to wait until I get my current group of engines completed. Upon completion I'll be writing a series of articles that will document not only how each engine works but also how to utilize it to create your own offshoot games. If I stop now I might lose momentum and never complete them. So for now, all of my efforts are going to go towards them.

Sorry for making an offer that I'm now suspending.

 
Current Project: Undertaking the design of my mammoth RPG. Utilizing all of the knowledge gained while coding the now defunct "Shadow Reign".

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
23rd March, 2005 at 09:24:55 -

go for it mate, i may help me too.


I thought of one system that is nice and simple.

each item is its own set item in the ini but it is already preset, all you need to save is the amount of item, if the item = 0 it wont show up.

i just thought of that as i clicked on the topic.

 
.

SculptureOfSoul



Registered
  14/03/2005
Points
  52
23rd March, 2005 at 10:00:21 -

Definitely not a bad system Andy. It all depends on what you're looking for. The only problem with that system is it's impossible to implement multiple bundles of the same item. You couldn't have two "groups" of 99 heal potions for example.

It all depends on what your game needs, of course.

 
Current Project: Undertaking the design of my mammoth RPG. Utilizing all of the knowledge gained while coding the now defunct "Shadow Reign".
   

Post Reply



 



Advertisement

Worth A Click