Jump to content


Photo
* * * * * 6 votes

Inventory And Item Engine


  • Please log in to reply
97 replies to this topic

#1 Davve

Davve

    GMC Member

  • GMC Member
  • 4091 posts
  • Version:GM:Studio

Posted 20 September 2009 - 07:19 PM

Info:

  • Title: Inventory and item engine v1
  • Description: This is a inventory and item engine that is easy to use and put in your game!
  • GM Version: GM 8, GM: Studio
  • Registered: Both
  • File Type: .gmk, .gmz
  • File Size: 1437 kB
  • File Link: Here!

Give credit if used!

Features:

  • Item scripts, making it easy to add/edit items!
  • Glitch-free, Runescape styled inventory with 28 slots
  • Fully customizable! Change colors and alphas!
  • Easy to put in your game!

Download:

Download pro version, non pro version and executable.

The difference between the two versions is that the Pro one uses alpha to draw the held item (draw_sprite_ext).

Controls:

Arrow keys - Move the player
Left click - Pick up items/Drag items in inventory/Select an option
Right click - Open an item's option menu
F1 - Game info

Versions:

Version 1.0 - 2009.09.20
First version of Inventory and item engine!


25jxfg2.png

Please tell me what you think and what you want in the next version! laugh.gif


Edited by Davve, 19 December 2015 - 10:50 AM.

  • 4

#2 BeefShaman

BeefShaman

    GMC Member

  • New Member
  • 44 posts

Posted 21 September 2009 - 04:35 PM

omg welldone
  • 0

#3 loverock125

loverock125

    GMC Member

  • GMC Member
  • 1830 posts
  • Version:GM8.1

Posted 21 September 2009 - 06:21 PM

Hmm this is very nice coded indeed.I've done almost the same inventory but still trying to figure out how to make items stack :D
  • 0

#4 exxod

exxod

    GMC Member

  • New Member
  • 144 posts

Posted 22 September 2009 - 12:05 AM

Very very nice. Indeed a great inventory example 5/5. In the future versions you could add multiple inventory panels I.E. banks or just multiple bags. Also for the script item_options, using no = 1,2,3,etc... to define the items ID seems like it would get confusing after about 20 items or so. If possible you might want to make those into strings(if no = "Paper"). This could cause errors but I'm not sure. :D On another note you should make it so you can choose the amount to drop and the amount to stack for stackable items.

Edited by exxod, 26 September 2009 - 04:50 AM.

  • 0

#5 Davve

Davve

    GMC Member

  • GMC Member
  • 4091 posts
  • Version:GM:Studio

Posted 26 September 2009 - 03:43 PM

82 downloads but only 3 comments? ^_^

Anyone else have any suggestions or something to say about this?
  • 0

#6 weckar

weckar

    Helping Hand

  • GMC Member
  • 2616 posts
  • Version:Unknown

Posted 26 September 2009 - 11:52 PM

I can see what inspired the design :-p
  • 0
Just had my 10-year forum anniversary. Feeling - Even - Older.
Awards & Recognitions:
Spoiler

[I have a nasty habit of writing "it is" simply as "it". Please forgive me, I try to avoid it.]

#7 13bgarli

13bgarli

    GMC Member

  • New Member
  • 177 posts

Posted 27 September 2009 - 04:55 PM

Well i think i'm gunna use this example... i have been tring to make my own inventory engine, but it wasnt working out lol
I like the way this is put together, the dragging, the collection of objects, the stacking, the options, everything.
but like every example, you can always update or change things...
some suggestions: custom ammount of boxs , space between boxes, size of boxes, number of rows, ect.
that would be some REALLY cool improvements ^_^ lol

but all in all i like it :D XD
  • 0

#8 Probynator

Probynator

    GMC Member

  • New Member
  • 1 posts

Posted 30 September 2009 - 05:08 AM

Nice system mate! I couldn't have come up with something like that myself, thats for sure!

One noob question though, the "show_message("") part, how do you add a no option for that? and where is the data for it stored?
  • 0

#9 JackBread

JackBread

    Spiky Bread of Death

  • GMC Member
  • 453 posts

Posted 16 October 2009 - 06:40 AM

Excellent! I can actually understand most of this! Thanks! d(^_^)b
  • 0

#10 Guest_Furios boy_*

Guest_Furios boy_*
  • Guests

Posted 16 October 2009 - 10:40 AM

You could make that box appear that says "Cheese-its just cheese"when you put your mouse over it. But until you havent put your mouse over anything than the box is invisible or something.

Sorry for the words that i might typed wrong, i dont speak english that well.

But still the example is pretty good

#11 Davve

Davve

    GMC Member

  • GMC Member
  • 4091 posts
  • Version:GM:Studio

Posted 16 October 2009 - 04:53 PM

You could make that box appear that says "Cheese-its just cheese"when you put your mouse over it. But until you havent put your mouse over anything than the box is invisible or something.


The variable global.inv_select returns what item in the inventory the cursor is hovering over, so...

if (global.inv_item[global.inv_select,0]>0) { //If the item the mouse is hovering over exists...
	inventory_draw_infobox(view_xview+16,view_yview+268,-1,0.5,c_lime) //Draw the info box
}

  • 0

#12 Osiris

Osiris

    GMC Member

  • GMC Member
  • 400 posts
  • Version:GM:Studio

Posted 17 October 2009 - 07:01 AM

When the inventory is full and you try to pick up an item the item just disappears...
  • 0

Current Project:   acujA7dP.png

A 2D Sandbox Adventure, currently in development.  Check out the WIP here.


#13 nemsisstars

nemsisstars

    GMC Member

  • New Member
  • 52 posts

Posted 17 October 2009 - 08:26 PM

Can you close and open the inventory?
  • 0

#14 linkxd1

linkxd1

    GMC Member

  • New Member
  • 5 posts

Posted 22 October 2009 - 08:34 PM

I think you should add to the next version:
  • Open/Close Inventory
  • Equipting Items
Those would be an "OUTSTANDING!" job :blink:
Right now it's: "Awesome!"
  • 0

#15 Davve

Davve

    GMC Member

  • GMC Member
  • 4091 posts
  • Version:GM:Studio

Posted 23 October 2009 - 12:32 PM

  • Open/Close Inventory

1: Make a global variable like global.showinventory.
2: In oInventory's step event, write "if global.showinventory=1" before all the mouse checks.
3: And in the draw event, write "if global.showinventory=1" before all the inventory_draw_... scripts.
4: Done!
  • 0

#16 NYS

NYS

    GMC Member

  • GMC Member
  • 453 posts
  • Version:GM:Studio

Posted 23 October 2009 - 02:29 PM

  • Open/Close Inventory

1: Make a global variable like global.showinventory.
2: In oInventory's step event, write "if global.showinventory=1" before all the mouse checks.
3: And in the draw event, write "if global.showinventory=1" before all the inventory_draw_... scripts.
4: Done!


Draw event won't be executed if the object is invisble, just toggle between visible ^_^
if (visible=true)
{
visible=false;
exit;
}
visible=true;

  • 0

#17 athrowawayxyz

athrowawayxyz

    GMC Member

  • New Member
  • 36 posts

Posted 31 October 2009 - 08:38 PM

This is awesome. Thanks!
  • 0

#18 Universal_X

Universal_X

    GMC Member

  • New Member
  • 126 posts

Posted 08 November 2009 - 07:21 PM

Awesome great engine! xD

I will use this in my game and give you credit ^^

But where do you find the item id in game?

Like in online games: "Player" dropped "itemid"


thanks //UX
  • 0
ѬѯҨ Cities of the Future

#19 Universal_X

Universal_X

    GMC Member

  • New Member
  • 126 posts

Posted 13 November 2009 - 09:29 PM

edit:

Could you make a shop script too? It would help to understand the context of the scripts.

thanks in advance!

Edited by Universal_X, 30 November 2009 - 01:40 PM.

  • 0
ѬѯҨ Cities of the Future

#20 kirisaku

kirisaku

    GMC Member

  • GMC Member
  • 26 posts
  • Version:GM8

Posted 16 November 2009 - 07:46 PM

Please tell me what you think and what you want in the next version! ;)

I would LOVE to see equipment box + hotkeylist in the next version ... ;)
Please make one :)
or explain me how to create one ^^
ty for your hard work =3
  • 0

#21 kirisaku

kirisaku

    GMC Member

  • GMC Member
  • 26 posts
  • Version:GM8

Posted 16 November 2009 - 09:04 PM

oh and i wanted to ask...
i have changed the "picking" item code, so that it would be picked without a mouse just a random keyboard button instead,
but i have encountered some problem... it works fine but, when i leave the mouse in the inventory window (collision) i cannot pick the items...
so in order to pick them i have to remove my mouse from the inventory window...
how can i fix it so i can leave the mouse anywhere and pick with any particular key....?
  • 0

#22 Alfred0110

Alfred0110

    Programmer

  • New Member
  • 366 posts

Posted 01 August 2010 - 09:24 AM

can somebody make a tutorial for this i dont know how to get it into my game
Nvm i mananged to make my own inventory

Edited by Alfred0110, 05 August 2010 - 09:15 AM.

  • 0

#23 theg721

theg721

    G Dawg

  • GMC Member
  • 1959 posts
  • Version:GM8

Posted 01 August 2010 - 10:17 AM

Can someone make a mirror? I can't download anything from MediaFire for some reason.
  • 0

#24 Hygo25

Hygo25

    GMC Member

  • New Member
  • 52 posts

Posted 06 September 2010 - 03:40 PM

You can drag an empty slot onto a slot with an item and it will still switch.
Not sure if it really matters at all, just wanted to point that out.
Great example! It's easy to implement into games!
  • 0
GENERATION 27: The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.

#25 adventchild

adventchild

    GMC Member

  • New Member
  • 33 posts

Posted 07 September 2010 - 06:09 PM

Hello erm... It won't download, I kinder need something like this..
I only want a Menu which will alow me to go to Bag-Items-KeyItems, Options, Save, Pokemon and Pokegear.
...
Anyways guess i'll look elswware...
  • 0
[img]http://t2.gstatic.com/images?q=tbn:ANd9GcTCgJkmCx3P7k5GMdZhVHtMg6xeKEDFajRIDsXC0E0C6Zo7lm8&t=1&usg=__OKdsWVF3QvbFP-cW9IylIRkJoAY=[/img
Goodtimes, Goodtimes, Check out my Pokemon Game It's coming soon :)

#26 Spanone

Spanone

    GMC Member

  • New Member
  • 69 posts

Posted 07 September 2010 - 06:38 PM

yep, download not working
  • 0
Posted Image
Posted Image

#27 Zombie_Plan

Zombie_Plan

    GMC Member

  • New Member
  • 22 posts

Posted 12 February 2011 - 07:15 PM

Hi.

I've tried porting this over into my game, but whenever I place an oItemOnGround I get an error that the variable "item" is undefined.
  • 0

#28 Davve

Davve

    GMC Member

  • GMC Member
  • 4091 posts
  • Version:GM:Studio

Posted 12 February 2011 - 07:20 PM

Hi.

I've tried porting this over into my game, but whenever I place an oItemOnGround I get an error that the variable "item" is undefined.

Place an oItemOnGround in your room and right-click on it while holding control and select Creation Code. Set item to the item value you want there. Like
item = 10; //The item with the ID 10 is lying on the ground.

  • 0

#29 Zombie_Plan

Zombie_Plan

    GMC Member

  • New Member
  • 22 posts

Posted 12 February 2011 - 07:35 PM

Hi.

I've tried porting this over into my game, but whenever I place an oItemOnGround I get an error that the variable "item" is undefined.

Place an oItemOnGround in your room and right-click on it while holding control and select Creation Code. Set item to the item value you want there. Like
item = 10; //The item with the ID 10 is lying on the ground.


Ah cool, thanks :D Now I get this error when I click on an item though:

ERROR in
action number 1
of Mouse Event for Left Pressed
for object oItemOnGround:

Error in code at line 3:
       inventory_add(item,number)
                          ^
at position 25: Unknown variable number

I assume I've missed something else. I don't know what though :S

Okay I derped and see; I need to add number = to the creation code too. Lol.

Edited by Zombie_Plan, 12 February 2011 - 07:39 PM.

  • 0

#30 Davve

Davve

    GMC Member

  • GMC Member
  • 4091 posts
  • Version:GM:Studio

Posted 12 February 2011 - 07:40 PM

I assume I've missed something else. I don't know what though :S

Yeah, you also need to fill in the quantity of the item, go to the creation code and enter like
number = 100;
I forgot about that, it's been a while since I made this :P
  • 1

#31 Zombie_Plan

Zombie_Plan

    GMC Member

  • New Member
  • 22 posts

Posted 12 February 2011 - 08:09 PM

I assume I've missed something else. I don't know what though :S

Yeah, you also need to fill in the quantity of the item, go to the creation code and enter like
number = 100;
I forgot about that, it's been a while since I made this :P


Yeah I found that out. I'd never known how to use creation code...now I do :D
  • 0

#32 Zombie_Plan

Zombie_Plan

    GMC Member

  • New Member
  • 22 posts

Posted 13 February 2011 - 08:27 AM

I hate spamming up a thread with questions, but I have another problem. When my inventory is full I can still pick up items, and they go nowhere. I have checked the code to the best of my knowledge (not much) and seen there is indeed code to stop it, however it doesn't seem to work.

Does anyone know if I need to make any additional changes?
  • 0

#33 Davve

Davve

    GMC Member

  • GMC Member
  • 4091 posts
  • Version:GM:Studio

Posted 13 February 2011 - 10:35 AM

I believe there is a script for checking the total number of items in the inventory, check if that is equal to 28 and don't pick up the item if it is.
  • 0

#34 Zombie_Plan

Zombie_Plan

    GMC Member

  • New Member
  • 22 posts

Posted 13 February 2011 - 11:02 AM

I believe there is a script for checking the total number of items in the inventory, check if that is equal to 28 and don't pick up the item if it is.


I believe it was, but it still let me pick up multiple more items afterwards... I don't think the script works :S
  • 0

#35 Davve

Davve

    GMC Member

  • GMC Member
  • 4091 posts
  • Version:GM:Studio

Posted 13 February 2011 - 11:05 AM

Replace the code in oItemOnGround's left pressed event with this:
//Pick up the selected item
if (global.inv_select=0 && inventory_items()<28) {
    inventory_add(item,number)
    instance_destroy()
}

  • 0

#36 Zombie_Plan

Zombie_Plan

    GMC Member

  • New Member
  • 22 posts

Posted 13 February 2011 - 11:10 AM

Replace the code in oItemOnGround's left pressed event with this:

//Pick up the selected item
if (global.inv_select=0 && inventory_items()<28) {
    inventory_add(item,number)
    instance_destroy()
}


What scares me is I tried doing something similar and it didn't work, but this did.

Thank you so much sir! :D

And now, if I drop something, the game doesn't register that there is empty space in my inventory.

Edited by Zombie_Plan, 13 February 2011 - 11:15 AM.

  • 0

#37 Katipo007

Katipo007

    42

  • GMC Member
  • 436 posts
  • Version:GM:Studio

Posted 30 September 2011 - 09:11 PM

Hey there I like your engine
BUT for some reason when you right click a item in the inventory the option box comes up but with no text!

so it looks like this
__
| |
| |
|_|

when i know it should look like this

______
|Wear |
|Drop |
|Cancel |
|______|


Hope i made some sense!

Edited by Katipo Games, 30 September 2011 - 09:13 PM.

  • 0

"let your light shine before others, that they may see your good deeds and glorify your Father in heaven." - Matthew 5:16

I do not need to fear anything; for if the God of all, who created and cares for everything is for me, who or what can be against me.


#38 Davve

Davve

    GMC Member

  • GMC Member
  • 4091 posts
  • Version:GM:Studio

Posted 30 September 2011 - 10:35 PM

Hey there I like your engine
BUT for some reason when you right click a item in the inventory the option box comes up but with no text!

so it looks like this
__
| |
| |
|_|

when i know it should look like this

______
|Wear |
|Drop |
|Cancel |
|______|


Hope i made some sense!

Go to the script called item_options and add your item ID there, together with the wished options.
  • 0

#39 Katipo007

Katipo007

    42

  • GMC Member
  • 436 posts
  • Version:GM:Studio

Posted 01 October 2011 - 04:31 AM

All the item option box's do this: Posted Image
(custom item or default)

Some one please help! :sad:

*edit* maybe its because I'm using 8.1? :dry:

Edited by Katipo Games, 01 October 2011 - 08:31 AM.

  • 1

"let your light shine before others, that they may see your good deeds and glorify your Father in heaven." - Matthew 5:16

I do not need to fear anything; for if the God of all, who created and cares for everything is for me, who or what can be against me.


#40 Davve

Davve

    GMC Member

  • GMC Member
  • 4091 posts
  • Version:GM:Studio

Posted 01 October 2011 - 01:02 PM

All the item option box's do this:

Have you edited item_options? If not, send the .gmk.
  • 0

#41 Jobo

Jobo

    Second-Scum-Of-The-Earth

  • YoYo Games Staff
  • 3000 posts
  • Version:GM:Studio

Posted 01 October 2011 - 01:47 PM

Hmm this is very nice coded indeed.I've done almost the same inventory but still trying to figure out how to make items stack :D

Loop through all items in the inventory until you find the same item as you're trying to add, and if successful, you just increase a counter on that item. Then when using/dropping a stacked item, you just decrease the counter.


@Davve
Pretty good example. A lot of people should find use in this, though I doubt 'newcomers' will find it very helpful as it's quite advanced.

Edited by Jobo, 01 October 2011 - 01:50 PM.

  • 0

My posts are my own views and opinions... Unless they are yours too, in which case I think you're a very intelligent and handsome individual (I think you are anyway!)


#42 Katipo007

Katipo007

    42

  • GMC Member
  • 436 posts
  • Version:GM:Studio

Posted 02 October 2011 - 12:33 AM

All the item option box's do this:

Have you edited item_options? If not, send the .gmk.


No I haven't edited any of the code I've sent the .gmk to your msn

Edited by Katipo Games, 07 October 2011 - 12:07 AM.

  • 0

"let your light shine before others, that they may see your good deeds and glorify your Father in heaven." - Matthew 5:16

I do not need to fear anything; for if the God of all, who created and cares for everything is for me, who or what can be against me.


#43 blackbeard

blackbeard

    GMC Member

  • GMC Member
  • 64 posts
  • Version:GM:Studio

Posted 10 October 2011 - 12:02 AM

This Inventory Code is great! I am using it in my Adventure RPG that I am converting to GML from some older code I have been compiling for a while. Right now I'm trying to implement it within my game environment, but I'm experiencing a couple of snags..... I have been messing around with the box sizes to accommodate a pause/inventory screen; however, I don't know if through this I have disabled the mouse "hover over" function- and the descriptions/options don't seem to be working either. I have also replaced some of the sItems with my own, and subsequently their descriptions, but I do not believe this to be the cause. Any suggestions/direction? Thanks.Posted Image
  • 0

#44 Katipo007

Katipo007

    42

  • GMC Member
  • 436 posts
  • Version:GM:Studio

Posted 12 October 2011 - 07:59 PM

All the item option box's do this: Posted Image
(custom item or default)

Some one please help! :sad:

*edit* maybe its because I'm using 8.1? :dry:


PLEASE SOME ONE HELP ME!
  • 0

"let your light shine before others, that they may see your good deeds and glorify your Father in heaven." - Matthew 5:16

I do not need to fear anything; for if the God of all, who created and cares for everything is for me, who or what can be against me.


#45 Davve

Davve

    GMC Member

  • GMC Member
  • 4091 posts
  • Version:GM:Studio

Posted 12 October 2011 - 08:09 PM

You never sent the .gmk...
  • 0

#46 Katipo007

Katipo007

    42

  • GMC Member
  • 436 posts
  • Version:GM:Studio

Posted 12 October 2011 - 08:59 PM

You never sent the .gmk...

I sent it to your msn. oh well where can i upload a file?

*edit*
is it tested in 8.1?
and how easy is it to save into a .ini?

P.S in the exe it worked fine: the option box worked, the HP was above the player
but in GM (8.1) none of that worked

Edited by Katipo Games, 12 October 2011 - 09:11 PM.

  • 0

"let your light shine before others, that they may see your good deeds and glorify your Father in heaven." - Matthew 5:16

I do not need to fear anything; for if the God of all, who created and cares for everything is for me, who or what can be against me.


#47 Davve

Davve

    GMC Member

  • GMC Member
  • 4091 posts
  • Version:GM:Studio

Posted 12 October 2011 - 09:51 PM

*edit*
is it tested in 8.1?
and how easy is it to save into a .ini?

P.S in the exe it worked fine: the option box worked, the HP was above the player
but in GM (8.1) none of that worked

Well, GM8.1 changed the way arguments work, which is the main reason I never upgraded there from GM8.0 and could possibly be the cause of the problem. Since I don't have 8.1, I won't be able to help you. :(
  • 0

#48 blackbeard

blackbeard

    GMC Member

  • GMC Member
  • 64 posts
  • Version:GM:Studio

Posted 13 October 2011 - 01:03 PM

Davve, this inventory engine is great! I've been working on modifying it to my own needs and I'm doing so with good results. I do have a question- In the inventory you use sprite sub-images to represent "things" in your gaming environment. I'm sure by assigning those images a variable they can represent objects . I was wondering if there was a way to create images with animation somehow in the stead of still sub-images. Almost to say- "Can a sub-image have sub-images?" Thanks again for any input.
  • 0

#49 mibikin

mibikin

    GMC Member

  • New Member
  • 3 posts
  • Version:GM8

Posted 25 May 2012 - 05:18 AM

Davve, in my game, I want to make it so the amount of arrows in the inventory goes down as they are fired? How would I go about doing this with this engine? I've accomplished a bunch of problems that I had with this inventory, but this I need help with. I know this is an old thread, but please reply.
  • 0

#50 Davve

Davve

    GMC Member

  • GMC Member
  • 4091 posts
  • Version:GM:Studio

Posted 25 May 2012 - 02:10 PM

Davve, in my game, I want to make it so the amount of arrows in the inventory goes down as they are fired? How would I go about doing this with this engine? I've accomplished a bunch of problems that I had with this inventory, but this I need help with. I know this is an old thread, but please reply.

In the item_options_code script:
global.inv_item[global.inv_optionitemno, 1] -= 1

Edited by Davve, 25 May 2012 - 02:10 PM.

  • 0