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

Mr Q



Registered
  06/11/2004
Points
  89
4th March, 2005 at 21:29:52 -

i know it might have something to do with an INI but i dont know how 2 use them.. HELP!!

 
n/a

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
4th March, 2005 at 21:39:08 -

http://www.create-games.com/cs_search.asp?q=inventory&sdo=on&sar=on&sfo=on

Scroll a bitsy, there are some articles.

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
5th March, 2005 at 09:31:44 -

You could use the list object, it would save to a seperate file but it is certainly easier than ini.
Personally i think the inventory is the most complicated part of making an rpg, perhaps only second to the battle part.

 
.

AsparagusTrevor

Mine's a pint of the black stuff

Registered
  20/08/2002
Points
  2364

Game of the Week WinnerHas Donated, Thank You!VIP MemberEvil kliker
5th March, 2005 at 10:49:14 -

What aboot the Bag object. I haven't used it, but it sounds like it's main purpose is making easy inventories.

 
Image

Mr Q



Registered
  06/11/2004
Points
  89
6th March, 2005 at 04:43:30 -

oh well i guess i will just have 2 put my rpg on hold for a while

 
n/a

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
6th March, 2005 at 10:07:51 -

Bag object, never heard of it. Does it work with tgf?

 
.

AsparagusTrevor

Mine's a pint of the black stuff

Registered
  20/08/2002
Points
  2364

Game of the Week WinnerHas Donated, Thank You!VIP MemberEvil kliker
6th March, 2005 at 16:32:18 -

No, it only works for MMF. http://click.spatang.com/ext/view.php?ext=271
Sounds pretty useful, I just haven't needed an inventory yet.

 
Image

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
7th March, 2005 at 10:55:52 -

Darn, one more reason to upgrade i supose.

 
.

Coop



Registered
  15/08/2004
Points
  347
10th March, 2005 at 19:34:16 -

The link to download the bag object doesnt work.

 
...

DistantJ [FZ Games]



Registered
  02/08/2004
Points
  855
12th March, 2005 at 06:45:52 -

Ah inventories, the hardest part of an RPG to do! I use Sub-Applications and INI myself, never tried out that 'Bag object', I'll take a look at it. Sadly Sub-Applications don't work in that outdated child's toy called The Games Factory.

The best way to work it in the games factory is to have an inventory which doesn't pause the game, a la Starfox Adventures. If you're using static movement programming for everything and aren't using one built in TGF movement you can freeze everything by putting all the events except the inventory screen's into a group and closing that group when loading up the inventory, but that can be a real pain.

To be honest I'd reccomend upgrading to MMF and getting used to it's differences for anyone creating an RPG. TGF just isn't cut out for RPGs. Not decent ones anyway.

 
http://www.fzgames.com

SculptureOfSoul



Registered
  14/03/2005
Points
  52
17th March, 2005 at 09:08:31 -

Inventories are easy with MMF. All you have to do is load up the INI of the character that you want and set the subgroup to [Inventory] or [ItemsHeld] or wherever you have your items.

Say you want to load the first 10 items from your inventory and display them on the screen. Just for this example lets put 10 text objects on the screen. Each one represent a "Slot" in your inventory, and they'll be named ITEM SLOT 1, to ITEM SLOT 10. Your ini might look something like this

Character1.ini

[Inventory]
1=Heal Potion
2=Ugly stick
3=Frozen mammoth testicle
4=
5=
6=
7=
8= <---the #8 over there is an ITEM in the ini, an ITEM in the [Inventory Group]
9= <---since the term ITEM is used to reference an INI slot, it can be hard to
10= <---determine the meaning of some of the paragraphs below. If you have trouble
11= <---read it twice or three times. Hopefully that will help clear it up.


...and so on.. in this case 4-11 are empty slots. The <---- arrows are just there to help explain the confusing term ITEM since it is both INI terminology and the term we are using for those things we are loading . The <---- arrows are not actually in the INI, they are there just as a //comment of sorts. Again, remember that in this example [Inventory] is the INI's GROUP...and each # before an equals sign is an item of that group. Therefore, the heal potion is located at "Item 1 of Group [Inventory]"...which can be shown as [Inventory]->Item 1.

Now, all you need to do is create some kind of indicator that marks what item is currently selected. This could be some kind of color wash behind the text, a little hand icon next to the slot, the currently selected slots text could change to a different color, etc. For simplicities sake we'll start it at the first text slot and set the color of the text of the currently selected slot to a different color
to indicate where we are at.

Now create a counter called "INVENTORY SLOT INDEX COUNTER" and start it at 1. It's max value should be set at 10 in this case, since that is the number of item slots that we have. We also need to have another counter that goes from 0-999 (where 999 represents the maximum # of items one can hold in their inventory). This counter will track the current index of the INI file. We'll call this counter the "INI INDEX COUNTER". Start it at 1.Now, whenever we are in an "inventory mode" - a mode where
the user can modify and move around the inventory - pressing UP should Subtract 1 from the "INVENTORY SLOT INDEX COUNTER", and pressing down should Add 1 to the counter.

When the counter is at it's lowest value, 1, and the user presses up, this indicates that they have the topmost item on their screen selected and they are trying to SCROLL UP. When the counter is at it's highest value, 10, and the user presses down, this indicates that they are at the lowermost item on the screen and are trying to SCROLL DOWN. Keep this in mind as it comes into play a bit later when we are loading items from the INI.

Now, the INI INDEX COUNTER should initially be set to 1. The INI INDEX COUNTER represents the position you are at in the INI, and this is also going to be what is showing up in the ITEM SLOT 1. Therefore, to load an item into ITEM SLOT 1 we do not simply load Item 1 (here item 1 means the first item in the INI. Remember that given 1=Heal Potion like in the example above....the number 1 before the equals sign is an
Item in the ini, and that in this case it is called "1". Therefore it is Item "1" in the INI".) from the INI, because then Slot one will ALWAYS show item 1 and we wouldn't be able to scroll up or down...bah, that's no fun!

So what we do instead is, The First item slot's (the text object) alterable string should be set to load the INI item <value of INI INDEX COUNTER>. This way when everything is first loaded the value of the INI index counter will be one, and
the first item slot will represent the item referenced by the INI at slot 1, and it will be the first item in the inventory. ITEM SLOT 2 (the second text object) should set it's alterable string to the INI item <value of INI INDEX COUNTER + 1>. This way, when the INI INDEX COUNTER is at 1, the item showing up in ITEM SLOT 2 will be item 2...

looking at the above example 2=Ugly stick...so in this case the text object ITEM SLOT 2 will show "Ugly stick".

To load the items into ITEM SLOT 3 thru 10, we follow the same process. ITEM SLOT 3's alterable string should be set to <value of INI INDEX COUNTER + 2>. ITEM SLOT 4 should be set to <value of INI INDEX COUNTER + 3>, and so on and so forth for the rest of the items. This can all be coded into one event.

Now you might be wondering the the ITEM SLOT INDEX counter was for, as we haven't got to using it yet. Quite simply it is used for scrolling through the inventory. Remember that when the user presses UP, the ITEM SLOT INDEX COUNTER has 1 subtracted from it, and when the user presses DOWN, the ITEM SLOT INDEX COUNTER has 1 added to it. Also remember that it's Min Value is 1, and it's Max value is 10, because that
is the number of item slots that we have displayed on the screen.

Now we need to make one event for each value of the ITEM SLOT INDEX COUNTER from 1-10. The events should go as follows:

ITEM SLOT INDEX COUNTER = 1 --> Set ITEM SLOT 1 (the text object) text color to red.
--> Set ITEM SLOT 2 (the text object) text color to grey.

What this does is "highlight" the currently selected item slot by changing the color of the text to red. The reason we set ITEM SLOT 2 back to grey (you can use any default color instead of grey here) is because the player might have just been at item slot 2 and moved up to item slot one, and if we don't set ITEM SLOT 2 back to grey, it too along with slot 1 will be red.

When the ITEM SLOT INDEX COUNTER is at 10, we need to make sure that ITEM slot 9 is set back to grey. Again this looks like this

ITEM SLOT INDEX COUNTER =10 -->Set ITEM SLOT 10 text color to red
-->Set ITEM SLOT 9 text color to grey.

For all other values the player could be moving either up or down to them, so we need to set the item slot both above and below the current one back to the default color. For example:

ITEM SLOT INDEX COUNTER = 8 -->Set ITEM SLOT 8 text color to red
--Set ITEM SLOT 7 text color to grey
-->Set ITEM SLOT 9 text color togrey

Phew, okay, now you've just got to make one of those for each value of the ITEM SLOT INDEX COUNTER, from 1-10, and you're all done with the item highlighting! YAY!!! The last part of this is the coolest.

Now remember that when the inventory is first loaded it sets the INI INDEX COUNTER to 1, and then all 10 ITEM SLOTS are loaded from the INI. Also, since the ITEM SLOT INDEX COUNTER is initially set to 1, upon initiation the first item slot will be highlighted RED.

Looking at the Example INI way up there, we'd see
*Heal Potion
*Ugly Stick
*Frozen Mammoth Testicle
*
*
*
*
*
*
*

The *'s just denote an item slot. There are 10 *'s because there are 10 item slots. Well, now lets use a more filled out INI for an example

Character1.ini
[Inventory]
1=Heal Potion
2=Ugly Stick
3=Frozen Mammoth Testicle
4=Antidote
5=Elixer
6=Jumping Boots
7=White Cape
8=Atma Weapon
9=Murasame
10=Fenix Down
11=Masamune
12=Throwing Star
13=Stiletto
14=Sages Robe


Okay, now we've got more than 10 items, so they can't all be shown. When it initially loads the INI INDEX COUNTER will be at 1, and ITEM SLOT 1 will show the item at 1, the Heal Potion, ITEM SLOT 2 will show the ugly stick, Item slot 10 will show the Fenix down, etc. Now what we need to do is create 2 new events.
The 2 events are:

Player Presses UP+
ITEM SLOT INDEX COUNTER =1: ---> Subtract 1 from the INI INDEX COUNTER

Player Presses DOWN +
ITEM SLOT INDEX COUNTER =10: --->ADD 1 to the INI INDEX COUNTER.

Lets look at the second event to see what it does and how it works. Take a look at the example ini just above and recall that ITEM SLOT 1 is holding the Item referenced by the INI INDEX COUNTER. ITEM SLOT 2 is holding the item referenced by
the INI INDEX COUNTER + 1. And ITEM SLOT 10 is holding the item referenced by the INI INDEX COUNTER + 9. If the INI INDEX COUNTER starts at 1, ITEM SLOT 1 is holding item 1, ITEM SLOT 2 is holding item (1+1)..or item 2...and ITEM SLOT 10 is holding item (1 + 9) or item 10.

At first ITEM SLOT 1 is highlighted. If the player presses down the ITEM SLOT COUNTER gets 1 added to it, and then the corresponding ITEM SLOT gets highlighted red. But now look at that second event I just listed. When the ITEM SLOT COUNTER is at 10 (it's maximum value) the INI INDEX COUNTER gets 1 added to it. So if you press DOWN when you are already at ITEM SLOT 10, the INI INDEX COUNTER gets 1 added to it. Remember that the item that the ITEM SLOTS load is based off of the INI INDEX COUNTER. So once you have item slot 10 highlighted and press down, the INI INDEX counter will get reaised 1, and will now be 2. ITEM SLOT 1 if you recall, is set to load the item referenced by INI INDEX COUNTER. Since that value is now 2, the item displayed in ITEM SLOT 1 will now be item 2, the UGLY STICK. ITEM SLOT 2 is set to load <INI INDEX COUNTER + 1>..and the counter is at 2 so now the final result of that is that slot 2 is showing item 3 from the INI, the frozen mammoth testicle. Item slot 10 is set to load <INI INDEX COUNTER + 9>, and 2+9=11 so ITEM SLOT 10 is now showing the masamune.

If we were to press DOWN again, we would add 1 more to the INI INDEX COUNTER, and now all of the ITEM SLOTS would be showing the item one further down the list on the INI.

Bah, okay, I don't know why I said that inventory's are easy in MMF . I also apologize for such a long post, but I just got carried away and tried to explain it as best as I could without having any pictures or examples present. Hopefully
some of this makes sense even without examples, and if anyone feels like I'm insulting your intelligence by repeating some points a thousand times I apologize, I am just reiterating the points that I had a hard time understanding when I was learning how to do this myself.

Let me also note that this is not the most efficient way to do this..for one thing it would be wiser to use a single active object and designate it's alterable values for use as the counters I have listed, but I didn't mention that until now because I thought that would only make it more confusing.

If anyone has any questions or would like me to elaborate further, please DCmail me. If you'd like I'll write up a VERY thorough example and I'll also show you how to load icons for items, as well as CLUMP/UNCLUMP items (99 potions in one item slot, for example).

Seeing as I've not used TGF for many years now, I won't be capable of making a tutorial for implementing such a complicated system with TGF. If you are serious about this kind of stuff, I highly recommend MMF.

~SoS

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".

DistantJ [FZ Games]



Registered
  02/08/2004
Points
  855
17th March, 2005 at 10:55:52 -

Sounds about right, Phizzy.

SculptureOfSoul, I admire that you took the time to write all that! It's a nice technique, admittedly better than the ones I've used in the past. In fact, *copies the psot to a txt file and saves it*.

 
http://www.fzgames.com

axel

Crazy?

Registered
  05/02/2005
Points
  4766

Game of the Week WinnerYou've Been Circy'd!
17th March, 2005 at 12:22:49 -

i think the hardest part of making a RPG is to be enough patient to finish it . Everything else just takes a lot of time!
There r lots of inventory tecniques:

-Arrays
-Lists
-INI
-Global values

I would say the list would be the easiest way, but that's only for MMF...

 
n/a

SculptureOfSoul



Registered
  14/03/2005
Points
  52
17th March, 2005 at 17:32:12 -

I think INI's are the way to go. Multiple INI's in fact. This way when you are referencing item 1 in INI 1, you set the second INI to reference the group of the item named in INI 1. For instance

INI 1............................INI 2
1=Heal Potion...........[Heal Potion]
................................TotalInInventory=33
................................BaseValue=50
................................Icon=8


Now if you use the technique I used in the above example, you could set the alterable string of the ITEM SLOT 1 to "INI INDEX COUNTER" + "(" + the value retrieved from TotalInInventory from INI 2 + ")"

The end result will show
*Heal Potion(33)
*Item 2
*Item 3...

Now create 10 active objects, and put each one next to the ITEM SLOT text. Make it a 32 direction object, and then make each direction a different type of icon (Dir. Right could be a sword, Dir 1(one above right) could be a staff, Dir 2 a shield, etc). Make sure you write down what direction is what icon. Now when you load the items into the item slots, pull the Icon Value from the second INI and set the direction of the corresponding active object to that value. In the example above the direction would be set to 8 (facing up), so we better have a potion icon in this direction.

All of that can be coded into one event, I believe.

There is a way to do this using copies of the active object instead of 10 separate ones, but it involves spreading a value in an alterable value and then using a fastloop.

There are also ways of creating item type filters...weapons only, items only, etc. Maybe i should just write an article?

~SoS


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".

SculptureOfSoul



Registered
  14/03/2005
Points
  52
17th March, 2005 at 17:39:36 -

Btw, thanks for taking the time to read all that, DistantJ!

I was hoping somebody might get use out of it besides myself. Y'know, even If I know a technique fairly well it's always a different matter trying to explain it. I always find that I learn a lot more about the technique as well as get new ideas on how to implement it when I actually take the time to verbalize (or textualize) my thoughts!



 
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