Lite-c Inventory System

Posted By: clone45

Lite-c Inventory System - 01/21/08 05:17

Hello,

I am incredibly excited to offer the 3d GameStudio community a flexible inventory system for lite-c. I'm usually pretty humble about my code, but I think that this is something special. Here are some of the features:

  • You can pop open multiple inventory bags and move items from bag to bag.
  • You can drag bags around and the panel layers are handled automatically for you. For example, if you have a few bags that overlap, clicking the one in the center will bring it forward.
  • The system supports callbacks so your code can tell what's going on.
  • It's easy to use. You don't need to touch the inventory code at all.
  • "Slot types", such as weapon slots, are supported.


Here's a youtube video showing it in action, although the arrow pointer doesn't show up in my video:

http://www.youtube.com/watch?v=r6tv3YM1SYg

I've created a demo that you can download at:

http://www.indiegamejobs.com/temp/inventory_demo.zip

The demo uses images from World of Warcraft because I didn't have any inventory images handy. Obviously, don't use those images in games. In the demo, press 'a' to open bag1. Press 's' to open bag2. Press 'd' to open bag3. Press 1 or 2 to add items to the inventory. Press z to close the demo.

Here's a excerpt from the demo lite-c:

Code:

item_sand = inv_create_item(1,0,"item1.pcx","item1.pcx");
item_wool = inv_create_item(2,0,"item2.pcx","item2.pcx");

// Create bag 1

bag = inv_create_bag(1,"pack.pcx");
inv_set_bag_drag_region(bag,5,3,128,18);
inv_set_bag_close_region(bag,129,0,148,19);

inv_add_slot_to_bag(bag,1,0,"slot_bg.pcx",9,38);
inv_add_slot_to_bag(bag,2,0,"slot_bg.pcx",44,38);
inv_add_slot_to_bag(bag,3,0,"slot_bg.pcx",78,38);
inv_add_slot_to_bag(bag,4,0,"slot_bg.pcx",112,38);

inv_insert_item_into_bag(bag,item_wool);



Documentation can be found on the wiki here: http://www.coniserver.net/wiki/index.php/Inventory.c_docs

I'm going to keep working on the inventory as I build out my game. However, it should be usable as-is. I've posted the main files on the wiki too so that people can continue the project if I get too wrapped up with my day job. Here's the wiki page:

http://www.coniserver.net/wiki/index.php/Clone45%27s_Inventory_Framework

A special thanks to everyone who takes the time to answer questions on these forums. You are awesome!

- Bret
Posted By: Pappenheimer

Re: Lite-c Inventory System - 01/21/08 17:21

Wow, looks very flexible and intuitive!
Great contribution!
Awesome in its additions like demo and documentation in the wiki!
Posted By: Quad

Re: Lite-c Inventory System - 01/22/08 18:18

great, exactly what i was looking for. (its even more )
Posted By: clone45

Re: Lite-c Inventory System - 01/23/08 03:17

You're welcome Quadraxas. I'm going to be adding some functionality that's missing in the next few weeks. For example, there should be a way to remove a bag from the layer-control system so that its layer remains constant. There should be a way to remove an item from a bag programmatically. There should also be a "close_all_bags()" function.

Also, although I've done my best to avoid them, keep an eye out for memory leaks.

Cheers!
- Bret
Posted By: PadMalcom

Re: Lite-c Inventory System - 01/26/08 16:37

There is no possibility to use it in C-Script, is it?
Posted By: FBL

Re: Lite-c Inventory System - 01/26/08 16:59

AFAIK allows C-Script using of Lite-C snippets, but not vice versa. Haven't tried though, but take a look at the migration page in the manual.
Posted By: PadMalcom

Re: Lite-c Inventory System - 01/26/08 17:18

I'll have a try (never thought that it would be possible to mix these both languages up)

EDIT: It doesn't work fine, I get an error in the inventory.c ... at line 373.
Posted By: Quad

Re: Lite-c Inventory System - 02/01/08 01:34

Quote:

I'll have a try (never thought that it would be possible to mix these both languages up)

EDIT: It doesn't work fine, I get an error in the inventory.c ... at line 373.




i succesfully added this to my expiremental project, i think i had some errors but dont remember exactly, fixing them was easy.

anyways, whats the error exactly?
Posted By: PadMalcom

Re: Lite-c Inventory System - 03/04/08 08:41

I now chaged my entire code to lite-c due to the advantage of structs, will try it again tonight.
Posted By: Arrovs

Lite-c Inventory System - 03/04/08 21:59

This is wonderfull! Im tryed to make inventory already long time ago, but without succes (of course im uzing c-script)! And problems with one panel creating more times and moving all. And all this interractive things like to you!
I sure will try out, but only through c-script!
And one question or really that is done only with lite-c and nothing from dll.
Posted By: PadMalcom

Re: Lite-c Inventory System - 03/06/08 07:31

Hey, is there any possibility to show a description when my mouse is over an item slot? I tried to figure out if the event_type you perform on the panel is an EVENT_TOUCH or and EVENT_CLICK but it won't work Seems as if a panel event can't decide between multiple event_types.
Posted By: Nowherebrain

Re: Lite-c Inventory System - 03/06/08 10:01

maybe trace from mouse pointer(slow sometimes) return the item id and pop up a help topic...not sure how well it would work as my code is ugly normally...(ok, always)lol
Posted By: Nicolas_B

Re: Lite-c Inventory System - 03/06/08 18:08

thx for this nice contribut.
Good Work!!

gz Nicolas
Posted By: PadMalcom

Re: Lite-c Inventory System - 03/07/08 09:23

Good Idea, I'll try that

Anyway thanks for your work Clone, I changed the code to have just one inventory as it is neccessary for Adventures. Since your comments were placed so well it was so easy to modify it!
Posted By: PadMalcom

Re: Lite-c Inventory System - 05/15/08 15:19

How do I cleanly remove items? I can't find a function here?
Posted By: PadMalcom

Re: Lite-c Inventory System - 05/20/08 14:13

Anybody there? frown
Posted By: paracharlie

Re: Lite-c Inventory System - 08/12/09 02:36

EVerything basically works and Nice work! I do get an error though. Empty prototype called in error when I call up a bag.
Code:
function addSlotPanelAssoc(Slot* slot, PANEL* slot_panel)



Also, when you drag around the bags the inventory slot bmaps stay in place on screen.
Any ideas on a fix?

Well I fixed that ^^^ problem now I have another error lol.
Empty prototype called in: inv_open_bag... Any ideas? I dont see any mispelling and no missing variables.
© 2024 lite-C Forums