Jump to content


Photo
- - - - -

An inventory example you can understand


  • Please log in to reply
10 replies to this topic

#1 ellisvlad

ellisvlad

    GMC Member

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

Posted 19 January 2011 - 12:13 AM

  • Title: Inventory Example by Vlad Ellis
  • Description: Allows multiple Items, Slots and swapping slots
  • GM Version: GM8
  • Registered: no(I don't think)
  • File Type: .gmk
  • File Size: 0.01MB
  • File Link: GMK (Link reuploaded due to popular demand =D)


No Credit is required, but is highly appreciated!! :)

Edited by ellisvlad, 20 November 2011 - 11:43 PM.

  • 0

#2 Unsung Hero

Unsung Hero

    GMC Member

  • New Member
  • 286 posts

Posted 24 January 2011 - 05:21 AM

It is very good, but I would rather have the coding on individual objects instead of just two controls. It would make it easier to understand which code goes for which item.
  • 0

#3 Newly Discovered

Newly Discovered

    Harmonious Genius

  • GMC Member
  • 2475 posts
  • Version:GM8

Posted 24 January 2011 - 05:29 AM

I find this very simple to understand, thanks a lot!
As for individual items, that would use way more memory than it needs to and with this, having their info in item_info, it keeps it well organized.

nice job.
  • 0

#4 remixx

remixx

    GMC Member

  • New Member
  • 74 posts

Posted 20 May 2011 - 09:00 AM

Very easy to understand, but how do I drop items and add more of the items to pickup into the room ?

Edited by remixx, 20 May 2011 - 09:05 AM.

  • 0

#5 Keevor

Keevor

    Pixel Phased

  • New Member
  • 23 posts
  • Version:GM8

Posted 03 November 2011 - 03:54 AM

link goes to yahoo search?
  • 0

#6 4 KINGS

4 KINGS

    BioThirst Studio

  • New Member
  • 549 posts
  • Version:GM8

Posted 03 November 2011 - 09:48 AM

Link is broken :confused:

Edited by 4 KINGS, 03 November 2011 - 09:49 AM.

  • 0

#7 ellisvlad

ellisvlad

    GMC Member

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

Posted 20 November 2011 - 11:44 PM

Link is broken :confused:


I've reuploaded it =D
  • 0

#8 The Idiot 11

The Idiot 11

    GMC Member

  • New Member
  • 1 posts
  • Version:GM8

Posted 13 December 2011 - 05:30 PM

How could I get it to pop up when I press the 'I' key in my game and go away when I press 'I' again. I'm sure it's easy but I've never tried something like this before and no one seems to be able to help me. Credit will be given.

Edited by The Idiot 11, 13 December 2011 - 05:31 PM.

  • 0

#9 creators124

creators124

    awesomeliciousmember

  • GMC Member
  • 866 posts
  • Version:GM8

Posted 07 May 2012 - 01:43 AM

this might be a little late in asking you...
but can you make it so that when you drop it on the same item you'll get the number of items you dragged?
  • 0

#10 FoxInABox

FoxInABox

    GMC Member

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

Posted 07 May 2012 - 11:02 AM

@OP:
the test values were wrong:
slotItems[1]=1   //For Testing \/
slotamounts[1]=1

slotItems[2]=2
slotamounts[2]=3

slotItems[3]=1
slotamounts[3]=1 //For Testing /\
the amounts were all set to slotamount[1] .. not to 2 and 3

you draw the inventory from slot 1, but dragging can have the variable 0 ^^ so if you start dragging from outside the inventory and drop on a slot, then it goes to the non drawn slot 0..

your mouse_isin script goes like so:
if (argument) return 1 else return 0
the argument will be true or false either way, so you could just return it instead
return (argument)
does save a bit of prosessing power

very easy example tho I'm not a fan of checking mouse position in the loop, and you also draw it in the loop, which makes the text go behind the other slots, remember the position instead and do the text drawing below the inventory, se my fix below..

and confusing that the item sprite is transparent.. was confused by how the items suddenly appeared in the empty room at first. 

@The Idiot 11:
press I event:
visible = !visible;

that will stop the draw event from running, another way is to stop a part of the event, for example if the draw event draws the inventory and the equipment window, then you do not want to close both:
show = true; // create event
show = !show; // press I event
if show = true{ // draw event
  // drawing code here
}
 
@creators124 && remixx:
how to fill a slot on drop, and drop outside inventory

I can try answer both of yours questions step by step:
note: this does not work with the wrong default test values, see fix at top of post

Spoiler

hope it's still easy to understand .. and will remove it if OP requests or adds some change like this to his file
  • 0

#11 ellisvlad

ellisvlad

    GMC Member

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

Posted 27 July 2012 - 06:12 AM

Because someone asked how, I'm writing how to add an item to the system, it is actually very easy to do :)

1) In the sprItems, add a new image to the end. the image number is your item's ID (Image 1 is item with ID 1, etc.)
2) Open the script item_info. copy and paste this segment of code just after the very last break:
case 3: //Our Item ID 
    switch argument1 { //request
      case 0: return 'Made by Vlad' break    //name
      case 1: return 'This tutorial was made by Vlad' break //description
      //any extra description... (case *: return 'Value' break //extra damage)
    }
  break
3) Now you can add your item to the inventory with item_add(3) or whatever your item ID is!

Easy as 1, 2, 3 :D

Speak to you all next time :)
Vlad
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users