The Daily Click ::. Forums ::. Klik Coding Help ::. Making a large inventory in TGF (100+ items)
 

Post Reply  Post Oekaki 
 

Posted By Message

Mr Fwibbles



Registered
  12/08/2006
Points
  8
16th August, 2006 at 17:06:17 -

Hi,

This is my first post here. I'm having a problem with TGF and it's driving me insane; none of the tutorials are really helping with what I want to do. Basically, I'm using an INI to keep track of an RPG-style inventory for items. Currently it's programmed to accept entries for 30 slots, but I could narrow that down for testing purposes. I don't need any help with saving to INI - the problem is the way I want to load in the data. Since I intend for the finished game to have hundreds of items, that's 100x30 lines of "code" for the various possibilities, and manually coding it like that is impossible since TGF appears to only accept 1024 lines for a single "level". I also want the scope for releasing patches with more items later on, so I don't want to tie myself down by saying something like "it will have exactly 123 items" or whatever.

What I want to do is have an inventory screen ("level") that displays icons (active objects) to show what you're carrying in each slot. The only inventory tutorials I've seen involve either edit objects (which I very much do NOT want to use, because you just get dull plain text and your game looks like it was made for DOS), or have a very limited number of items and thus do not have this "1024 lines" problem.

For some images depicting my problem, please see http://grandia.rpgplanet.gamespy.com/carro/ (I'm using style 2). Is there any way I can do this in TGF? Maybe I need a plug-in? People have suggested using loops to load the data, but I wouldn't know where to start. MMORPG makers, this is directed at you especially! How can I get this to work?

 
n/a

Deleted User
16th August, 2006 at 17:31:59 -

Im sure more people will answer, but im making an example to show you how i wouldve solved it. I think i know a pretty good idea...

 

defenestrator

Old

Registered
  12/07/2003
Points
  724
16th August, 2006 at 17:58:09 -

Mr Fwibbles, do you smoke crack?
I don't understand why you need 100 lines of code for each slot. If you have 100+ items and 30 slots... here, try this:

-Make an extra counter object.
-Give each item an identifying number. You can use one of the alterable values for this. Just make sure you use the same alterable value for each item (but, of course, a different identifying number). So, healing potions would have an identifying number of 1, for example.
-Whenever the cursor is over a slot, set the new counter to that item's identifying number. Then, you change the text according to what the counter says. So, if the counter says 1, you have the description text says something like, "This is a healing potion. It tastes like chalk, but will heal you."

That should resolve the problem you describe, unless I am the one smoking crack and I have totally misunderstood what the problem was.

 
n/a

Ski

TDC is my stress ball

Registered
  13/03/2005
Points
  10130

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!KlikCast HelperVIP MemberWii OwnerStrawberryPicture Me This Round 28 Winner!PS3 OwnerI am an April Fool
Candy Cane
16th August, 2006 at 17:59:34 -

We found Cannabis plants in my grandmas garden today. It turns out it was quite innocent, the bird seed she buys contains hemp seeds or something, my uncle was trying to explain lol

 
n/a

Mr Fwibbles



Registered
  12/08/2006
Points
  8
16th August, 2006 at 18:09:06 -

Defenestrator, displaying the description text isn't the problem. It's getting the relevant active object ("item") to create/position inside the "slot" without making an individual event for each active object. I don't have much experience with alterable values, could you please make an example .gam for me?

Image Edited by the Author.

 
n/a

defenestrator

Old

Registered
  12/07/2003
Points
  724
16th August, 2006 at 19:27:40 -

Oh, yeah. I think TGF only allows 3 alterable values per active object. I mean, you only need one, but... yeah, I forget a lot of the TGF stuff because I don't have it installed any more, which is also why I can't get you an example.

If it's the placement of things in the inventory that you're worried about, you can use the same system as I described before. I guess you don't need to worry about the alterable values as long as you have some way of keeping track of all your items. Number all your items and write it down someplace. You can use these numbers in your INI too, if you like. Let's pretend you've done that, so the hero has 30 slots. In slot one, he has a healing potion (ID number 1). In slot 4, he has a Elf Decapitation Sword (ID number 12). Slots 2 and 3 are empty (ID 0). So, when you display the inventory, you have two unseen counters and an active object. One counter is the Slot Number and the other is the Inventory ID Number of the current item. The active object is what will be used to tell the program where to place the item. The Slot Number's default value should be 1 because you want to start with the first number. You'll need 30 actions for the slots. So, if Slot Number=1, you place the Active Object at the x and y coordinates of the first slot. You also set the Item ID Number counter to whatever item ID is in the first slot in the INI. Use the "retrieve value from object" or whatever it's called. That's all you do. Now, make 29 other actions just like that one, for each of the different slot numbers. So, if Slot Number=2, move Active to where slot 2 is and change the Item ID Number to whatever slot 2 shows in the INI. Now, once you have 30 of those, you need 100 actions for the items. In each, you'll tell the program what to do if the Item ID Number is equal to a certain value. So, if Item ID Number=1, create healing potion at Active Object and add 1 to Slot number. Now don't tell me it doesn't work or that you don't understand or I will find you and eat you.

 
n/a

Deleted User
16th August, 2006 at 19:37:15 -

Im gonna do an EASY solution. Wait a couple of minutes and its done.

 

Deleted User
16th August, 2006 at 19:56:04 -

Im way too tired to make a more detailed example ^^'
Sorry! I apologise.

But this might give you an idea on how to do it
http://www.freewebs.com/klik-domain/Solution.gam
Click the inventory boxes to change items.
The thing it does is use one direction for each different item. With more than 32 items, just make it display another animation if its itemnumber is greater than 32.

Hope it helps a bit

 

Joe.H

Evil Faker

Registered
  19/08/2002
Points
  3305
16th August, 2006 at 19:59:55 -

You could use the picture object, and load an image from a string in an ini file to display different objects.

 
My signature is never too big!!!

Deleted User
16th August, 2006 at 20:00:25 -

Or use my fantastic idea

 

Joe.H

Evil Faker

Registered
  19/08/2002
Points
  3305
16th August, 2006 at 20:15:58 -

but your idea stores an ini file in the windows directory instead of somewhere people will look when deleting the game >.<

 
My signature is never too big!!!

Deleted User
16th August, 2006 at 20:37:45 -

Yes cuz im clever

 

Joe.H

Evil Faker

Registered
  19/08/2002
Points
  3305
16th August, 2006 at 20:48:13 -

you could use appdrive$ + appdir$ + "file.ini" in the event editor >.>

 
My signature is never too big!!!

DanielRehn



Registered
  18/09/2002
Points
  139
16th August, 2006 at 21:53:04 -

Don't store stuff in the windows folder ffs! -.-

 
n/a

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
17th August, 2006 at 21:47:39 -

This may or not help you, but what I did for Captain of the Guard 2's small inventory is along the lines of what defenestrator is talking about. I had 3 counters, each of which had 10 pictures to them. Like this:

Animation Frame / Value:

1 = Empty Box
2 = Red Water
3 = Blue Water
4 = Killer Fart
5 = Bowling Ball
6 = Electric Shield

etc, etc..

Then, I used an array to store the actual values of what Daxon had on him, where the array's values called up the picture box like this- Array Value(1) = 2 meant that in box #1 he had a Red Water, and it showed a picture of the Red Water in the first inventory box. It's pretty simple-ish, and I don't know if it'd be good for a big inventory like you're planning, but maybe that will give you some ideas for what you want to try.

 
--

"Del Duio has received 0 trophies. Click here to see them all."

"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"

DXF Games, coming next: Hasslevania 2- This Space for Rent!

Mr Fwibbles



Registered
  12/08/2006
Points
  8
18th August, 2006 at 07:39:00 -

Thanks for the input, everyone. I'll start with Skydragon's way, and if that doesn't work for me, I'll give the other ideas a try.

 
n/a

Joe.H

Evil Faker

Registered
  19/08/2002
Points
  3305
18th August, 2006 at 07:52:25 -

if you have a legal version of TGF, i suggest getting a discount on TGF2 or MMF2, as TGF is severley outdated and is very limited

 
My signature is never too big!!!

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
18th August, 2006 at 08:42:29 -

The list object could help you somewhat.

 
.

Mr Fwibbles



Registered
  12/08/2006
Points
  8
18th August, 2006 at 17:29:41 -

Skydragon, where abouts in the code do I tell it to change the animation for items with an ID number of over 31? I tried retrieving the value of the direction with a counter, then saying "if counter is greater than 31, then display animation 32-63" but that didn't work... everything else works perfectly though!

 
n/a

Deleted User
18th August, 2006 at 19:18:22 -

Hmm, glad it works.
To solve that,, try making the item get the direction to an alterable value first, then change direction into the value, and also change animation if the value is greater than 32?
Im too damn tired to explain it better Sorry...

 

Werbad



Registered
  18/09/2002
Points
  235
19th August, 2006 at 06:59:39 -

Translation into TGF code:
* ItemN >= 1
+ ItemN < 32
- Active1 set direction to ItemN
- Active1 make visible
- Active2 make invisible
- Active3 make invisible
- Active4 make invisible

* ItemN >= 32
+ ItemN < 64
- Active2 set direction to ItemN - 32
- Active1 make invisible
- Active2 make visible
- Active3 make invisible
- Active4 make invisible

Using different animations is recommended since it uses only 1 object/itemslot

 
n/a

Mr Fwibbles



Registered
  12/08/2006
Points
  8
19th August, 2006 at 10:01:45 -

Eee, I've just about done it (I just set alterable value B to the value of the INI at the same time it retrieves the direction). Just one small issue right now - instead of displaying item #31 as 31, it's showing direction 0 of animation 2 (or "direction 32"). Not entirely sure why, but I'll keep playing around with it and see if I can fix that.

Edit: I have to change the animation to CustomAnim1 if alterable value B >= 33? That doesn't make sense... the directions are 0 to 31... what happened to direction 32? Oh well, at least it's working now. It only took me... ALL DAY ;_;

Edit 2: The last object is sticking on "cherry" (item 16) instead of "pineapple chunks" (item 48 ). All of the other animation changes work fine though. Could this be to do with the number of loops or something?

Image Edited by the Author.

 
n/a

Mr Fwibbles



Registered
  12/08/2006
Points
  8
19th August, 2006 at 15:26:54 -

OK, changing the animations was working briefly, but now it's gone totally haywire and it's changing the animation RANDOMLY. Seriously. I've noticed that it's displaying the wrong items, but if the item is wrong it's always 32 items in front or behind the number it should be - hopefully meaning the animation is just wrong. But WHY? It was working before and I didn't change anything! *Grumbles*

(Oh yeah, and I double posted because I got sick of editing the previous post)


Edit: It works fine (apart from the last slot) if I manually alter the item numbers in the INI, but if I let the game set the item numbers, it messes everything up (only changes the animation for some, not others).

Image Edited by the Author.

 
n/a

Deleted User
19th August, 2006 at 16:43:23 -

Ahh, sorry, i dont have time to help you.
Hope you solve it somehow, just try looking through the events after mistakes in the code.

 

steve



Registered
  13/09/2002
Points
  200

VIP Member
22nd August, 2006 at 11:13:31 -

Does TGF have Active Picture object? I can't remember... anyway that would help you to not have so many active objects (as you would read in each item picture as an external)

 
n/a

Joe.H

Evil Faker

Registered
  19/08/2002
Points
  3305
22nd August, 2006 at 11:53:22 -

it has picture object, on the multimedia bit, which can load external files

 
My signature is never too big!!!

Mr Fwibbles



Registered
  12/08/2006
Points
  8
22nd August, 2006 at 15:19:58 -

@JonWoG: Thanks for the offer. I'm just going to finish off a few other things in this same "level" (frame) first, and then I can send it to you. Might be a couple of days yet.

 
n/a

DaVince

This fool just HAD to have a custom rating

Registered
  04/09/2004
Points
  7998

Game of the Week WinnerClickzine StaffHas Donated, Thank You!Cardboard BoxDos Rules!
22nd August, 2006 at 15:39:16 -

Don't use directions, use frames! And set the frame speed to 0.

Then, in the event editor, set the frame number to the item number when loading an item.

 
Old member (~2004-2007).

Alice Pierce



Registered
  08/01/2006
Points
  6
23rd August, 2006 at 14:03:36 -

Small tip about "inventory":
You can save many values in one.
If you want to save 5 values [value1,value2,value3,value4,value5] in one [called ValueZ, or if you want - global value 1 etc.], and every value can keep integer between zero and Q, save using this equation:
ValueZ=1*value1 + Q*value2 + (Q^2)*value3 + (Q^3)*value4 + (Q^4)*value5.
To load values, use this equation:
value1 = (ValueZ) /1) mod Q
value2 = ((ValueZ) /Q) mod Q
value3 = ((ValueZ) /(Q^2) ) mod Q
value4 = ((ValueZ) /(Q^3) ) mod Q
value5 = ((ValueZ) /(Q^4) ) mod Q
I recommend to save inventory in Dynamic Array 2 [easy to add and remove item from inventory].

 
;]
   

Post Reply



 



Advertisement

Worth A Click