GameMaker Studio 1 & 2 Inventory Tutorial

Поділитися
Вставка
  • Опубліковано 5 січ 2025

КОМЕНТАРІ • 356

  • @TheGrimmy
    @TheGrimmy 6 років тому +38

    I seriously appreciate this from the bottom of my heart... my game has 1066 items.... and I'm not that good at programming, so this would have taken me years to code without following your tutorial -_- You're a real life saver!

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

      Hey man I see that your starting aswell, Im starting up a company about game design and other stuff
      Id love it if you joined website dead-dream.com reply so you can give me your skype or whatever

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

      that sites IP address could not be found, apparently. I also don't use skype. I'm almost all the way done the project though, and the design is already ironed out. Thank you for taking the interest, though.

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

      :/ Im really just looking for Game Developers for Dead Dream, thanks for answering though

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

      No worries, and good luck finding a dedicated crew. Cheers!

  • @Opinada_podcast
    @Opinada_podcast 2 роки тому +3

    It's weird how this 1 hour tutorial took like a week for me to adapt and implement to my project. You've save me a lot to understand many code basics, thank you so much man!

  • @OminousGiggle
    @OminousGiggle 3 роки тому +4

    Had to do some serious revamping of a bunch of the code to get this to work how I need it to in my game, but all in all, very solid tutorial!
    Also one of the few good tutorials I came across that makes a list-style inventory as opposed to an inventory icon grid.
    Thank-you very much for the guide!
    Also ran into a couple bugs that repro in your downloadable project as well.
    1. If you scroll past the bottom of shown items (so scrolledAmount goes up) then move up a couple slots, then go back down, your inventory starts scrolling 1 item too early. This can be repeated until reaching a point where pressing down while at the top of your list will scroll the whole list of items. This is because we increase scrolled amount any time our itemSelected is larger than our inventoryEndAt, even if we're not on the last item of the list. And then we used that incorrect scrolledAmount to draw our item list.
    I changed my scrollDown to look like this (I also removed the clamp so I could set up a loop from the top of my list to the bottom, but that's in another section of code.)
    if (global.scrolledAmount + inventoryOnScreen ds_grid_height(myItems))
    {
    --global.scrolledAmount;
    }
    2. For anyone making a game that does not give the player the ability to move and obtain more items while their inventory is open (more rpg style), you still need to update the inventoryEndAt in the step event or you'll crash whenever you delete the last of an item.
    This can be fixed by copying our create code for the inventoryEndAt into the step event. (It'll live in both places, since we need it during the create event as well)

  • @michaelcapone175
    @michaelcapone175 4 роки тому +4

    Just finished this entire course and it's amazing. Far beyond anything else the web has to offer on inventories in GMS2...and it is three years old at that. Not only can this serve as someone's inventory for an RPG, platformer, or any game type really, it can easily be converted in to an equipment manager, a crafting system, and even a questing system. Everything Aaron showed us in this video can get that all done. Considering this was a free course published three years ago, I am sold on the fact that I want your advance course on your new website. I am making an action RPG, not a turn-based, but the inventory system and I am sure the dialogue system in that course will cover the price of admission. Can't wait. Thanks Aaron!!

  • @meganoob9281
    @meganoob9281 6 років тому +15

    This is the best inventory tutorial on the internet!

  • @avery3748
    @avery3748 4 роки тому +1

    You have explained this in such a way that simply no other UA-camr could. I really appreciate the help here, it was like... ds_grids and arrays have been really overwhelming for me, yet within the first ten minutes of this video, something clicked.

  • @tusk5651
    @tusk5651 2 роки тому +1

    dude that's incredible, you literally helped me so much!! the only issue i had was that at some point it gave me an error "assignment operator expected" and "malformed if statement". this was quickly fixed tho: just added curly brackets to the if statement and it worked perfectly:) adapting this to my project will take time, but your code is just absolutely wonderful!

  • @SGTIvan921
    @SGTIvan921 Рік тому +1

    Timestamps [Part 2]:
    23:47 Inventory GUI work starts here [Create an objInventoryGUI and have a sprite ready for use. He has one already.]
    24:11 Create event of the GUI [defining textBorder]
    24:52 myItems = playerInventory --> used for shortening the variable only
    25:00 Text colour, isEmpty variable, and if inventory is empty display the emptyMessage "You've no items."
    25:23 More global variables
    26:07 inventoryEndAt

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

    after many hours and days of completing udemy courses and learning so much, not 1 of them courses taught me and explained in a way you did! and your explanations are perfect, everything you said i completely understood and advanced my knowledge of GML in a huge way, i wish i had found this video sooner. i appreciate the time it has taken for you to do this video and respect to you for sharing it with the world, i cant comment on how appreciative i am about this tutorial. thank you!

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

      I'm glad to hear it :) My newest series is another inventory series as well, so that may interest you. I also have courses on my website, letslearnthistogether.com if you want more from me.

  • @katarinet.1323
    @katarinet.1323 7 років тому +2

    this is by far the most intuitive video tutorial I have found on the subject. It's clearly commented, you explain things thoroughly, you provide source code. Positively phenomenal. Views *do* make this a little tricky, but definitely not impossible. A little maneuvering and some prayers go a long way haha. Thank you so much!

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

      +Katarine T. I've got a video on compensating for views as well, so it's definitely possible.

    • @katarinet.1323
      @katarinet.1323 7 років тому +1

      Beyond Us Games I did figure it out! :D I actually watched your other video on views as well, which helped tremendously. Now I'm trying to adapt this video into a crafting system using another ds grid and scripts :S

  • @Pikashoes6
    @Pikashoes6 4 роки тому +1

    Great tutorial man, learned a lot about things I wasn't good at and applied it to how my game is set up. Very easy to understand, perfectly coherent for an intermediate programmer.

  • @Kptkrunch_
    @Kptkrunch_ 5 років тому +2

    This was a great inventory system and helped me understand how the data structures in GM2 work. I am definitely going to check out the rest of your stuff.

  • @pixelricebowl
    @pixelricebowl 5 років тому +1

    I've been working on a casual pixel art game and this inventory system has been very useful. Thanks so much for providing this informative and useful tutorial!

  • @VaLentino-ws1ef
    @VaLentino-ws1ef 9 місяців тому

    This video Is real Gold. A lot of thinks to learn here, thank you sooooo much!

  • @DAGJason
    @DAGJason 4 роки тому +1

    Well done and easy to follow even for a novice like me. I was able to be up and running with a few struggles and modifications in a weekend. Thanks much.

  • @DamnMascus
    @DamnMascus 5 років тому +2

    This is a VERY well done tutorial, I am still learning about data structures (lists, maps, and grids), and this really contributed to that, I appreciate it! Keep it up!!

  • @РусланСычев-й7и
    @РусланСычев-й7и 4 роки тому +2

    Спасибо за уникальное и актуальное видео.
    P.s from Russia with love

  • @LukePNG.
    @LukePNG. 3 роки тому +1

    hey, how would i check to see if an item is selected and then use it/ add it's Hp value?

  • @avery3748
    @avery3748 4 роки тому +1

    Just finished. Incredibly helpful! Though I do wish you would have gone over using the arrow keys to navigate "Use" and "Trash" instead of the mouse. But I will try to figure it out!

    • @mackenzieyang6380
      @mackenzieyang6380 2 роки тому

      have you figured out how to use it with keyboard?? i'd greatly appreciate it if you could share the code!

  • @NeZversSounds
    @NeZversSounds 6 років тому +2

    First time seeing ++ before i. I've learned a bit C++ never seen that. But as I found out:
    ++i will increment the value of i, and then return the incremented value.
    i++ will increment the value of i, but return the original value that i held before being incremented.
    For a for loop, either works. ++i seems more common.

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

      Yep. It’s an important distinction sometimes.

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

      Where would you need to know which one to use in which situation?

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

      In very particular situations that I’d wager you would never encounter, at least not in GMS.
      In C++, you can do a loop and possibly run into an issue if you use the ++ after when using pointers.

  • @seabassmcbigfat
    @seabassmcbigfat 6 років тому +12

    This is like
    actually some college level lecture shit.
    well done

  • @mistermario6432
    @mistermario6432 4 роки тому +2

    I followed step by step until min 23 where you test the pick up object.
    I've got this Compile Errors.
    obj_Inventory Event: Create at line 6: function"additem" expects 6 arguments, 0 provided
    obj_pickup Collision Event Width obj_player at line 2: function "additem" expexts 6 arguments, 5 provided.
    I have exactly same code than yours(showed) at this point but I don't get whats happening.
    Any help?

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

      It says you’re missing an argument. Check your commas, make sure you’ve got all 6 arguments in that script where they should be.

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

    Just a tip you can do sPlayer or oPlayer instead of doing Obj_player or spr_player

  • @minasriska2838
    @minasriska2838 4 роки тому +1

    To be honest this is the best tutorial that I've encountered on the internet so far!!! Great Job!!! But I do have a question tho. When I pick up items the inventory doesn't show any items from the ds_grid (I am sure tho that the items are added to the ds_grid). It is just empty. I started thinking that the InventoryEndAt is the problem (the math part in the floor function) or the math part of the for loop in the draw event of objInventoryGUI.

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  4 роки тому +1

      Hmm, if they’re being added to the grid, that’s the first part. If you know they’re there, then play around with the values you’ve got for displaying them and you’ll get it.

    • @minasriska2838
      @minasriska2838 4 роки тому +1

      @@LetsLearnThisTogether Ah, sorry for my delayed reply. Wish you a Happy New Year by the way :D . So I managed to find the solution and it was not the problem that I mentioned........really......after searching my project I found out that the items were not added in the ds_grid list and I was like w(゚Д゚)w . So I managed to target the problem and it was........curly brackets in the addItem script, at the case where the item is not in the inventory.....but again I really appreciate for replying!!!

  • @guyclegg
    @guyclegg 6 років тому +1

    How do we equip items? Also make another pannel that will display stats? Did the inventory parts completely. Thanks.

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

    Always enjoy your work, it's always impressive

  • @lloyd011721
    @lloyd011721 8 місяців тому +1

    awesome video. could this be done better now that its been 6 years and gms got updated ?

  • @Tennishero
    @Tennishero 7 років тому +5

    Good tutorial. You really try to thoroughly explain everything that you do, which is greatly appreciated.
    How can I change the color scheme of my code to match yours? The color scheme you use seems very intuitive.

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

      +LaminatedSun Thanks!
      Color options are in preferences, under general. Look up my tips video for that and other useful tidbits.

  • @vocenaoentendeunada2505
    @vocenaoentendeunada2505 3 роки тому

    Man! You explain very well! I understood every thing, but I had a problem, in the first time you try to spaw the menu in the screen "31:10", in my project it just don't spaw. I don't understando why, I watched the video again and compared my code with yours and they are the same. Do you have any sugestion?

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  3 роки тому

      Hmm. After you spawn it in, put a breakpoint and run it in debug mode. Does that instance get destroyed by something else? Is it visible? Is it on the wrong layer and behind something else?

  • @LukePNG.
    @LukePNG. 3 роки тому

    hello, I think that i may have missed the part where you said how to use an object?

  • @Chupie77777
    @Chupie77777 Рік тому

    Hey! This is pretty old, but I'm at around the 40 minute mark, and everything works great, but when I pick up a single item, the amount says "j" instead of "1." It works well when I pick up more than 1, but if I only have 1 item, it says "j" instead of "1".

    • @Chupie77777
      @Chupie77777 Рік тому

      Nevermind.... I think the font I'm using makes the 1 look like a j.... my bad lol

  • @SDWI-Woodworking
    @SDWI-Woodworking 6 років тому +2

    Yes, great video and well informative. It is also a well developed inventory system. Was wondering if you could tell me how to make 2 changes to it.
    1. Only shows items with a 0 amount.
    I have to dump my whole list of items/materials in it so I can use it for crafting. I only want to see what is owned in the inventory when I click the inventory button, but want to use the same ds_list to view everything available in my game. I was going to make another copy of the inventory system for crafting, although, with it being so memory intensive, wasn't sure if that was a good idea.
    2. Along with the scroll, is there a way to "click" on an item in the list?
    Thank you for giving us this great tool.

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

      1) You can definitely create more ds_lists if you desire. They use memory, but not too much, and as long as you delete them when you’re done, you won’t have any issues.
      I’m not sure exactly how to do what you’re asking, but I believe you’d have a check when displaying the items that if it has 1 or more in the amount, then just don’t show it.
      2) That becomes a little trickier. What you’d need to do is get the coordinates of the mouse and then compare it to the rectangle currently being drawn. If it’s within that rectangle, call the use script. If you want to be able to click on any of the items in there, you’ll have to figure out which item is at the top, then the x and y coordinates of each slot #.
      You can do it, but it’ll require a lot of experimentation.

    • @SDWI-Woodworking
      @SDWI-Woodworking 6 років тому

      Thank you for the reply. I guess if it were easy, everyone would do it. LOL. I do have another item to ask you about. I am using 3 of your inventory systems to do multiple things. 2 of them, when scrolling work fine. On the 3rd one the rectangle will sometimes bounce around. Sometimes it will scroll up/down item by item and other times it scrolls every 3rd or 4th item in the list. Any ideas what could be causing this? I triple checked the math that you said in your video would cause visual discrepancies and it is spot on. I do have to say that this is an amazing inventory system and I appreciate you using your expertise to teach it to me.

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

      I only know the answer of the 2nd question. You have to create a mouse right pressed global event. There, you have to paste this code:
      if(mouse_x>=textBorder && mouse_x

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

    so im leaving this comment halfway through the video 39:54 (which is AMAZING btw!) and everything is on screen and functioning like it should except my sprite/specific name of the obj and the x amount of items are all offset some how... im thinking it has something to do with my resolution...could you possibly tell me the res of the room in this project?(: I literally started messing with GMS2 yesterday (never coded in my life), so im definitely an amateur.. any help would be greatly appreciated!

    • @devintidball905
      @devintidball905 4 роки тому +1

      disregard, I just put in number values instead of TextBorder and I got it straightened out :)

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

    I followed your tutorial for room transitions but I am unable to open the menu in a separate room, even if I check the box that says persistent on objInventoryGUI and objInventory. How can I make it so that the menu will open in a separate room?
    I also had a separate question, which was asking how I could make the game pause while I have the menu open.

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

    FATAL ERROR in
    action number 1
    of Create Event
    for object obj_pickup:
    Push :: Execution Error - Variable Get -1.undefined(100021, -2147483648)
    at gml_Object_obj_pickup_CreateEvent_1 (line 2) - myItemName = undefined;
    thank you for this wonderful tutorial!
    i'm stuck at 18:45.
    i'm using gamemaker studio 1.4.
    undefined is not changing color when i type it in. i tried is_undefined, but that doesn't seem to work either.
    the error i get using is_undefined is "cannot use function/script name for a variable using 'is_undefined'.

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  5 років тому +1

      Undefined is a data type, is_undefined is a function, so you can't swap those two.
      If you're get an error then it means you're not assigning value to myItemName like it requires, so check that section out.
      You can also download my project and compare its code to yours.

    • @Yppopojoj
      @Yppopojoj 5 років тому +1

      @@LetsLearnThisTogether thank you very much. I got a prompt to update gamemaker and after the update "undefined" worked fine. You've been immensely helpful.

  • @Chupie77777
    @Chupie77777 Рік тому

    How would I impliment a controller in this? Everything works great with the controller, but when I scroll through the inventory, I press down once, and the inventory scrolls through the items really fast, so its hard to just scroll down 1 by 1

    • @Chupie77777
      @Chupie77777 Рік тому

      Figured it out! Got the idea from Heartbeast!
      If anyone wants to fix this issue, in the objInventoryGUI object, create an alarm[0]. In the step event of the objInventoryGUI (or wherever you are checking to see if you are pressing up or down on the controller/arrow keys), before you check any input, put "if alarm[0]

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

    Plz help me. My room uses physics and idk why but items do not detect collision.
    Its 100% connected with collision because i have used *on key pressed* and everything was ok but while using collision with player nothing happens.

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

      Dont use the black boxes to check anything, it just screws u over

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

    great tutorial. How do you change the predefined colors of your code inside GMS2?

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

      +LaminatedSun In preferences, general. You can look at my tips video for specifics.

  • @Chupie77777
    @Chupie77777 6 років тому +1

    I'm not sure if my other comment made it to this thread, so sorry if this is a duplicate comment, but I'm trying to draw my "Use" and "Trash" buttons in a draw GUI event, and its working like a charm, however, every time I open my inventory, it creates a SECOND set of buttons on the same x and y coordinates, and when I move my character around with the inventory open, the 1st set stays with the camera in the correct spots, but the second set stays underneath the inventory without following the camera. Any tips? I've been trying to figure it out for a few hours.

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

      Update: It creates the Button Object in a stagnant x and y position that I gave it, while it only draws the Button Sprite on top of the inventoryGUI, so in order for me to hover over anything and get the buttons to work, I have to hover over the "second" set of buttons (the button object) that is stuck at the stagnant x and y position. I guess I just need the button object to follow the inventory GUI instead of stay in the same position. I've already watched the GUI tutorial with GetViewX and GetViewY, but its still not working

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

      okay.... NOW, when I open my inventory, it draws 2 versions of the sprite, one whole inventory that follows the screen, and one that stays behind at the original x and y position. whaat is happening

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  6 років тому +1

      It sounds like you’ve got some drawing problems. I can’t say exactly what the issue is from just your info, but I’d encourage you to download my project and compare your code to it. See if you can find what’s wrong that way.

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

    Hi,
    I'm at 31:13 in your video and I've got to the part where I'm pressing I and something (just the blank bg for the inventory) is supposed to be showing up. I've got some display code in the console telling me it's being created, and it's being created where I tell it to, but I can't see it and it's not showing up in the workspace while the project is paused. Any ideas what I could be missing? I also tried drawing it on a layer instead of at a depth and that didn't seem to work either.

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

      Are you drawing it in the draw event specifically? It can't be done in any other event.

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

      @@LetsLearnThisTogether Thank you for the reply! At that point in the tutorial, there isn't a Draw event yet. obj_Inventory has a Create and Key press I Event, and obj_InventoryGUI has a Create event, and the only other objects are the player and objPickup. It's only objInventoryGUI that's showing up in the tutorial, there aren't any items or other sprites in it yet, but that's the bit that's not showing up for me. I did start from scratch instead of starting with your provided files, so maybe that's what's causing the problem.
      I watched ahead a bit and you do create a Draw event directly after this, but I don't want to move on until mine works. (tho maybe I should)

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

      Try moving on a bit, maybe clone your project and try in that one and see if you can get it fixed.
      If you use a draw_ anything function, besides draw_set, it must be done in a draw event. Odd I don't have one yet.

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

      @@LetsLearnThisTogether It is weird! I figured it was just magic.
      I've hit a breakthrough!(?) When I divide only the x value you provide by 2, the descriptive text shows up about 600 pixels down when I press i, and when I divide only the provided y value by 2, the whole thing displays about 600 pixels down, properly scrollable and all! Dividing both by 2 seems to have no additional effect. (The armor sprite and the box that's supposed to go behind the descriptive text aren't displaying for some reason but I'll cross that bridge when I come to it.
      This is super bizarre because we have the same room size (I ended up downloading your project file to reference), but, it's still progress, and I can probably tweak things into position from there.

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

      Well, it seems like if I divide things that rely on y offset by 2 and add 90 (????) they end up in roughly the right place imgur.com/a/LY3SjiV

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

    I know this is a old video but I followed it up to 40:00 word by word but when I open my inventory I can’t see the image? Please help

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

      I encourage you to download the finished project and compare it to yours to see what's different.

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

      Beyond Us Games I have been trying to but it won’t let me look at it when I go to open it I can’t find it

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

      Chances are it is because you are using the trial version of gamemaker. You can only open projects by others if you buy the 'full' version. There is a temporary license that is cheaper(40$ per year) that can be found on the YoYo games website.

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

    Wanted to add if you download the full system from your link and load it into the latest GMS2 (IDE v2.3.0.529 Runtime v2.3.0.401)
    The game does not compile and flags up Compile errors :
    Script: scrollDown at line 12 : Assignment operator expected
    Script: trashItem at line 30 : Assignment operator expected
    Script: scrollDown at line 11 : malformed if statement
    Script: trashItem at line 29 : malformed if statement

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

      Ah, yes. 2.3 doesn't like the ++ operator by itself. If you add the {} around the if statement where that it is, it would fix them all, I think.

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

      @@LetsLearnThisTogether i was playing for ages and found this worked, i dont know how correct it is :
      scrolledAmount = --scrolledAmount;
      itemSelected = --itemSelected;
      it worked a charm haha
      i will try the method you suggested :P thank you i will check your website out.

  • @fire_man3173
    @fire_man3173 4 роки тому +1

    Quick question, I used this system in a fan game of mine and was wondering if I could keep it in (with credits of course). In other words, may I use this in my game?

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  4 роки тому +1

      Of course! No attribution is required, but appreciated :)

    • @fire_man3173
      @fire_man3173 4 роки тому +1

      @@LetsLearnThisTogether Thank you for responding! Your work is outstanding!

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

    Great Video and series. Not sure if i'm doing something wrong but if i have two of the same items and i pick both of them up, they don't stack.

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

      Yeah, it sounds like something in your add script didn't get changed properly. Download the finish project and compare your script to mine. It's a tricky little detail to add the amount, instead of just replacing it.

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

    It's will be way easier if you will draw it at "Draw GUI" event instead of regular "Draw". If you do that, you'll be able to draw your GUI relatively to your camera, not the room.
    I'm not english-speaking person so i might write something wrong:)

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

      It can be easier to use the GUI, it’s true. But when doing so it also requires changing sprite sizes and adjusting the scale of what you’re drawing, which can also get complex.
      Whichever way works for you, do it.

  • @DrJurdenPeterbergsteinlerwitz
    @DrJurdenPeterbergsteinlerwitz 3 роки тому

    Hi - How would I target/delete a specific item in my inventory? For example: If Player wants to sell a specific item or if Player hands in a quest-item it will have to be deleted from inventory. Is this possible? Thanks for the video, it is really great (I'm a little late).

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  3 роки тому

      You can for sure. I’d create a script and pass in the name of that object. Then do a for loop through the inventory and when you find the item, move all items after it down 1 slot. That will resize the array and delete that item.

    • @DrJurdenPeterbergsteinlerwitz
      @DrJurdenPeterbergsteinlerwitz 3 роки тому

      @@LetsLearnThisTogether Yikes, I have no clue where to start. You got any example?
      Anyways, thanks for the fast answer. I'll have a look at it.

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  3 роки тому

      I think I cover it in my advanced course. But I don’t think I have a video about it. I’ll add it to my list.

    • @DrJurdenPeterbergsteinlerwitz
      @DrJurdenPeterbergsteinlerwitz 3 роки тому +1

      @@LetsLearnThisTogether Yea, that would be awesome. I'll check out your course too. Thanks for the replies!

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

    OMG! Thank you for this tutorial! The only question I have is how would you go about saving the information inside the ds_grid?

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

      +XenoFect Ah yes! I've got that code done, I just need to record those tutorials. I'll get on that.

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

    Haha okay I'm really sorry, but I am having a small issue. At least this one is directly related to the video. In the video at 58:00 where you put in a check to use the script that directly relates to the object that is being used, the script within the object is not being called upon. I get an error because the first script I have is being called upon instead of the script under myItemScript. What should I check through to see what I've done incorrectly?
    Edit: Would you like me to post the error/ my related codes?

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

      Yeah, go ahead and post the error, that is usually a big help.

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

      Alright here it is. Just so you know in relation to your video, object_use is your objButton and scr_menu is the first script under the tab. mpos is within scr_menu. I'm sure you can tell this and read the error far better than I can, but I just wanted to clarify in case it would help.
      ###################################################################################
      FATAL ERROR in
      action number 1
      of Step Event0
      for object object_use:
      Variable object_use.mpos(100002, -2147483648) not set before reading it.
      at gml_Script_scr_menu (line 5) - switch (mpos)
      ###################################################################################
      --------------------------------------------------------------------------------------------
      stack frame is
      gml_Script_scr_menu (line 5)
      called from - gml_Object_object_use_Step_0 (line 6) - script_execute(ds_grid_get(playerInv, 4, itemSelected));

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

      So normally when a variable isn't set before reading it, it's some sort of spelling error. Double check you've got mpos spelled correctly when you create it and call on it. If it's wrong in any way, you'll get this error.

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

      That's not the problem exactly, mpos is within scr_menu which it isn't supposed to be reading at all, and that is why it isn't set. The script it should be reading is actually called "useHandbook," however, it seems as if the line of code "script_execute(ds_grid_get(playerInv, 4, itemSelected));" is completely ignoring anything after script_execute and is defaulting to reading the first script under the script tab.

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

      Ohh. I believe I ran into that problem as well, and mentioned it in the video, but I'm blanking on the exact solution now. Have you finished my video yet?

  • @fireballdj1274
    @fireballdj1274 3 роки тому

    I’m experiencing an issue where I just can’t see the inventory show up in the game. I’ve checked the layers and the objInventory is on the highest one and is persistent etc. I basically transferred everything from the given project to my game expect player/other items/tile sets. Would this be because my room is significantly smaller than as shown at 320x180?

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  3 роки тому

      Run your game in the debugger and check the x and y of the objects. They may be outside of the room. Where you’re drawing things it may be drawing outside of the room, too. Those things happen pretty often.

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

    This is by far the best inventory system I have seen. I've ran into a problem though. I'm using 1.4 and when I press the trash button it deletes all of the inventory. Can't seem to find where i went wrong in the code.

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

      +Chris Porter Thanks. It sounds like either your key press is being repeated until nothing is left, or your script is deleting them all. You could check your brackets, that's probably what's wrong,.

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

      That's exactly what I thought. I've been looking in the "Left Pressed" action in the objButton and in the trash item script but I still can't find a problem:/

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

      +Chris Porter Send it my way, email the project to me at beyondusgames@gmail.com.

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

      I actually ended up figuring it out! I had coded the buttons a little differently and it was conflicting with the actual function of them so I changed them back to the alarm system that you put in place. Thank you for the awesome tutorial!!

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

    Good tutorial, by far the best i found! But the inventory does not move with the camera. It is always created at the bottom left corner of the room and if the camera is centered on the player and the player moves to the right side of a larger room then the inventory is out of the screen...
    Any idea how to improve the code to fix that?

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

      +DerTabulator Yeah, check out my videos on working with views. They address that issue exactly.

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

      use draw GUI.

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

    I am trying to create a shop that will take 10 dollar items out of my inventory and add 1 product item in return. I am using if ds_grid_value_exists to check if the player has any dollars in their inventory but I don't know how to 1) check to see if the player has 10 dollars or 2) if they do have 10 dollars, how do I remove them?

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

      Your ds grid is a container for data, and you can access it with the functions provided, or just like an array, with a # symbol.
      So if you’re checking the amount of money, you only need to know where it’s stored. PlayerInventory[# 0,0] might contain the money. That will return it. To alter it, just use it again but subtract from it.
      PlayerInventory[# 0,0] -= 10

  • @mauritzgyllenhak4401
    @mauritzgyllenhak4401 3 роки тому

    Any way of making the inventory follow along with a viewport?

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  3 роки тому

      Sure, just replace the x and y of where you’re drawing things at with that of the viewport. I’ve got a video on how to manage that on my channel.

    • @mauritzgyllenhak4401
      @mauritzgyllenhak4401 3 роки тому

      @@LetsLearnThisTogether was able to change the position of everything but for some reason the "clickable" part of the buttons "trash" and "use" are misaligned with their sprites. Any idea of what's causing this?

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  3 роки тому

      Do you mean the text inside the buttons? If so, check your h and v alignment, because when they get set once, it effects the entire project. You should set all those draw functions every time you draw text

    • @mauritzgyllenhak4401
      @mauritzgyllenhak4401 3 роки тому

      ​@@LetsLearnThisTogether No the text is aligned perfectly BUT when i use a viewport, the "highlight" and the function of the buttons "use" and "trash" dont work when i mouse over them. Rather the region of the screen (when I use a viewport) where i can click and where the highlight comes into effect stays inside the same place (in the room) as it does when i DO NOT use a viewport. I assume that the "mouse enter", "mouse leave" and "left pressed" events are coded for the object and not the sprites drawn in the gui but I do not know how to change these events to work with a viewport properly!

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  3 роки тому

      Yeah, those events are for the objects. So you can move the objects around as the viewport moves, or replicate them in your step event and manually check if the mouse enters a region and if it does when it’s clicked, activate the right code

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

    So i've got everything implemented compatible with views and keyboard controls for the scrolling, but what would be the best method to go about making it so that use and trash come up as a separate submenu when I press the keyboard action button over whatever item I have selected

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

      +ron jon Just call the scripts for those into those buttons. Should work about the same.

  • @lia-breefox6321
    @lia-breefox6321 Рік тому

    Is it normal that the link for the completed project doesn't work?

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

    Quick question, can it be possible to put "Empty" in grid 0,0?
    Now it will be Empty, Name, Amount...etc.
    So that you don't have to write
    newItemSpot = ds_grid_height(gridToAddto) - 1; when resizing?

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

    Hey i noticed that when i put the script for the item that I can only use its name (ex. heal_player and not heal_player() ). The thing is i would like to have different healing items with different strengths and they way it is right now i cant just have 1 script like : heal_player(20) to heal 20 hp for example, since i cant add the (20). Is there any solution to this problem?. Other than that this was an amazing guide, thank you very much for this video!

  • @Singerrapperwhoknows
    @Singerrapperwhoknows 6 років тому +1

    I am currently getting an issue where the collision between the player and the obj_pickup is not being triggered at all. Is it because my game, as well as my player, is using physics?

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

      That can be. Physics does change how the game checks things.

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

      have you fixed that? I have same problem

  • @hocs89
    @hocs89 7 років тому +4

    Awesome!! Thanks a lot!

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

    This was amazing! Thank you for your work! Small question. I have a small bug in my implementation and was wondering if you had any ideas. If i have a lot of items in my inventory and i scroll down so the screen scrolls lets say...4 times? then go up until the inventory scrolls up 1 then go down again, the inventory will start scrolling down with the difference between the 4 and the 1. It's not a big problem but ... its driving me nuts lol.

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

      I remember running into this problem, as I was creating the system. I think it had something to do with the scroll variable not getting set when going down.. Download my finished project and compare your code with mine. It's something small, but it drove me nuts, too.

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

      Thanks for the quick reply! Last night I went over your code with a fine tooth comb and couldn't find the difference. Alas...I will add it to my "not important" list and just silently let it erk me hahhaha. Thank you again :P

  • @chaoslight11
    @chaoslight11 6 років тому +1

    Thanks for making the video, it's gonna be a huge help in a game I'm making.
    Just one question though. Is there an easy way to make it have limited inventory space?

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

      Sure. You just have to create a variable like maxSize, and then whenever you run into an item, check it against the current size and if you've got too many items, don't pick it up.

    • @chaoslight11
      @chaoslight11 6 років тому +1

      Thanks for the quick reply! I got it implemented in game real quickly and now it's working like a charm

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

      I'm just gonna leave a reply here since I don't want to fill up the comment section with questions, I added an additional variable to the add_item script, calling it newItemDestroyScript, since I want to have a script happen whenever the items are destroyed to display some text, And I though, "Hey, all I should need to do is change the playerInventoryWidth to 6, copy and paste the code from the use item command, change it to 5 instead of 4, and it should work."
      Well turns out that in doing this, it causes the game to crash after throwing away a second item, or attempting to throw away an item after using an item. And I am not entirely sure why, was wondering if you could answer this. since *using* items works perfectly fine, but throwing them away with this code in front of it causes an (undefined not being a number) message to pop up.

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

      What's the error?

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

      ___________________________________________
      ############################################################################################
      FATAL ERROR in
      action number 2
      of Step Event0
      for object obj_inv_menu:
      (null) argument 1 incorrect type (undefined) expecting a Number (YYGI32)
      at � (line 49) - script_execute(ds_grid_get(myItems,5,itemSelected))
      ############################################################################################
      --------------------------------------------------------------------------------------------
      stack frame is
      gml_Object_obj_inv_menu_StepNormalEvent_2 (line 49)
      (BTW, this is being called from the same menu that houses the myItems variable)

  • @ciantaylor6348
    @ciantaylor6348 3 роки тому

    Everything is exactly as you posted, but I get this:
    ds_grid_height argument 1 incorrect type (undefined) expecting a Number (YYGI32)
    at gml_GlobalScript_additem (line 18) - for (i = 0; i < ds_grid_height(gridToAddTo); ++i)
    :(

    • @ciantaylor6348
      @ciantaylor6348 3 роки тому

      If anyone ever has a similar problem, it turns out my function wasn't being properly defined. The script worked when I added this at the start:
      function addItem(gridToAddTo, newItemName, newItemAmount, newItemDescription, newItemSprite, newItemScript) {
      }

    • @durszlak2551
      @durszlak2551 2 роки тому

      @@ciantaylor6348 thx bro Ive been trying to figure this out for 3 months, you really helped.😃

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

    Only getting " " in the debugger when I pick up an item. It properly increases the height and stuff but no item name/description. Do you have special debugger settings? Noticed that the global var was in the instances tab but for me it was in the variable tab for example.
    Edit: I do get "Undefined" for the object that I didn't add any creation code to.

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

      I haven't really changed the debugger around, I'm guessing GMS updates and have done that.
      As to that error, it's odd. I'm not really sure what to say, except you should download my project and compare it with yours.

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

    Help when I have more than 1 item and I finish removing all of one pickup it gets rid of everything in the inventory

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

    Hey friend. I was wondering... do you think it'll be too hard to draw 2 selectable vertical columns of items instead of one with your inventory method? If so, might you have any hint or clue you could share to achieve it?

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

      It would require a little bit of trickery, but I bet you could manage it.
      The first idea that comes to mind is having an if statement check either a certain number of items on the left or the length of displayed items matches an amount. If it does, then start displaying items with a different x, one column over.
      You'll then need to think of specific use cases, like if they're scrolling how do they move between? If they're using a mouse, how do you handle moving between two columns? But you could do it.

    • @FaramurDodecuai
      @FaramurDodecuai 6 років тому +1

      Holy shit.
      It'll be a tough ride for sure. I'll give it a try. Thank you.

  • @cthulhu_1
    @cthulhu_1 3 роки тому

    why? How the undefined ItemSprite returns your the first sprite? I get Error

    • @cthulhu_1
      @cthulhu_1 3 роки тому

      ############################################################################################
      ERROR in
      action number 1
      of Draw Event
      for object Obj_item_nuevo:
      I32 argument is undefined
      at gml_Object_Obj_item_nuevo_Draw_0 (line 3) - sprite_index=item_sprite;
      ############################################################################################
      gml_Object_Obj_item_nuevo_Draw_0 (line 3)

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

    Also, how can you make the GUI move with a camera following the player?

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

      Here's the link to how to do that for GMS 2: ua-cam.com/video/69dmqUeMgwY/v-deo.html
      And GMS 1: ua-cam.com/video/Ah0sfNTGfZc/v-deo.html

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

    Hello, really hope you are still active on this video. I am trying to implement the menu system with arrows (keyboard only). I managed to get the scroll up and down to work but not next step taking it to mouse enter and mouse leave. Instead I want to use space bar to select the item eg. "red berry" and then have the two options become available on the side. Where the button currently is, the... "Use" "Trash". Then I want to be able to go right and left to select what I want to do with the item and then press space again to do whatever that is (run the script - this part I can do just not getting the menu to work like that). Thank you immensely regardless.

    • @EskeReven
      @EskeReven Рік тому

      state machine, put the menu controls in one state, and the submenu controls in another .. then have it change upon actions

    • @Chupie77777
      @Chupie77777 Рік тому

      ​@@EskeReven could you please explain a little more how to do that? Im trying to do the same

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  Рік тому +1

      I have a video on state machines that might clear things up.
      What it comes down to is either a big block of if statements, or specific functions you call only in scenarios. Such as if you’re in the menu, only call the script menu() so the player can’t do anything unrelated to menu, such as moving.

    • @EskeReven
      @EskeReven Рік тому

      @@Chupie77777 look for tutorials on state machines, basically you are putting the controls for moving up and down in the menu in one state, and up and down in the submenu in another state .. they often use states to change controls when walking/swimming/hurt/dashing to get better control .. and if you learn state machine you can pretty much make combat systems like pokemon pretty easily .. but what is a state, it is just a changed variable, if state == "menu" use these controls else if state == "submenu" use these controls, but a switch statement is better for that, you can even make a fully function based one.

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

    I was wondering if you could help with drawing the GUI on a camera system instead of the bottom left corner of the room

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

      I might be able to. For the most part, if you're using draw GUI, just use coordinates based on the camera size, I believe, and it'll always be there.

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

      it is for the objInventoryGUI and I'm using what your using

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

      Beyond Us Games can you help me, please? when I use Draw GUI it show inventory correctly, but buttons work just when player at top left corner, how can I fix it?

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

      Hmm. Do the buttons stay in the correct spot all the time?
      If you’re using views at all, check out my tutorials on how to use them, and then implement that when you create the buttons so they’re always in the right spot.

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

      Beyond Us Games the buttons are drawn in the GUI correctly, but I can click it only when the player staying in the upper left corner of the room, because the real buttons don't move.

  • @augurofnyarlathotep5051
    @augurofnyarlathotep5051 6 років тому +1

    Wow... just wow... and thanks it was helpful

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

    anyone know how to get myItemName, myItemAmount and the others from what item in the inventory is selected

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

    Is there a way to check if there are any items in the inventory? I don't want the player to press the use button and have the game crash because it can't execute a script
    I tried modifying the script so that it was
    if (myText == "Use")
    {
    if (ds_grid_height(playerInventory) > 0)
    {
    script_execute(ds_grid_get(playerInventory, 4, itemSelected));
    trashItem();
    }

    }
    But that didn't seem to stop the game from crashing

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

      That seems like it should work, I don't know why it doesn't. Checking to see if it's empty before use and only trashing if it has something makes sense. You could try putting that height check inside of trashItem() and see if that worked there.

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

      The issue isn't with the trash button its with the use button, for some reason the height check doesn't register in the check, not entirely sure why

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

    Please help me I can't pick up item

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

    Would it be difficult to have the inventory appear in the bottom corner of a viewport or camera?

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

      +Kevin Koch It's not too difficult, but views do cause some issues. I'll be adding a video soon on using views and adapting for them.
      The code you'll want is something like: camera_get_view_x(view_get_camera(view_current)). That will give you the x position of the top left of the current view, no matter where it is. And then use the y function of that to get y.

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

      Thanks for the quick reply! It looks like it isn't just as easy as replacing the obj_inventory x, and y positions with the function you gave me, though I was expecting as much. If you or anyone is curious of what happened, the inventory display disappeared and the inventory description display would pop in at the bottom of the camera but, wouldn't follow the camera. I also tried mixing in the method for creating a following point score in gamemakerstudio2's "my first game tutorial' but, that didn't work either.

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

      +Kevin Koch Well, be sure and place the functions in the draw event, not just the create event. Even if you make it in the right spot, they have to be constantly updated if you're moving around, which means adding them in the draw or step event, too.

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

    This may be a stupid question, but what part of the video explains/ sets the font?

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

      +Evalina D Not sure which part. But you use a function draw_set_font and then pass in the font you want.

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

      Beyond Us Games ah okay thank you!

  • @shaylap908
    @shaylap908 3 роки тому

    hi i used this code for my game as i currently working on it i cant run my game because there are compile errors how d i fix this?

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  3 роки тому

      It depends on the compile errors. Which version of GMS are you using?

    • @shaylap908
      @shaylap908 3 роки тому

      @@LetsLearnThisTogether i’m in game maker studio 2.0 i forget the IDE but it’s the most recent version

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  3 роки тому

      What’s the compile errors you’re getting?

    • @shaylap908
      @shaylap908 3 роки тому

      @@LetsLearnThisTogether sorry this is very late but it says misinformed if statement and something got expected (i’m not looking right now) but i know the errors are in script trashItem and script scrollDown

  • @frankiejrey
    @frankiejrey 3 роки тому

    Are there any updates I should make to mine if I am using the latest GM. I keep getting this error:
    script_execute argument 1 incorrect type (undefined) expecting a Number (YYGI32)
    at gml_Object_obj_Button_Mouse_5 (line 4) - script_execute(ds_grid_get(playerInventory, 4, itemSelected));
    I think it's due to the script_execute function, and how I am pulling a script from a ds_grid. Any ideas?

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  3 роки тому +1

      No, I don’t think that’s it. It’s saying your sending in undefined instead of a number. So whatever is in your ds grid is undefined. It looks like your adding items to the grid isn’t working.

    • @frankiejrey
      @frankiejrey 3 роки тому

      @@LetsLearnThisTogether Could it be that I am using globvar and not global.variable?

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  3 роки тому +1

      It could be. I don’t think globvar is a thing anymore. Global.variable makes a variable accessible everywhere.
      But even then, I think it might still reside in where you’re adding items. Run your debugger after adding an item to check that it really got inserted.

    • @frankiejrey
      @frankiejrey 3 роки тому

      @@LetsLearnThisTogether Using the debugger, I found the problem. The script is being added to the list as "". How do we add the script to the item? I am currently using myItemSprite = script(); I am going to try to add it using quotes, could that be it?

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  3 роки тому +1

      I believe you need to leave the brackets () off. With the brackets, you’re calling that script immediately. Without them, you’re storing a reference to it that you can use later on.

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

    Sorry, one more question! I have multiple rooms in my game and I only want the object to appear once. However, when I leave the room and go back, it has reappeared. How can I keep it from reappearing?

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

      +Evalina D Mark that room as persistent. It's an option in the rooms tab.

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

      ohh that makes sense. I tried setting the object to persistent so I was heading in the right direction at least. thanks!

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

    Skip to 18:40 for the real action.

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

    Just wanna check before I spend 2 hours doing this: does it work on GameMaker Studio 1?

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

    Can i get some help?
    I am making a RPG game and i was trying to make a inventory. The first time i tried sprIthemBox wasn't showing up and neither were the buttons. i was using the same sprite and i went back and looked over the video up to that point around 3 times. I couldn't fix it so i decided to start over. when i started over i tried again and i used the same sprites but none of the sprites are showing up for the inventory. i tried to download the completed one in the description but when i try to open it up i cant find it anywhere. i have to trial so that might be why i cant open it but idk. i tried to look up how to open downloaded projects but i couldn't find any videos about it. if you could help me that would be great, but if not i can just wait till i buy a upgrade and then see if i can open your game and see what i did wrong.

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

      I don't know if the trial version is the problem, but I suppose it could be, as this project has a lot of sprites.
      If sprites aren't showing up, be sure you're drawing them in the draw event, and that the object you're drawing with is set to visible.

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

    My item sprites are showing up as a black box in my inventory??? Can i get some help please

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

      What Sprite are you assigning to them? You still need to tell each item what Sprite it is and then draw that correctly.

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

      Beyond Us Games Nevermind i fixed it, just didnt assign a sprite 👍

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

    Is it possible to follow this tutorial and create this inventory in game maker 8? I can't port my game over to studio 1 or 2.

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

      +Jack Hughes I've never used 8, I don't know what functions they have access to. If you have ds grids, you can probably follow along, yeah.

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

      Everything in the Inventory seems to work except for the "newItemName" I can only use numbers in name. If I try to use double quotes and write a name for an item this error appears:
      ERROR in
      action number 1
      of Collision Event with object obj_player
      for object obj_pickup:
      In script addItem:
      Error in code at line 12:
      if (ds_grid_get(gridToAddTo, 0, i) == newItemName) {
      ^
      at position 44: Cannot compare arguments.
      The only change I have had to make to the code due to GM8 was changing how the "myItem" variables are initialised. Due to undefined not existing in GM8. Any ideas for how to fix the problem. This is the best inventory tutorial ive seen and I really want to use it in my game.

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

      +Jack Hughes Hmm, never seen that error. But it seems that you're trying to compare things that aren't compatible. If you have the function string(), try to use that on line 12, putting newItemName inside of the function. It will make that variable a string, which is what you need.
      Or you may need to wrap ds_grid_get inside of string(), so that you for sure get a string back with it, instead of a real. It's called type casting, and the new GMS programs do it automatically.

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

      I managed to get everything in the inventory working, except that when i use an item, no matter what, all my items are discarded. Any ideas for how to fix?

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

      +Jack Hughes Sounds like your discard script is somehow getting called. I'd recommend putting a break point on your use item script (by pressing f9 on that line of code) and running the debugger. Then you can walk through each line of code after you use an item to see exactly why you're discarding items.

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

    Hey, friend, it's me again. Hopefully I'm not becoming a nuisanse, it's just that I discovered something minnor, yet, a bit confusing to look at, and was seeking your help.
    On my project and yours, if you get the cursor going down at the end of the displayed items, when you reach the end and go further down, the rows shift upwards to give the illusion of scrolling down, right? Everything is fine there, but if you scroll down 1 time, then go back up one slot with the cursor, and you try to go down again to the bottom item on the list, the page will scroll down again even if the cursor hasn't reached the last item displayed on the list.
    So if you scroll down the items one time, but you get the cursor at the top item displayed (and not scrolling back up), if you go down again, the items will scroll down even if the cursor is at the top of the items displayed and not the bottom; it might be a bit confusing when selecting items for the player.
    I was trying to fix it with the scrollAmount and itemsOnScreen vars but I just couldn't figure it out... would you mind giving it a little check, pretty please?

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  6 років тому +1

      Ah, I ran into that problem several times when making this project. I thought I had it figured out, but it appears not totally.
      I'll take a look at it when I get a chance. You may have to remind me with the question again, but you're not bothering me at all, don't worry

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

      Glad to hear that. Alright then, I'll come here tomorrow or past tomorrow at some point to remind you, thank you for helping me.

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

    ran into a bit of a problem. my sprites show up as they should when placed but when i pick them up only my first sprite is used.
    im using GM1.4

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

      how you deal with the creation of the custom function in GMS 1? i'm stuck in that point, and can find nothing in the google about it! I tried to use the way was show in the tutorial, but always GMS 1.4 don't recognize as custom functions.If anyone can help me, i will appreciate a lot.

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

      Custom functions? You mean scripts? I’m confused as to what’s not working for you. Can you be more specific?

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

      @@LetsLearnThisTogether it's kind of, um that part when you set the first script, and in the addItem function has some arguments like gridToAddTo and etc. But GMS 1.4 seems not to recognize this "custom" function when i need to call it. Sorry for my bad english and question, i'm new to GMS.

  • @ciantaylor6348
    @ciantaylor6348 3 роки тому +1

    Getting through it slowly, thanks for the great tutorial.
    But now I get this:
    global variable name 'playerInventory' index (100019) not set before reading it.
    at gml_GlobalScript_invendown (line 1) - itemSelected = clamp(++itemSelected, 0, ds_grid_height(playerInventory) -1);
    Why is it being such an *sshole? It is set. It's exactly like yours, but it just hates that id. I've used myItems, changing global var to globa.playerInventory, But the game simply wont run while this script exists

    • @ciantaylor6348
      @ciantaylor6348 3 роки тому

      Fixed. If someone gets the same issue, add a little to the up and down scripts:
      if instance_exists(objinventoryGUI) {
      itemSelected = clamp(++itemSelected, 0, ds_grid_height(myItems) -1);
      }

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

    Hey man! I am trying to do this... but the collision is being activated. Is it because I have physics? I tryed to toy with my code but no such luck. Also, how would I be able to fit the Inventory in the View? Also, would you have this code in a GameMaker 1.4 file? GameMaker Studio 2 refusec to work on my laptop. Anyway, Thanks man!

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

      +Nappa I'm a little confused as to what you mean. What collision? What exactly is happening and what isn't working?
      I don't have anything for GMS 1, although you can open the objects from GMS 2 with a notepad and then copy and paste the code into GMS 1.

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

      +Nappa What Collison? What are you referring to? Can you be more detailed? And I don't have anything for GMS 1, but you can download the project and open the objects in notepad and copy and paste the code into GMS 1.

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

      The collision with the player and obj_Hero_Parent. I am using physics for my game and I was wondering if that was the reason that they aren't even working. I even put a debug message in the collision event, to see if they they were even working, but the debug message weren't even working. And Ill check it out in notepad. Ill send you an email with my game link to see if you find anything that I am missing.

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

      Can confirm this works in GMS w/o physics. Try using a button press event to verify if the collision is the problem.

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

      Thank you!

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

    How would I give a specific item to a specific character and do nothing if I try to use the wrong item?

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

      +Tsubaki Hmm, can you be more specific? Is this an item like a potion that only works on character a? Or like equipment that only works on a a Warrior?

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

      I just need it to trigger an achievement, otherwise it doesn't do anything. its just like a "notebook" that has to be accepted by character A and no one else, while character B has to accept only a "book".

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

      +Tsubaki My guess is that the item code itself is what you would write that in. When the character uses the item, it checks who owns it and then gives out the achievement or does nothing.
      Now, how you tell who owns it becomes the problem. Each character should probably have their own inventory, or add another spot on the items to say who owns it when it's given to a character if you have just one mass inventory.

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

      Ew, okay, this sounds fun. So in the creation script I should put "myItemOwned = npc_3" or something to that nature, then use that to write an if/ else statement to work out what should happen when presented to the character?

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

      +Tsubaki I think you'd just check if the character ID/object index is equal to the one calling that script. If it's equal, do something, else do something else.
      When the script is called, whatever object called it is also passing all it's data into the script, so you can check things like the id of the caller.

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

    So when i trash an item it goes to 0 but doesnt destroy but after I press trash again it destroys please help

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

      +Chandler Serres Sounds like you've got a less than check somewhere instead of less than or equal to 0. Check in your script where your destroy it, and where you're displaying the item.

  • @DukeofBlasphemy
    @DukeofBlasphemy 6 років тому +1

    Amazing!

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

    Hey, after some hours dealing with my butthurtness I was actually able to convert this into a pause menu to display and use my objects; well close, to it, I left out some objects i don't need like the click buttons; however, I'm getting this error when consuming all the amount of items of an item:
    "draw_sprite argument 1 incorrect type (undefined) expecting a Number (YYGI32)
    at gml_Object_obj_inventario_pause_Draw_64 (line 16) - draw_sprite(ds_grid_get(myItems, j, i + scrolledAmount), 0, bbox_left + 28, itemTopStart + (i * 40) + 5);"
    And a little above of it says this:
    Grid 0, index out of bounds writing [0,1] - size is [5,1]
    Grid 0, index out of bounds writing [1,1] - size is [5,1]
    Grid 0, index out of bounds writing [3,1] - size is [5,1]
    If you've the time could you help me please? If you are willing to, please let me know if you need more details:
    I don't have the objInventoryClickable so the sort script is not being called anywhere. Is it involved on the accomodation of the grid's rows whenever an item is fully consumed?

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

      It looks like two things are occurring. You're trying to access data that the grid doesn't have, that's what the index out of bounds is saying.
      Secondly, one of the arguments for drawing the sprite is incorrect, probably the first one, but I can't tell from just this code.
      Try putting a break point on the draw sprite line, and look at each of the variables you've got in that function, and see what their values are, as that should resolve that sprite drawing error once you discover which argument you're passing in isn't actually a number.
      Once you've got that fixed, let me know what error you're getting next.

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

      Hey what's up, man, thanks for the replying, I appreciate it. So I wasn't able to figure it out with the debugger, every var showed a number. However, it seems I really needed this piece of code:
      if(ds_grid_get(myItems, 0, 0) != 0) {
      isEmpty = false;
      inventoryEndAt = ds_grid_height(myItems);
      if(ds_grid_height(myItems) >= floor((sprite_height - (textBorder * 3)) / 32))
      inventoryEndAt = floor((sprite_height - (textBorder * 3)) / 32);
      }
      //When removing last item from inventory, doesn't allow player to appear
      if(ds_grid_get(myItems, 0, 0) == 0) {
      isEmpty = true;
      inventoryEndAt = 0;
      }
      And it's working now, but now I have another problem. Whenever the inventory is emptied, I have a blank slot, if I use the "blank slot" it attempts to call the first script on my script lists.
      I also tried that in your project and happened maybe the same, well it threw and error I couldn'nt understand (I clicked the use button when the inventory was empty) Should I do some sort of check with isEmpty var?

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  6 років тому +1

      Hmm, I must have forgotten about that case.
      Yeah, have a case that checks for an empty slot and don't let it do anything. That should fix it.

    • @FaramurDodecuai
      @FaramurDodecuai 6 років тому +1

      Beyond Us Games It did fix it, thank you friend. You're truly the best, only your tutorials explain the things I really need to learn to develop my ideas. I owe you

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

    I'm back, miss me? Haha. Well, I watched the rest of the video close enough to make it uncomfortable and it didn't address the problem (I guess because you never assigned a script back to an item?). However, I looked at your individual videos and you did answer the same question with someone else on video 5. The problem is (relating to your solution on the previous question) that I have a valid script assigned to my item and it's still trying to pull from the first script under my resource tree. Any ideas? Thanks!

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

      Hmm, I thought I addressed it, but I can't remember the exact solution. Double check your project against my finished one. If you don't find, export your project and email it to me at beyondusgames@gmail.com, and I'll look it over.

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

      Will do, thanks!

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

      Ahahahaha I found it! It was simple and stupid and I'm terribly sorry for using your time, but thank you for your help. (For future reference for anyone with this problem) When calling the script in the creation code, turns out you can't put the 2 parentheses like you have to in normal code, which I was doing.

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

      Oh the mistakes we all make it.

  • @AndrewOBannon
    @AndrewOBannon 5 років тому +1

    awesome

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

    thank you for gamemaker video

  • @tctrax
    @tctrax 6 років тому +3

    i think i love you

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

    Great tutorial!
    Any advice you have on the following issue would be wonderful:
    I get a fatal error when my player object collides with my pickup object.
    global variable name 'playerInventory' index (100020) not set before reading it.
    at gml_Object_oPickup_Collision_1f7deb89_d2fa_4c90_84b7_d88718a30e40 (line 3) - addItem(playerInventory, myItemName, myItemAmount, myItemDescription, myItemSprite, myItemScript);
    EDIT: I placed the object inventory within the room and it seems to be picking up objects, but still a little funky, as the realtime debug won't let me change my global player inventory to ds grid. Maybe I'll figure this out if I keep messing with it...
    Thank you, Beyond Us Games!
    Peter

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

      +Peter Boice When it's not set it means it hasn't been given a value yet, so you may be trying to access it before it's actually created. So be sure the order of events is that you make the variable then access it.

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

      Thanks for the reply!

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

    followed code exactly, no inventory showed up

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

      Download the completed project (link is in the description) and see if you can run his. Not seeing too many other people having this issue so my guess is there is a typo somewhere in your code.

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

      @@michaelcapone175 i did

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

      Check your layer depths. It’s possible you’re drawing the inventory behind a layer of yours.

  • @jasonmiller7223
    @jasonmiller7223 3 роки тому

    will not run at all in latest version of studio 2/free

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  3 роки тому +1

      Good to know! I have a newer version which uses a GUI for the inventory that is updated to 2.3.

    • @jasonmiller7223
      @jasonmiller7223 3 роки тому

      @@LetsLearnThisTogether can you link to the version? Thanks

  • @kawanpld9969
    @kawanpld9969 9 місяців тому

    Still works? My game is crashing :(

    • @kawanpld9969
      @kawanpld9969 9 місяців тому

      Don't work anymore! I discovered on the forum that many things in the game maker have changed so this tutorial has unfortunately become outdated, maybe one day the creator will make a remake for us.

    • @acegambit7391
      @acegambit7391 7 місяців тому

      @@kawanpld9969 were you able to find the new way of creating an inventory with new updates?

    • @kawanpld9969
      @kawanpld9969 7 місяців тому

      @@acegambit7391 this code works, you just need fix the function because the gml functions have changed

    • @kawanpld9969
      @kawanpld9969 7 місяців тому

      I'm using this code in my rpg

    • @acegambit7391
      @acegambit7391 7 місяців тому

      @@kawanpld9969 are you using an old version of GM?

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

    Yo, just came to remind you of the question about the cursor doing weird stuff. I could somewhat manipulate it but I just did a freaking mess of code. So i'll await for you instead.

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

      Alright, so I couldn't replicate the problem in my finished project. Can you send me yours and I can look at it? I do remember this problem, but I also remember fixing it so it was no longer an issue. It had something to do with scroll amount, and an edge case (a unique problem requiring an if statement).
      You can email me at Beyondusgames@gmail.com

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

      What, are you sure D:? Did you fix it after or before uploading the project to youtube? Let me download your project again from the description and see if the problem is there, and let you know; if I'm hallucinating I'll send you my project tomorrow or tonight.

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

      Alright, I downloaded the "completed Project" on the description from Google Drive, I downloaded the .rar file (the one to the right), and the problem persists there. Maybe you uploaded an a little older version of your project, before implementing the fix? Or maybe we are not talking about the same issue.
      I open the inventory.
      Use the ↓ down arrow key to go all the way down on the items.
      When the "page scrolls up" I backtrack a single item using ↑ up arrow key.
      Then I press ↓ down arroy key again, and instead of making the cursor reach the bottom, the "page scrolls up" again.
      Please let me know if we are in the same page.

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

      K, got it. I was able to replicate the problem, and I found the solution.
      On the first if statement in the scrollDown script, add this line after the variable inventoryEndAt
      + scrolledAmount
      That will compensate for those scroll up and downs. It fixed it for me. Let me know if it does it for you.