[GameMaker Tutorial] Stacking RPG Inventory

Поділитися
Вставка
  • Опубліковано 8 вер 2024
  • Check out my popular GameMaker Book and GameMaker Courses: www.heartbeasts...
    Video by Electric Donkey showing how to make this work with views: • [Extended GameMaker Tu...
    Follow me on Twitch for GameMaker livestreams: / uheartbeast
    Follow my twitter: / uheartbeast
    Like my Facebook page: / heartbeast.studios
    Follow me on Tumblr: / uheartbeast
    Thank you all so much for your support!

КОМЕНТАРІ • 254

  • @MasterSoko
    @MasterSoko 8 років тому +48

    That feeling of fear when he runs his room and doesn't get any error messages but you get one. He says, "Good, no error messages!" At that point, you know you are on your own trying to figure out where you went wrong. :)

    • @ArmisHart
      @ArmisHart 8 років тому +5

      +Puric Yato he can't hold our hands forever :c

    • @exthase_original
      @exthase_original 7 років тому

      the best errors are these, you make 3 videos ago... and you still search for the damn line

    • @meganoob9281
      @meganoob9281 7 років тому +1

      Every time you get an error you know you are on your way to learn something.

  • @TheLordofLemons
    @TheLordofLemons 9 років тому +4

    Nice to see this finally done, I've been waiting for ages to see you cover this!

  • @finnmontaner3310
    @finnmontaner3310 8 років тому +3

    There should be a part 2 about how to implement it into the game, how to change its position, how to change its size, how to change aesthetics, how to show/hide it, etc.

  • @pyxelpub8251
    @pyxelpub8251 8 років тому +2

    Hey Heartbeast, can you make an expanded tutorial on how to make one item take like 4 spaces, like in Deus Ex and Resident Evil 4?I think that would make items more realistic, a handgun would take like one space where as a shotgun would take 2 or 3.Thanks man, keep up the great vids!

  • @JimmyMcGill12
    @JimmyMcGill12 9 років тому

    Oh man you're working overtime dude, thanks for making another video today.

  • @snootboi6988
    @snootboi6988 7 років тому +2

    Hey Heartbeast, Love your Tutorials...
    But, You've got YY is greater than width, instead of height.
    And, the same for XX. 32:55

  • @SlawBunnies909
    @SlawBunnies909 7 років тому

    Amazing tutorial. I had a few errors here and there but was able to fix them by going through the comments are figuring it out myself. I was using different grid sizes and names, so I wasn't going by your exact code. Nonetheless, very great tutorial.

  • @uheartbeast
    @uheartbeast  9 років тому +4

    See link in description for video by Electric Donkey showing how to make this work with views: ua-cam.com/video/LMdXczEAn4c/v-deo.html

    • @survivalgamer1275
      @survivalgamer1275 8 років тому +2

      +HeartBeast
      *FOR EVERYONE GETTING AN ERROR WHEN CHANGING THE DIMENSIONS OF THE INVENTORY*
      at [ 33:10 ] he made a mistake, he linked the yy with width and xx with height (should be other way around)
      Just switch those around

    • @survivalgamer1275
      @survivalgamer1275 8 років тому +1

      +HeartBeast *I made a drag and drop function for this inventory system check it out!:*
      EVENT: Create:
      // Drag and Drop
      dnd = false;
      dnd_item = item.none;
      dnd_count = 0;
      EVENT: Global left pressed:
      ///Drag and Drop
      //Drag and drop (empty)
      if dnd = false {
      dnd_cords_x = x_to_gx(mouse_x);
      dnd_cords_y = y_to_gy(mouse_y);
      dnd_count = count[# dnd_cords_x, dnd_cords_y];
      dnd_item = box[# dnd_cords_x, dnd_cords_y];
      if !dnd_item = item.none {
      dnd= true;
      repeat(dnd_count) { inventory_remove_item(dnd_cords_x, dnd_cords_y); }
      }
      } else {
      if dnd_item = item.none {
      dnd = false;
      repeat(dnd_count) { inventory_add_item(dnd_cords_x, dnd_cords_y, dnd_item); }
      } else {
      var gx = x_to_gx(mouse_x);
      var gy = y_to_gy(mouse_y);
      dnd_item2 = box[# gx, gy];
      dnd_count2 = count[# gx, gy];
      repeat(dnd_count2) { inventory_add_item(dnd_cords_x, dnd_cords_y, dnd_item2) }
      repeat(dnd_count2) { inventory_remove_item(gx, gy, dnd_item2) }
      repeat(dnd_count) { inventory_add_item(gx, gy, dnd_item) }
      dnd = false;
      }
      }

    • @survivalgamer1275
      @survivalgamer1275 8 років тому

      What does not work?

    • @survivalgamer1275
      @survivalgamer1275 8 років тому

      +MrVesprFTW And, have you inserted everything in the right event?

    • @kingdomofmoviez5362
      @kingdomofmoviez5362 8 років тому

      when I click on a top half of a square nothing happens but when I click on the bottom half it adds the item and the stack circle is above the items

  • @coffeeshop8046
    @coffeeshop8046 8 років тому

    By changing the draw event to a draw GUI event the inventory worked well with my view system.

  • @mrmortonblogs
    @mrmortonblogs 8 років тому

    I know it's been quite a while since you've done this, but one thing that's challenging for me is trying to implement an 'equip' system. Where you have fixed slots (like on a character outline) and can drag/drop things from your inventory into the appropriate slot. The system could then check what item is in what slot and make changes to global variables (like the characters combat stats).Thoughts?

  • @psionixsoftworks7771
    @psionixsoftworks7771 6 років тому

    At 6:40 you can save an extra step. The grid values default at 0.

  • @manolisaniolip8163
    @manolisaniolip8163 8 років тому +1

    I wanna make an enchanting system where you can +1-+10 your armor/weapon. DO i have to make a seperate item for each + upgrade? What are some other faster ways to do it? Thanks

  • @patrickdavis9209
    @patrickdavis9209 9 років тому

    Good job with the videos as always. I would love to see a lets pixel on enemy slimes with animation

  • @Galluxi
    @Galluxi 9 років тому

    nice tutorial!

  • @DiasFranciscoA
    @DiasFranciscoA 9 років тому

    Your tutorials are just great...simple, clean and very well explained! Keep them coming ;)
    (btw: if I want to add a item database, lets say, item: description, weight, use action, icon.. should it be done using a obj for each item? or would it be better to add a code segment in the "Inventory" create event handling the array of items?! do you have some ideias.. you could make some advice tutorials, not explaining everything... but giving pro and cons about several system implementations, like battle systems and menus and inventory)
    Again, great work, and... is it possible to buy the physic copy of your book and ship it to Portugal (Europe)? :D

  • @AbolinGames
    @AbolinGames 9 років тому +5

    but can you maybe make a exstanded tutorial because i can't use my camera move's with my player and than the inventory disappears so can you help me please?

    • @bonecrusher2002
      @bonecrusher2002 9 років тому +1

      instead of a draw event put it into a draw gui event as a gui sticks to views

    • @AbolinGames
      @AbolinGames 9 років тому

      bonecrusher2002 tried it didn't work or i did it wrong.

    • @ElectricDonkeyGML
      @ElectricDonkeyGML 9 років тому +1

      +Abolin If you put it into the draw GUI (which I have tried) the issue is that when you click to remove/add an item, it thinks that you are out of the x and y range. This is because in the x_to_gx and y_to_gy scripts it is looking at the x and y co-ordinates of the inventory and then seeing how big the rest of the inventory is from there. As the inventory itself is drawing in the GUI, but the inventory's co-ordinates are still somewhere in the room. This tells the computer that the certain inventory is in the room (where you placed the object) however we see it as being in the GUI and on our screen. Hope you can understand that. I am currently working on putting this into the GUI and will reply when/if I finish :)

    • @ElectricDonkeyGML
      @ElectricDonkeyGML 9 років тому +1

      +Abolin I have changed a few bits of code to make it sorta do this. It can only be placed in the top left hand corner though atm. Here are the changes -
      x_to_gx - Replace inventory.x with view_xview[0]
      y_to_gy - Replace inventory.y with view_yview[0]
      inventory draw - (Swap to draw GUI)
      inventory draw GUI - Replace var tx = x+(xx*box_size); with var tx (xx*box_size);
      ((Do same with y, obviously changing the x to y))
      Hope this helps :)

    • @AbolinGames
      @AbolinGames 9 років тому

      Electric Donkey thanks man

  • @OliverSallander
    @OliverSallander 8 років тому

    Hi Benjamin! I'm fairly new to programming and have a question about why you choose to have two ds_grids one for the item and one for the count? correct me if I'm wrong but couldn't one ds_grid hold both information? I read somewhere that data structures is pretty memory heavy on GM so it would make sense to use as few as possible, but I fear I'm missing something!
    I really appreciate your videos, keep up the excellent work! :)

  • @loplopdoosderachter9287
    @loplopdoosderachter9287 9 років тому

    I learn all thinks of game maker .From thuis channel.Thx!

  • @kayomn
    @kayomn 8 років тому

    So how would you go about assigning things like item names and descriptions? This is ID-based, which is well and good, but the player would probably need more elaboration on what the item did other than a small image.

  • @theabsurdityseries5597
    @theabsurdityseries5597 8 років тому +6

    Is there a way to save this??

    • @dukmadueno3793
      @dukmadueno3793 7 років тому

      yes, with an advanced ds map you can, search for it

    • @sixthsurge
      @sixthsurge 6 років тому

      file_text_open_write and ds_grid_write?

  • @ElaBamz
    @ElaBamz 8 років тому

    Thank you for your wonderful lessons

  • @mattleonhart1075
    @mattleonhart1075 8 років тому

    Thanks a lot for this tutorial, Ben!

  • @SaladeDressin
    @SaladeDressin 8 років тому

    Hi. Thnx for this inventory. I got it working and also moving with my view.
    But, how can I get a description of the items inside the inventory? So when I hoover with my mousepointer over a item, I get a little text what it is right next to the item count circle.

  • @TheReapersPenguin
    @TheReapersPenguin 8 років тому

    Hi, thank you for the amazing tutorial, quick question though, how can I set it up so if I have say a health potion in my inventory and I press a certain key on keyboard one item is removed?

  • @jakeandaidadventures
    @jakeandaidadventures 8 років тому

    How can I make the middle mouse button select the sword or whatever item I want to select?

  • @MonochromaticEarth
    @MonochromaticEarth 7 років тому

    so we have this handy script to find the grid the mouse is over but how do i find what item in in that slot?

  • @Sam-tw5jn
    @Sam-tw5jn 8 років тому

    Is it possible to add 'inventory slots' ? So the player could expand the inventory at some point during the game?

  • @someidiotfromover7yearsago
    @someidiotfromover7yearsago 7 років тому

    but how do I check the value of the item my mouse is hovering over?
    So that when I remove it, I can actually check which item is being used?
    That seems like really important information and I don't know if I just missed how to do it or it wasnt mentioned

  • @gamemaker2012
    @gamemaker2012 5 років тому

    How can I limit the items, like only keep adding 1 til I reach 9 after that then it stops ?

  • @hamod2g978
    @hamod2g978 9 років тому

    thanks man, great tutorial!

  • @Etienne_H
    @Etienne_H 9 років тому

    How did you learn all of this btw? I like your way of explaining the syntax. Very helpful.

    • @stupidstormy36
      @stupidstormy36 9 років тому +1

      Rene Hupfer A good place to start would be the help file included with Game Maker (by pressing F1) and look through its contents. You can also take a look at the built-in tutorials for Game Maker Studio. From the Welcome screen, click on the Tutorials tab and select which tutorial you'd like to do. You may have to download and install them, but this is an easy fix by right clicking the tutorial and then click on Install.

  • @ElectricDonkeyGML
    @ElectricDonkeyGML 9 років тому

    +HeartBeast I made a video showing you through the stages on how to add this to the GUI layer, am I allowed to post the link?

  • @killallfeminists
    @killallfeminists 7 років тому

    how to do that if collide with particular object player is gonna pick a particular item and how to equip

  • @Hatmaster
    @Hatmaster 9 років тому

    Thank you for the video

  • @matrixstudio9560
    @matrixstudio9560 8 років тому

    I just found (with some help) one major problem that I had. I had my inventory object named as obj_inventory where as Heartbeast just named his inventory. I was wondering why inventory showed up red in his code and white in mine, It wasn't registering in my brain. I had to go back through all of the code and change "inventory" to "obj_inventory" So be mindful of what your inventory object is named.

  • @SimianVirus
    @SimianVirus 6 років тому

    Omg man, i didnt know that inventory will be so hard to write. Thanks for this simply tutorial how to get powerfull eqipment in my game. (this is my first inventory i ever made... copied :D)

  • @tuckertcs
    @tuckertcs 9 років тому

    aparently the sword and bomb only show up if I make the inventory 8x8 (I origonally edited it to be 8wide and 1 tall ????

  • @CoreyHardt
    @CoreyHardt 8 років тому

    My mouse clicks are misaligned with adding/removing inventory objects, by exactly half of the x and y values of the boxes. I'm not sure how, I believe I followed every line of his code to the letter. Really bothering me that I can't figure it out.

  • @kokkiiiiiiiiinis
    @kokkiiiiiiiiinis 9 років тому

    Awesome as usual Ben :)

  • @UNDADTHPNGUNLRD
    @UNDADTHPNGUNLRD 6 років тому

    Trying to get this inventory to work in a draw gui event has been completely hopeless for me. I've read every comments that has anything to do with this problem to no avail. Can anybody help?

  • @sinanian5724
    @sinanian5724 8 років тому

    Ben is taking a while to upload a inventory tutorial to his RPG series. So can I use this one?
    ~Bork

  • @dominickillian3391
    @dominickillian3391 8 років тому

    how do you get this to work with a key press such as pressing i opens the inventory

  • @jar0fair
    @jar0fair 8 років тому +1

    I am getting error:
    draw_sprite argument 2 incorrect type (5) expecting a Number (YYGI32)
    at gml_Object_obj_inventory_DrawEvent_1 (line 7) - draw_sprite(spr_items, box[# xx, yy], tx, ty);
    Does anyone know why this might be happening? It seems like a few other people are encountering the same error.

    • @thegridlion4156
      @thegridlion4156 8 років тому

      I got the exact same message. I don't know how to fix it, but i tried changing the names of the variables and it didn't do anything. So yeah. It's not that.

    • @thegridlion4156
      @thegridlion4156 8 років тому

      I know it's the box[# xx, yy] causing problems, but that's about it.

    • @Poloskaberci
      @Poloskaberci 8 років тому

      try to put string() around the box[# xx, yy]

    • @computer4rt
      @computer4rt 8 років тому

      i got the same error: i think when you copied the line four in (draw event): "for (xx = 0; xx < width; xx++){}", you forgot to change some of the arguments in line three: "for (yy = 0; yy < height; yy++) {}"
      i hope it help's you out

  • @MiguelAngelValdepenaDelgado
    @MiguelAngelValdepenaDelgado 6 місяців тому

    very very good !!!

  • @JoshBeatty6
    @JoshBeatty6 9 років тому

    Are you participating in ludum dare?

  • @wangsoft
    @wangsoft 8 років тому

    How would you make this work with a controller? I want to use xbox one controller D-pad to control the inventory eg. cycle through ect.. Does anyone have any suggestions?

  • @jubba8195
    @jubba8195 9 років тому

    Nice video but you should have a video implementing this into an RPG game

  • @tuckertcs
    @tuckertcs 9 років тому

    ok I fixed part of it I now have 4 potions but still nothing else??

  • @dstails_4599
    @dstails_4599 6 років тому

    Is there a way to possibly do this in game maker 8.1?

  • @GeorgeKTM4String
    @GeorgeKTM4String 8 років тому

    I'm getting an out of bounds error:
    Grid 1, index out of bounds writing [4,3] - size is [4,4]
    Whenever I click outside the grid. I learned grid 1 is the count grid, and it was giving me an issue right here:
    ///Add a Random Item to the Inventory
    var gx = x_to_gx(mouse_x);
    var gy = y_to_gy(mouse_y);
    var add_item = choose(minor_heal_pot[?'sprite'],minor_rez[?'sprite'],weak_axe[?'sprite'],metal_shield[?'sprite'],cloth_shoes[?'sprite']);
    if(count[#gx,gy]==0)
    {
    inventory_add_item(gx,gy,add_item);
    }
    else
    {
    count[#gx,gy]++;
    }
    Since the out of bounds debugging is inside the add_item script, its kicking me out of my game. I found a bootleg workaround, but is there a more elegant solution to sorting this out?
    HeartBeast has the same thing I have (unless I've missed something) and he gets his debugging message and does not get kicked out when he clicks outside of his grid.
    Anyone got any ideas?

  • @larryteslaspacexboringlawr739
    @larryteslaspacexboringlawr739 9 років тому

    thank you for gamemaker tutorial

  • @Nickerino617
    @Nickerino617 7 років тому

    This tutorial helped me alot with what I am aiming for! Thanks! I have one quick question about the stacking. I added a stack limit for the items, set it to stop counting on 999 and add a new stack in the next free slot. That works fine. but now I'm wondering how I can disable the stack for certain item groups, like swords and armor. It is a bit tedious to say
    if (add_item != item.sword && add_item != item.shield && etc....) I can't figure it out :/

    • @Nickerino617
      @Nickerino617 7 років тому

      Nevermind :p managed to fix it by saying if (add_item

    • @Fjordgnu
      @Fjordgnu 7 років тому

      Would you mind explaining where/how you set up the stack limit? I'm way out of my depth here, I feel.

    • @Nickerino617
      @Nickerino617 7 років тому +1

      Inside the scr_pickupItem
      for (var yy = 0; yy < obj_inventory.slotH; yy++) {
      for (var xx = 0; xx < obj_inventory.slotW; xx++) {
      var item_count = obj_inventory.itemCount[# xx,yy];
      if (obj_inventory.invSlots[# xx,yy] == add_item && item_count < item_maxCount && add_item

    • @Fjordgnu
      @Fjordgnu 7 років тому

      Cheers - appreciate it! I should be able to puzzle it out from here. :)

    • @Fjordgnu
      @Fjordgnu 7 років тому

      ... and got it! Once again, much appreciated!

  • @purpleice2343
    @purpleice2343 8 років тому

    Why not just set item count to 0 and set item to none if count is less than 0? Player won't lose anything (having something negative is bad anyway) and bug will fix itself if it ever happens.
    13:55

  • @lambnugget3246
    @lambnugget3246 7 років тому

    How to add an item to the first empty slot with "pickup item" script ?

  • @JohnPanozzo
    @JohnPanozzo 8 років тому +4

    Yeah after I completed this tutorial my character disappeared... I think I might just re code the whole game, lol.

    • @theabsurdityseries5597
      @theabsurdityseries5597 8 років тому +2

      you need to draw the player object too if you used the player for the inventory drawing

    • @CoffeUp
      @CoffeUp 4 роки тому

      use draw_self() inside the draw_event for the object of the player

  • @domi4587
    @domi4587 9 років тому

    Everything works just my grid dont get shown, i looked for 5 times every code and nothing found... rly need help
    You do awesome tutorials, keep on doing this awesome stuff :)
    Thx for answers and the tutorial

    • @patrykkozio155
      @patrykkozio155 8 років тому

      +Ghandi check your inventory_pickup_item, check loops in the script make sure if write xx++ and yy++

  • @tuckertcs
    @tuckertcs 9 років тому

    mine drew 5 potions and no bomb or sword???

  • @vincent4571
    @vincent4571 4 роки тому

    Ur a f-in genius! THANK YOU

  • @DevDeDeveloper
    @DevDeDeveloper 8 років тому

    can someone explain the uses of box[# xx, yy] for me? I don't understand how draw_sprite(spr_item,box[# xx, yy], tx, ty) gives the image index needed or how draw_text(tx-1,ty-8,count[# xx , yy]) gives the correct string. If someone could explain it'd be really helpful because this is stopping me from fully understanding ds grids. thank you

    • @survivalgamer1275
      @survivalgamer1275 8 років тому

      +devin kelly Oke, I finally (because of this vid) understood the grid bullshit --
      So,
      let get the example: box[# xx, yy]
      "box" is refering to the grid
      the square bracket contain which "slot" of the grid needs to be accessed / changed etc.
      Then I will try to make it as clear as posible (I am not the best at explaining... ) LET'S ADD AN ITEM
      this is what you have in your script (add item)
      ///inventory_add_item(x, y, item)
      var xx = argument[0];
      var yy = argument[1];
      var add_item = argument[2];
      So, let me convert it step by step:
      In you're code you would type this: inventory_add_item(3, 1, item.bomb)
      the line above will add a bomb item in the x=3 and y=1 slot
      [empty] - [empty] - [empty] - [empty]
      [empty] - [empty] - [empty] - [BOMB]
      [empty] - [empty] - [empty] - [empty]
      [empty] - [empty] - [empty] - [empty]
      This will be:
      var xx = argument[0]; >>>>> var xx = 3;
      var yy = argument[1]; >>>>> var yy = 1;
      var add_item = argument[2]; >>>>> var add_item = item.bomb;
      then if I refer to: box[# xx, yy] the xx is the x coordinate in the grid the yy the y coordinate
      ------------
      draw_sprite(spr_item,box[# xx, yy], tx, ty)
      It took me a while to figure this one out (thanks for commenting - it helped me understand too :) )
      draw_sprite >>>> explains itself
      spr_item >>>> same thing
      box[# xx, yy] >>>> because of the "for statements" it will be all coordinates available in the grid. (line below)
      box[# 0, 0] > box[# 0, 1] > box[# 0, 2] > box[# 0, 3] > box[# 1, 0] > box[# 1, 1] > box[# 1, 2] > ETC.
      tx (and ty) are calculated like this: x+(xx*box_size)
      x as the start position of the inventory object
      xx as the slot number of the grid (x coordinate)
      * box_size (so it knows how far in pixels it has to be drawn.
      Oke, I think I explained it, but, I am not sure if this was your question, I'll try helping you if I was not clear :)

    • @kayomn
      @kayomn 8 років тому

      +devin kelly "#" is the accessor symbol for a grid in a data structure. It allows you to manipulate the grid as if it were a plain array, by adding the # to inform the engine it's a grid you're editing. Grids are really just 2D arrays.

  • @Ragnark1
    @Ragnark1 8 років тому

    Did you go to BYU? You look familiar.

  • @Darkness2Maxrocko
    @Darkness2Maxrocko 8 років тому

    The remove item wont work... i have no idea why all the code is exactly the same .-. anyone else having this or is it just me

  • @TeddHUN
    @TeddHUN 8 років тому

    How i can save this inventory and load? :D

  • @RandomGameFun
    @RandomGameFun 7 років тому

    is there a download for this so i can see the code without watching this video?

  • @MishiyaeruGamer
    @MishiyaeruGamer 7 років тому

    I wanna know how to save a dsgrid using ds map :(

  • @LiamDoesProgramming
    @LiamDoesProgramming 9 років тому

    Hey Ben, I'm wondering if I could make the inventory interactive but on the GUI layer. I can't figure it out, I've checked out your GUI buttons video but that isn't working :/ anyway this is possible?

    • @ElectricDonkeyGML
      @ElectricDonkeyGML 9 років тому

      +LiamDoesProgramming I have changed a few bits of code to make it sorta do this. It can only be placed in the top left hand corner though atm. Here are the changes -
      x_to_gx - Replace inventory.x with view_xview[0]
      y_to_gy - Replace inventory.y with view_yview[0]
      inventory draw - (Swap to draw GUI)
      inventory draw GUI - Replace var tx = x+(xx*box_size); with var tx (xx*box_size);
      ((Do same with y, obviously changing the x to y))
      Hope this helps :)

    • @LiamDoesProgramming
      @LiamDoesProgramming 9 років тому

      +Electric Donkey thanks man! now time to make it more dynamic, I'm thinking about making a second view the size of the gui. That might work. Good programming! (idk lol)

    • @LiamDoesProgramming
      @LiamDoesProgramming 9 років тому

      +Electric Donkey I did this and it isn't working D:

    • @survivalgamer1275
      @survivalgamer1275 8 років тому

      +Electric Donkey I know it is half a year later, but thanks, it is working, now I need to figure out how to change it from the left top corner, but I think, I'll be able to :)

    • @survivalgamer1275
      @survivalgamer1275 8 років тому

      +Survival Gamer Oke, that was faily simple... just change:
      var tx = (xx*box_size); to: var tx = (xx*box_size + 32);
      (or what I did, change the 32 to a variable and change that in create event :)
      EDIT:
      and changing in x_to_gx:
      (xx - view_xview[0]) to (xx - view_xview[0] - obj_inventory.inv_left_dist)
      as inv_left_dist is my variable for the distance

  • @skylaryuen6863
    @skylaryuen6863 9 років тому

    Thank you~ Useful~

  • @kyaniteprocessing5816
    @kyaniteprocessing5816 9 років тому

    What language does this use, it looks lots like javascript to me with how it is written :P

    • @BEAlchemy
      @BEAlchemy 8 років тому +1

      +Kyanite Processing GML - GameMaker Language

  • @spritedungeon6648
    @spritedungeon6648 8 років тому

    This is crazeeeeyyy!!! xDDDDD THANKSS!!!

  • @tctrax
    @tctrax 8 років тому

    I could really use some help with some error messages that I have been receiving.
    If someone could PM me that would be amazing.

  • @aggeblue8136
    @aggeblue8136 9 років тому

    Does anyone know how i can remove a specific item? like when i use a key i want only exact that item to disapear from inventory

    • @ElectricDonkeyGML
      @ElectricDonkeyGML 9 років тому

      +agge blue That should be quite easy. Just use 2 for loops to loop through every single box and check each box for the item, if it finds that item, use the remove script to get rid of it. If you need any help doing this private message me.

    • @aggeblue8136
      @aggeblue8136 9 років тому

      Electric Donkey I'm not experienced in gml and not sure where to use the for loop, if you don't mind helping me out on this i'd appriciate!

    • @ElectricDonkeyGML
      @ElectricDonkeyGML 9 років тому

      +agge blue
      Hi, about the removing of a single item here is the code -
      Add an event for the key you want to press then add this -
      for(var xx = 0; xx < width; xx++) {
      for(var yy = 0; yy < height; yy++) {
      if(inventory.box[# xx, yy] = ((ITEM YOU WANT TO REMOVE)) {
      inventory_remove_item(xx, yy);
      }
      }
      }
      That should work, if not, just say :)

    • @aggeblue8136
      @aggeblue8136 9 років тому

      Electric Donkey Thankyou! :-) works perfect

    • @ElectricDonkeyGML
      @ElectricDonkeyGML 9 років тому

      agge blue​ anytime ;)

  • @carmesea0476
    @carmesea0476 7 років тому

    i love you somuch

  • @alentursunovic9607
    @alentursunovic9607 9 років тому

    Is
    This the first part to your rpg series ?

  • @matrixstudio9560
    @matrixstudio9560 8 років тому

    What is wrong with this code. There's like 10 people asking about it here? Why do so many people have this error?
    draw_sprite argument 2 incorrect type (5) expecting a Number (YYGI32)
    at gml_Object_obj_inventory_DrawEvent_1 (line 11) - draw_sprite(spr_items, box[# xx, yy], tx, ty);
    draw_sprite(spr_items, box[# xx, yy], tx, ty);
    if (count[# xx, yy] > 0)

    • @royhu9100
      @royhu9100 7 років тому +1

      It means that the type of "box[# xx, yy] " is not correct. It may because that the coordinate of ds_grid is out of range, for example the grid size is 5*10 but your code try to get the value at [6,1](x is out of range). Try to swap the coordinate to box[# yy,xx] (or change the previous code about xx and yy). And it may also caused by the wrong value type of the ds_grid value, make sure that the enum variables have a number value. I hope it can help you.

    • @SlawBunnies909
      @SlawBunnies909 7 років тому

      Ah, such a simple mistake anyone can make but I see what you mean now. Thanks for figuring it out.

  • @CapAmerica584
    @CapAmerica584 8 років тому

    lol I use GM 8.0 pro and I don't need accessors.

  • @aggeblue8136
    @aggeblue8136 9 років тому

    Hey Heartbeast first of all thankyou for this awesome tutorial
    AND i just wanted to ask
    how can i make it so i whenever i remove an item it gets to dropped under the player's x, y? Becaus right now it's abit shame that the item just disapears ? D:
    becaus if you need more inventory space to new items in ur game this could be useful
    sorry if this is too much i just have no idea how to impliment this
    For anyone that wants the inventory to follow with views. All you have to do is edit the inside the *x_to_gx* likethis: *if (xx < Inventory.view_xview[0]) return -1;*
    *return (yy - Inventory.view_yview[0]) div Inventory.box_size;* also remember to edit with *y_to_gy*
    Also could you expand this tutorial abit. I have some ideas to what could be inside the tutorial, maybe make it so whenever you reach a max item stack, like in minecraft 64 then it goes to the next slot. And if possible make it so you can drag the item like in diablo and drop it on the ground same with putting inside the inventory? Just some ideas

    • @ElectricDonkeyGML
      @ElectricDonkeyGML 9 років тому

      +agge blue I'm afraid this code for the x_to_gx doesn't work. However, I do know how to make items reach max items. Make these changes -
      inventory_add_item -
      In add one to the count add this - if(obj_inventory.count[# xx, yy] < 10) { ((Replace 10 with whatever item you want it to stop stacking at.))
      You can also add an } else { in and put this in - show_message("That slot is full!");
      obj_inventory.box[# global.box_x, global.box_y] = global.last_item
      obj_inventory.count[# global.box_x, global.box_y]++;
      return false;
      This will say that the slot is full and then place it back in the previous slot. (make sure to set global.box_x and y to the previous box somewhere. Also global.last_item should equal the last item, if you need help setting these just ask :)

    • @aggeblue8136
      @aggeblue8136 9 років тому

      Electric Donkey Thank you for the replay i'll try it out!. as for the x_to_gx i forgot to mention also change the *draw event' to *draw GUI event*

    • @ElectricDonkeyGML
      @ElectricDonkeyGML 9 років тому

      +agge blue Even if you move it to a draw GUI event it doesn't work (mainly because x and y don't exist in the GUI) But even if you change the x and y in the draw GUI event to integers it still doesn't work. P.S. I am working on the dropping of items, however I have changed my inventory_remove/add_item a lot so may not work perfectly with the original code.

    • @aggeblue8136
      @aggeblue8136 9 років тому

      Electric Donkey it works for me not sure what i did to make it work, but if you want i can upload my project with inventory? also mind helping me out on the dropping item system?:P

    • @ElectricDonkeyGML
      @ElectricDonkeyGML 9 років тому

      +agge blue If you could do that it would be massively appreciated! I can help you with the dropping of items although I fear it would be too complicated to explain over the comments, I can guide you through it in private chat/ messaging on youtube however.

  • @allen5576
    @allen5576 8 років тому

    PLEASE help
    this has been going on for a LONG time
    whenever i try to read my sign it senses the dash key so fast that it just makes it unreadable
    HELP!

    • @survivalgamer1275
      @survivalgamer1275 8 років тому

      +Allen LaneTM What do you mean by that? read your sign? what dign? this is an inventory tutorial..

    • @allen5576
      @allen5576 8 років тому

      Survival Gamer
      It is not referencing this video but another one by him

    • @survivalgamer1275
      @survivalgamer1275 8 років тому

      +Allen LaneTM which video?could you link it? I'll watch it, and I'll try to help you after, :)

    • @survivalgamer1275
      @survivalgamer1275 8 років тому

      +Allen LaneTM which video?could you link it? I'll watch it, and I'll try to help you after, :)

  • @justachipofftheiceberg6313
    @justachipofftheiceberg6313 5 років тому

    I need to find a inventory system that isn't a pain in the neck to implement new items

  • @theordinarygreen9634
    @theordinarygreen9634 8 років тому +2

    Citrix killed my family.

  • @Albertogonzalez-ml5wy
    @Albertogonzalez-ml5wy 8 років тому

    anybody know how to make an item NOT STACK?

    • @theabsurdityseries5597
      @theabsurdityseries5597 8 років тому

      i will tell you but if you can help me, My inventory object isnt drawing the rest of my objects and clicking with the mouse adds the item id first then the add 1
      put the code or files for the inventory object and the scripts the next ccomment
      i will tell you then

    • @theabsurdityseries5597
      @theabsurdityseries5597 8 років тому

      never mind fixedit!!
      I do know how to make items reach max items. Make these changes -
      inventory_add_item -
      In add one to the count add this - if(obj_inventory.count[# xx, yy] < 10) { ((Replace 10 with whatever item you want it to stop stacking at.))
      You can also add an } else { in and put this in - show_message("That slot is full!");
      obj_inventory.box[# global.box_x, global.box_y] = global.last_item
      obj_inventory.count[# global.box_x, global.box_y]++;
      return false;
      This will say that the slot is full and then place it back in the previous slot. (make sure to set global.box_x and y to the previous box somewhere. Also global.last_item should equal the last item, if you need help setting these just ask

    • @theabsurdityseries5597
      @theabsurdityseries5597 8 років тому

      OOOOOOOOOOOOORRRRRRRRRRRRR
      this is more simple
      This is his pickup script ( I think that is the most needed one with max items per slot)
      // Check for item in inventory
      for (var yy = 0; yy < obj_inventory.height; yy++) {
      for (var xx = 0; xx < obj_inventory.width; xx++) {
      if (obj_inventory.box[# xx, yy] == add_item) {
      obj_inventory.count[# xx, yy]++
      return true;
      }
      }
      }
      Simply add 1 line of code to make your work become real
      if obj_inventory.count[# xx, yy] < 8 {
      *So that would make: *
      // Check for item in inventory
      for (var yy = 0; yy < obj_inventory.height; yy++) {
      for (var xx = 0; xx < obj_inventory.width; xx++) {
      if (obj_inventory.box[# xx, yy] == add_item) {
      if obj_inventory.count[# xx, yy] < 8 {
      obj_inventory.count[# xx, yy]++
      return true;
      }
      }
      }
      }

  • @vaynlion2512
    @vaynlion2512 8 років тому

    So... how can you pick up items by walking over? ... i don't really get it..
    Here's my code (Step: obj_item_note1)
    var gx = x_to_gx(x);
    var gy = y_to_gy(y);
    var add_item = obj_item_note1;
    if (point_distance(x,y,obj_player.x,obj_player.y) < 64)
    {
    move_towards_point(obj_player.x,obj_player.y,4);
    if (point_distance(x,y,obj_player.x,obj_player.y) < 2)
    {
    instance_destroy();
    inventory_add_item(gx,gy,add_item);
    }
    }

    • @DevDeDeveloper
      @DevDeDeveloper 8 років тому

      +VAYNlion idk the answer but you can check gmc.yoyogames.com and ask there

    • @survivalgamer1275
      @survivalgamer1275 8 років тому

      +VAYNlion as far as I understand it should be:
      This is my version I simply just typed it to test your thing out:
      if distance_to_object(obj_player) < 32 {
      inventory_pickup_item(item.bomb);
      instance_destroy();
      }
      in your case it should be a note - so, add a note to the spr_items
      in the inventory object add (in create event) (execute code (enum))
      this should work fine
      enum item {
      none = 0,
      potion = 1,
      bomb = 2,
      sword = 3,
      note = 4
      }
      *Let's say you kept the sprites he used*
      if you didn't you need to adjust the "4" above to whatever subimage you used...

    • @patrykkozio155
      @patrykkozio155 8 років тому

      +Survival Gamer try that with place_meeting :D

    • @valiant_hero
      @valiant_hero 7 років тому

      add a colision event, and then make it add an item to the inventory, then deystroy the item (instance_destroy();)

  • @sagylel
    @sagylel 8 років тому

    But. How can i use crafting with that?

  • @xcreatorminigames6227
    @xcreatorminigames6227 5 років тому

    Very good content, but do not answer emails.

  • @redpilltruthbombs4717
    @redpilltruthbombs4717 6 років тому

    Still living in the attic huh?

  • @PizzaGamingTheReal
    @PizzaGamingTheReal 9 років тому

    This for what?

  • @tobi-b
    @tobi-b 7 років тому

    Just wasted 50 of my life

    • @uheartbeast
      @uheartbeast  7 років тому

      You should be more careful what you watch... ;)

    • @tobi-b
      @tobi-b 7 років тому

      HeartBeast sorry I was just salty because I wasted 40 min just to find out it didn't work for my game 😖

    • @uheartbeast
      @uheartbeast  7 років тому

      Oh darn. Yeah that sucks. This should work in about any game, though. Which type of game are you making?

    • @tobi-b
      @tobi-b 7 років тому

      HeartBeast it's an RPG. But in this is for games where u can see the whole map and not for games where u walk around with the cam following u. It's probably easy to change it, but I have never worked with a grid before

  • @ArthodGDT
    @ArthodGDT 8 років тому

    Heartbeast how do I make a limit to how many per inventory slot?

    • @survivalgamer1275
      @survivalgamer1275 8 років тому +1

      +Arthod GDT Hey, you probably don't mind, me helping you :)
      This is his pickup script ( I think that is the most needed one with max items per slot)
      // Check for item in inventory
      for (var yy = 0; yy < obj_inventory.height; yy++) {
      for (var xx = 0; xx < obj_inventory.width; xx++) {
      if (obj_inventory.box[# xx, yy] == add_item) {
      obj_inventory.count[# xx, yy]++
      return true;
      }
      }
      }
      *Simply add 1 line of code to make your work become real*
      if obj_inventory.count[# xx, yy] < 8 {
      *So that would make: *
      // Check for item in inventory
      for (var yy = 0; yy < obj_inventory.height; yy++) {
      for (var xx = 0; xx < obj_inventory.width; xx++) {
      if (obj_inventory.box[# xx, yy] == add_item) {
      if obj_inventory.count[# xx, yy] < 8 {
      obj_inventory.count[# xx, yy]++
      return true;
      }
      }
      }
      }

    • @ArthodGDT
      @ArthodGDT 8 років тому +1

      I got it figured out, but thanks alot for helping me though

    • @survivalgamer1275
      @survivalgamer1275 8 років тому +1

      +Arthod GDT Maybe you can help me out with an error, I am kinda stuck... so this is the error message I get when left clicking outside my inventory:
      FATAL ERROR in
      action number 1
      of Mouse Event for Glob Left Pressed
      for object obj_inventory:
      DoAdd :2: undefined value
      at gml_Object_obj_inventory_GlobalLeftButtonPressed_1 (line 12) - count[# gx, gy]++;
      In this file:
      /// Add a random item to the inventory
      var gx = x_to_gx(mouse_x);
      var gy = y_to_gy(mouse_y);
      var add_item = choose(item.potion, item.bomb, item.sword);
      if (count[# gx, gy] == 0) {
      inventory_add_item(gx, gy, add_item);
      } else {
      count[# gx, gy]++;
      }
      I searched up:
      DoAdd:: Execution Error
      Something has gone wrong when using the addition (+) expression.
      When he clicks next to it it just says, outside borders, what means that his script started (inventory_add_item) - after some testing I kinda know for sure it didn't start the script... And I don't know why
      (I named mine: obj_inventory instead of Inventory)

    • @ArthodGDT
      @ArthodGDT 8 років тому

      I am not sure. But try to make it: "Inventory.count(# gx, gy]++" instead of it being without: "Inventory."

    • @survivalgamer1275
      @survivalgamer1275 8 років тому

      +Arthod GDT I tried that, gave the same error message, I am going to see if I can find the solution, Thanks anyway!!!