Basic Inventory System - Don't know where to start
by Steven Peterson · in Torque Game Engine · 11/08/2005 (10:21 am) · 27 replies
I think the built-in scripted inventory system would be adequet for my needs, but I've read inventory.cs and item.cs three times and I still just don't "get it". How does it work? Where is the inventory stored? How do I check whats in the inventory to display it in GUI, or use an item?
I've checked out Tim Newell's tutorials and they seem old and overkill for what I need but i'm not sure. Going to go read them again. Haven't found anything written on here about the scripted system.
All I need to store is:
- a dozen or so items/weapons - you have 'em or you don't
- 1/2 dozen "ammo" type items
The hardest thing I will need to do is write the inventory out to a file with a handfull of other variables and thats the saved-game-state.
[i]Does anyone see a blatent reason here why I can't use the scripted inventory system? Or can anyone sum up how it works? the code didn't do it for me...[i]
Thanks once again,
Raven
I've checked out Tim Newell's tutorials and they seem old and overkill for what I need but i'm not sure. Going to go read them again. Haven't found anything written on here about the scripted system.
All I need to store is:
- a dozen or so items/weapons - you have 'em or you don't
- 1/2 dozen "ammo" type items
The hardest thing I will need to do is write the inventory out to a file with a handfull of other variables and thats the saved-game-state.
[i]Does anyone see a blatent reason here why I can't use the scripted inventory system? Or can anyone sum up how it works? the code didn't do it for me...[i]
Thanks once again,
Raven
#2
Today I got Tim Newell's Popup-Inventory-GUI "working" per-say. It iterates through the inventory and tells me whats there so far... Not much of a start but better than nothing I guess.
I still don't understand how/where to define a new item that can be placed in the scripted inventory, which I think will meet my needs, or how to determin what items the player starts with. (Haven't gotten to picking up or selecting an item yet).
It seems like this system is fairly spread out over several files, and I can't seem to connect all the dots. Has anyone else used this?
11/09/2005 (12:21 am)
Thanks for the tips Mr. Pig, but i'm still struggleing with this one. Today I got Tim Newell's Popup-Inventory-GUI "working" per-say. It iterates through the inventory and tells me whats there so far... Not much of a start but better than nothing I guess.
I still don't understand how/where to define a new item that can be placed in the scripted inventory, which I think will meet my needs, or how to determin what items the player starts with. (Haven't gotten to picking up or selecting an item yet).
It seems like this system is fairly spread out over several files, and I can't seem to connect all the dots. Has anyone else used this?
#3
11/09/2005 (12:31 am)
I didn't even bother with the torque inventory. i just wrote my own. I need both consumables and equipables. So instead of trying to figure out how to adapt the existing, i just wrote one from the ground up. All items aren equipment are saved with my custom save file. Which currently just saves characters stats and items and what not. Doesn't save location or anything like that.
#4
Might want to take a look at my Back to Basics tutorial on SimSets vs SimObjects, for a good idea on how to implement a new inventory should you decide to do so.
11/09/2005 (10:05 am)
@Raven, Inventory is extremely simple once you get your mind around it. Basically every item is inventoriable, just create the item in script as soon as it's picked up it's in Inventory.Might want to take a look at my Back to Basics tutorial on SimSets vs SimObjects, for a good idea on how to implement a new inventory should you decide to do so.
#5
In player datablock:
You need the max inventory amounts for each item. In this example would be replaced by the name of the idem and would be replaced by the max number of this idem each player can have.
In idem datablocks:
In each idem datablock you will need the following. will be replaced with the name of the idem, will be replaced with the max amount of the idem (same as above), and would be replaced with the type. (I forget the allowed types, I can only think of ammo for right now)
In weapon shape datablocks:
In each weapon shape datablock you need the following. will be replaced with the type (weapon), same idea as above. will be replaced with the idem that, if you run into it, the weapon is added into your inventory, and the idem that if you run into it, ammo for that gun is loaded into your inventory.
I hope this helps.
11/09/2005 (2:46 pm)
Umm.. the base of the inventory system is the main inventory file. It has hooks in each item/weapon data block, as well has max-amount hooks in the player datablock. There are also some functions in the idem.cs file. So, you are right it is spread-out. The way it works, or I think it works, is as follows:In player datablock:
You need the max inventory amounts for each item. In this example
maxInv[<idem>] = <amount>;
In idem datablocks:
In each idem datablock you will need the following.
pickUpName = "<name>"; maxInventory = <amount>; className = "<type>";
In weapon shape datablocks:
In each weapon shape datablock you need the following.
className = "<type>"; item = <pickup>; ammo = <ammo pickup>;
I hope this helps.
#6
Second: Thanks everyone for your posts. I'm not there yet but I think I'm getting a better handle on it.
@Ramen: was it hard to get the save-data to a custome file working? I haven't gotten there yet, but it's on the list.
@Dreame: - I'll look up the tutorial tonight! Thanks.
@Mr. Pig: Thanks, this does help clear things up a bit. So to my understanding, I'll probably need a file similar to crossbow.cs for every weapon. For simpler items I can probably put them in one myItems.cs file but I at least need a:
equivlant to define each. Right?
Thanks all,
Raven
11/09/2005 (4:00 pm)
First: Sorry to anyone who saw my multiple-posts earlier - damn repost data...Second: Thanks everyone for your posts. I'm not there yet but I think I'm getting a better handle on it.
@Ramen: was it hard to get the save-data to a custome file working? I haven't gotten there yet, but it's on the list.
@Dreame: - I'll look up the tutorial tonight! Thanks.
@Mr. Pig: Thanks, this does help clear things up a bit. So to my understanding, I'll probably need a file similar to crossbow.cs for every weapon. For simpler items I can probably put them in one myItems.cs file but I at least need a:
datablock ItemData(Crossbow) {}equivlant to define each. Right?
Thanks all,
Raven
#7
11/09/2005 (6:00 pm)
Aside from "Weapon" and "Ammo" how do I find all the legal "classname" choices for itemData?
#8
So if anyone has relevent input towards that end post it here as well. Thanks! :-)
11/09/2005 (9:41 pm)
If I ever nail this down I'm thinking of writing a tutorial as a Resource/TDN-contribution. Maybe someday it'll save someone else some suffering, as this really is an under-documented feature.So if anyone has relevent input towards that end post it here as well. Thanks! :-)
#9
If you are just looking to display inventory items, all you need to do is make sure the client gets updated about inventory since it actually has no clue about inventory, then stick a gui ontop of it.
If you want to completely redefine the Inventory system, then you are kind of on your own, however Tim Newells resource is a good start.
If you look at my MMORPG tutorial 1 Inventory for the Client, you will see a fairly simple implementation, that makes minimum mods on the system. Also had I known then what the proper usage of SimGroups and SimSets were, I would have used a simple loop through a SimSet instead of all that fancy schmancy array stuff.
11/09/2005 (10:25 pm)
It really all depends on what you want from an Inventory.If you are just looking to display inventory items, all you need to do is make sure the client gets updated about inventory since it actually has no clue about inventory, then stick a gui ontop of it.
If you want to completely redefine the Inventory system, then you are kind of on your own, however Tim Newells resource is a good start.
If you look at my MMORPG tutorial 1 Inventory for the Client, you will see a fairly simple implementation, that makes minimum mods on the system. Also had I known then what the proper usage of SimGroups and SimSets were, I would have used a simple loop through a SimSet instead of all that fancy schmancy array stuff.
#10

while mine works in such a way that the items are script objects, and not actual objects.
11/09/2005 (10:45 pm)
Saving and loading isn't hard. you just have to remember to write in the same order you read. Plus you have to remember that if you want somethign saved, you have to tell it to do so. For now, mine just saves my inventory and character stats. later i'll add in support to save your position.
while mine works in such a way that the items are script objects, and not actual objects.
#11
How long did it take you to really get to know Torque? It seems like you really know your stuff. Even though i always do a search first and figure out a ton of stuff on my own, I feel like i'm spamming the boards with tons of questions.
On the other hand, I've only had TGE since August and my game's 1/3 done, so I guess i'm doing better than everyone who says "I've had it a year, i read the book 3 times, and I'm thinking about starting to try and make a demo"...
Thanks for all the help guys! I'll keep reading the links, I feel i'm really close now! lol.. famous last words...
11/10/2005 (2:47 pm)
@Dreamer, thx, I'll check out the implementation you have there. How long did it take you to really get to know Torque? It seems like you really know your stuff. Even though i always do a search first and figure out a ton of stuff on my own, I feel like i'm spamming the boards with tons of questions.
On the other hand, I've only had TGE since August and my game's 1/3 done, so I guess i'm doing better than everyone who says "I've had it a year, i read the book 3 times, and I'm thinking about starting to try and make a demo"...
Thanks for all the help guys! I'll keep reading the links, I feel i'm really close now! lol.. famous last words...
#12
11/10/2005 (5:39 pm)
1/3 in 3 months? Wow, either your really good, or your game's gunna suck! XD Anywhoo, good luck with everything.
#13
Count on it taking 8-12 months of daily messing around to get familiar enough with the code to make a game.
And remember the first 90% is always the easiest to get done, it's the fine tuning, tweaking and debugging that will take the remainder of your time.
11/10/2005 (5:54 pm)
@Raven, what on earth gave you the impression I really know my stuff. I've been an SDK owner for over 2 years and still to this day, I find new stuff out on a daily basis. ;)Count on it taking 8-12 months of daily messing around to get familiar enough with the code to make a game.
And remember the first 90% is always the easiest to get done, it's the fine tuning, tweaking and debugging that will take the remainder of your time.
#14
Dreamer, the fact that you've written several tutorials and understand simobjects! :-P Every time I see the word "ShapeBase" I go diving for cover, cuz I'm usually tapped out on learning for the day.
LOL @ the first 90%. I have a bug list that's growing faster than weeds. For everyone i solve, i've got 3 new ones...
Thanks both for the encourgment! By the way I just got Tork-Orc to pick up an object i created AND it displayed in the gui. We have proof of Concept! lol...
Now on to that damn "user-is-hungry" bug - it just won't go away...
11/10/2005 (8:24 pm)
A little of column 'a', a little of column 'b', Mr. Pig. If you want to read about it, check here: My ProjectDreamer, the fact that you've written several tutorials and understand simobjects! :-P Every time I see the word "ShapeBase" I go diving for cover, cuz I'm usually tapped out on learning for the day.
LOL @ the first 90%. I have a bug list that's growing faster than weeds. For everyone i solve, i've got 3 new ones...
Thanks both for the encourgment! By the way I just got Tork-Orc to pick up an object i created AND it displayed in the gui. We have proof of Concept! lol...
Now on to that damn "user-is-hungry" bug - it just won't go away...
#15
Do you have the POV working correctly on your logitech dual action? I've noticed weird issues with it... dunno if it's my controller... or torque.
11/10/2005 (8:35 pm)
@RavenSlay3r Do you have the POV working correctly on your logitech dual action? I've noticed weird issues with it... dunno if it's my controller... or torque.
#16
The next thing (after inventory and gui) is to build my new player model, animate him and program all the controls. I designed a really awesom prince-of-persia style combat system on paper!... ;-)
11/10/2005 (9:04 pm)
Ps. I guess column 'c' would be: I have no clue how much work I actually have left to do. The next thing (after inventory and gui) is to build my new player model, animate him and program all the controls. I designed a really awesom prince-of-persia style combat system on paper!... ;-)
#17
I generally DON"T use the "D-Pad" thing on the logitec. I've had problems with it in numerous emulators, if thats what your reffering to. I think it's a bad design or somthing..
I started with these two resources:
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5471
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5474
11/10/2005 (9:09 pm)
Ramen, the joysticks are working beautifully, actually one of the few things that is.. I generally DON"T use the "D-Pad" thing on the logitec. I've had problems with it in numerous emulators, if thats what your reffering to. I think it's a bad design or somthing..
I started with these two resources:
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5471
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5474
#18
I just saw this link: http://www.frappr.com/garagegames, your right near me!
I live in Hackettstown, but go to school in Glassboro. Drive through Flemington (when it has roads) all the time. They better put the circle back before ThanksGiving so i can go home! :-P
11/10/2005 (9:29 pm)
Mr. Pig,I just saw this link: http://www.frappr.com/garagegames, your right near me!
I live in Hackettstown, but go to school in Glassboro. Drive through Flemington (when it has roads) all the time. They better put the circle back before ThanksGiving so i can go home! :-P
#19
11/12/2005 (9:58 am)
XD. All I have to say... XD
#20
11/12/2005 (12:37 pm)
@ Raven, yeah, i got both those working as well. I use the Dpad for menu navigation and what not. it's funny, i can't press a button, and say slide my finger on it to get to a new button. no. i have to press a button, then release it before it will let me press another one. everything else works fine.
Torque Owner Matt "Mr. Pig" Razza
2112.weaponSlot[3] = true
2112.weaponName[3] = "ak47"
2112.weaponAmmo[3] = 30
I would belive that there inventory system works the same basic way. I think that the vars are saved under the iteam, not the shapebase. Also, they don't use "slots", they do the arrays by name so it would be [ak47] not [3] if I am right. I hope this helps, I'd give you a code example for there inventory system, but I never used it. It didn't support everything I needed anyway, so I made my own.