INVENTORY & ITEM SYSTEM in Godot

Поділитися
Вставка
  • Опубліковано 18 чер 2020
  • In this video I will show you how to create an inventory and item system in Godot 3.2 with persistant player inventory using Godot resources and ResourceSaver.
    Third Person Character Controller Tutorial: • Third Person Character...
    FPS Character Controller Tutorial: • FPS Character Controll...
    Patreon: / codewithtom
    Discord: / discord
    Twitter: / codewithtom

КОМЕНТАРІ • 182

  • @ZPaul2Fresh8
    @ZPaul2Fresh8 Рік тому +15

    It is to be noted that the syntax to export variables is now '@export var'. I've found this while using version 4.0.2 and I'm unsure when this started but hopefully this helps others.

  • @kblin517
    @kblin517 4 роки тому +196

    deletes func _ready():
    *procedes to write func _ready():
    Is this the equivalent of opening up blender, deleting the default cube and instantly doing shift + a add cube?

    • @colossus779
      @colossus779 4 роки тому +13

      searching google in google

    • @codybeach2258
      @codybeach2258 4 роки тому +17

      If you delete the default method and create a new ready method you get more functionality

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

      @@codybeach2258 HAEHKAEHKAEKHAEKAHEAHE

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

      He could just select Template: None when creating script and it would just contain one line: extends Resource

    • @EidoEndy
      @EidoEndy 3 роки тому +7

      I think it's just a case of brain on autopilot. So yes.

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

    Absolutely great tutorial! Prolly the best I have ever watched. Super informative and detailed and still not too long. Thanks a lot dude, 5/5!

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

    I wish this video had more views because your way of handling an inventory system using resources is absolutely top notch :) SUBSCRIBED :D

  • @TheSubzeto
    @TheSubzeto 4 роки тому +17

    Your videos are inspiring. I followed the "Make an FPS" parts and it really helped me to further understand how Godot works. keep it up

    • @CodeWithTom
      @CodeWithTom  4 роки тому +5

      That's great to hear! Thanks!

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

    WOW! Such a nicely designed tutorial. This really helped me out. Thank youI

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

    this is a concept that has always intimidated me in gamedev, which has basically stopped me from making uh... any kind of complex game whatsoever lul. but you explained this very well, even for my tiny brain! it'll take more studying but i think i have a light grasp on it now. so thank you!

  • @redbu11
    @redbu11 2 роки тому +2

    finally, a proper inventory implementation guide, unlike what other youtubers propose

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

    By the way, your video is amazing! I would love to see a second part, in which you approach some untouched aspects, like using the UI to "spawn" the items.

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

    Great tutorial! Please more like this! Good programming practices

  • @t6_archives
    @t6_archives 4 роки тому +12

    Scare Daddy. We miss you, glad to see you're still uploading!

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

      T6! How you doing? Miss you guys too. Drop me a DM on Twitter 😁

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

    great video. easy to follow and very complete! I hope I'll be able to use this in a game soon.

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

    awesome vid Mr Tom, great!!

  • @Eternic_
    @Eternic_ Рік тому +4

    this might just be the best inventory tutorial i've seen so far. i love how clean your code is and on top of that you explain complex systems in a way that makes it easy to follow.
    do you consider making more videos about this topic? there are so many things still left untouched that i would love to see your approach on. for example making the inventory visuals, drag and drop (by clicking, not just dragging), splitting stacks, dropping items, equipping or consuming items and so on
    in any case that's an easy sub for me and i hope to see more of you in the future!

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

    Amazing the resource trick was very good. I am going to take this idea and going to expand onto it :D

  • @sabinamariteslanada9748
    @sabinamariteslanada9748 4 роки тому +9

    Can you make a video on how to save and load items using this inventory system of yours

  • @jordanmason4024
    @jordanmason4024 3 роки тому +14

    I would love to see a tutorial on how to make an actual useable item with effects!

  • @chrisvogel.8370
    @chrisvogel.8370 2 роки тому

    Excellent Tutorial!

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

    Keep making these videos Tom they are Oh so good

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

    Holy sheet this is a great tutorial.
    It really is great for teaching you the gd script API and how it works.

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

    Awesome video Tom. Just curious. How do you set the texture inside the InventoryGrid? Perhaps it will be explained in the next tutorial video =)

  • @danielchettiar4393
    @danielchettiar4393 3 роки тому +3

    Hey thanks for this amazing tutorial , beginners like me get to learn a lot about the game engine this way.
    Although I was wondering : *How do you reset the items in the inventory to a constant value when you load the game?*. :)

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

    really good video bro

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

    Thx big for your work!!!

  • @1luckyjo
    @1luckyjo 4 роки тому

    🤘 love you videos xx

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

    Solid tut

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

    I did not understand a f*cking thing in this video but my inventory system works so thanks :)

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

    This works great! But where would i add custom code? Like what effect the Item would have if you right click with it or so.

  • @dani.ochouno
    @dani.ochouno 4 роки тому

    Awesome! Thanks

  • @jaruizm1
    @jaruizm1 4 роки тому +6

    I want to thank you for all your awesome tuts. I follow the top-down tut and I create a fun Combat-like tank game but I want to ask you if I can open source the game because I'm base the game in your code. Thank you.
    PS: sorry for my english

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

      Thank you for your kind words. You absolutely can and I'd love it if you'd share your creation on our Discord 😁👍

  • @paolocrivello3646
    @paolocrivello3646 3 роки тому +5

    I don't think the database approach would scale performance wise if you have more than a thousand items. Loading upfront all the items resource would require a lot of memory ( if you account the mesh and the textures). Same thing applied for the get item function, worstt case scenario would check the whole database to return an item.
    If you're going to manage a lot of items you don't really need to load the whole db upfront. I managed to make it fast by searching the item by it's resource name, and by checking if the resource exists

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

    Another doubt just appeared as I was near the end of the video.
    At 47:43, you create the Magic Orbs, what would be the best way to make it so as each Magic Orb has some unique stats? For example if I have a sword (non stackable), and it has a durability counter, what's the best way to store that between dropped/equipped/saved states?

  • @cmds.learning7426
    @cmds.learning7426 4 роки тому

    cool work

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

    Hey Tom, I am having an issue with the items displaying in the inventory. I have it set to add 3 Oak Logs, and instead of adding a stack of 3 Oak Logs, it adds 3 stacks of x1 Oak Logs. I tried messing with the export var and even the max_stack_size check in the Inventory script but nothing seems to fix it?

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

    Hi. Great video. How can i equip or use items that i collect?

  • @sarfrazkhanabdullaleghari2044
    @sarfrazkhanabdullaleghari2044 3 роки тому +11

    I have a question. How do you subtract a quantity or an item from the inventory when you are done (let's say) using the item or removing it in-game?

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

    well thanks for the video. now i have to figure out how to remove items xD this will be a hassle

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

      if anyone has expanded on this system i would appreciate it if you write me a message :D

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

      @@fruitdudetv Well, I've managed to remove items on it but I'm still figuring out how to equip or use the items. It's simple just create a new function in the Inventory.gd with _items.remove(index). Also, don't forget to emit signal inventory_changed.

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

    A very nice tutorial! Only thing i dont understand is why the _items in the Inventory Resource is an export variable.
    Because when you make the MagickOrb you use the exported vars to configure the MagickOrb, but with the Inventory you dont use the _items to configure anything. And you use the functions to manipulate the _items internally. Am I mising something here? Or is it an Export because it otherwise dont get saved on the disk?

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

    How would this work if you have weapon items in your game? Like a sword that is an area2d and swings around?

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

    Hi! This tutorial was super helpful and I learned a lot. I was curious how I would go about using textures rather than text so that I can have a visual inventory. I think I just need to reference the texture rather than have a string for the item name but I'm not entirely sure how to do that since each item has a different texture. Would I use the resource so it loads a general texture?

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

      You've probably gotten a solution worked out by now, one possible option would be to save an image somewhere in "assets/", and export a Texture from the ResourceItem script. In each concrete implementation of a ResourceItem, you can set that Texture in the inspector.
      Then instead of just adding a Label to the UI, you could also create a TextureRect, similarly to how he creates a Label in the video. You'll set the TextureRect.texture property to point to the Texture that is exported by your concrete ResourceItem (Pickaxe.texture, for example).
      Lastly you'll add it to the GridContainer.
      You'll probably want to combine the Label and TextureRect into a single UI node, which inherits from Control (or one of it's subclasses), so that they get added together as a single item in the GridContainer, instead of as two separate items.
      Hope this is helpful, if you haven't already found a solution.

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

    I have a question. At around 28:01, you create new_item as a dictionary. Is there a reason to not create a InventoryItem class (from Resrouce) to keep this data instead of a Dict?
    This way we would be able to have the static typing advantage. Is there a reason to not create it as a class?

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

    just finished the last one ........i was wondering if you can tackle a leveling up and power up system every game has those also

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

    Hello. How can you implement a method to remove an item from inventory?

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

    Thank you tom

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

      You are very welcome

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

      @@CodeWithTom Do you mind doing some UI tutorial in godot sometime?

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

    hi, since the folder structure doesnt exist after export do we know how to create a system like this which respects the conversion of the gamefiles?

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

    Amazing tutorials. Works splendidly. But i want to expand it a little and use other variables / sprites / meshes :D. Any pointers where i should start? My guess is change somehow get item in item_database script and then add item function in invventory script. I don't want exact solution or tutorial, but just tell me if i am thinking right :D

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

    I enjoyed it. I don't think a persistent inventory is a good idea, but I understand you were just showing people some methods to do something like this.

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

      Hi Justin, glad you enjoyed it. Can I ask why you say that you don't think a persistent inventory is a good idea?

    • @1986DarkStalker
      @1986DarkStalker 2 роки тому

      We are still waiting, Justin. Tell us please.

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

      @@1986DarkStalker Create a 2nd world and you'll see why. I followed this tutorial to design my inventory but it quickly became a nightmare during changing scenes. This doesn't work even if you change the scene to itself. So I shifted to a "create when you need it" approach.

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

    Great tutorial, but how can we access item values and functions, to use a health potion, for example? ^^

  • @Joe-yv6zj
    @Joe-yv6zj 2 роки тому

    Pls can u explain this part of the code " inventory_item.item_reference.name " in the player inventory Resource script , cause I have gone through godot doc to find such functions or methods so to understand what it does , the return value , and the type it extends

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

    How could we implement this code to have enemies drop gear when killed? I love the video man, best item system video tutorial for godot engine.

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

    Would this way of using resources as items be expandable upto 100’s of items in a game?? (Performance wise and in general)

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

    how can i remove items from the inventory?

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

    how to work in an incremental item_id when creating new item
    sending int over network is more desireable

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

    Hey @Code with Tom I'm not seeing the name of the items im picking up on the panel, not sure why

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

      did u fix it? got the same problem

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

    Thanks for the tutorial, but I'm getting this error when I try to play my project:
    E 0:00:01.159 emit_signal: Error calling method from signal 'player_initialised': 'GridContainer(InventoryGrid.gd)::on_player_initialised': Method not found..
    core/object.cpp:1228 @ emit_signal()
    GameManager.gd:17 @ initialise_player()
    GameManager.gd:9 @ _process()
    Not sure what the problem is, any ideas? Code at the noted lines seems correct.

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

    i get the error message "Directory" not declared in the current scope? Any sugestions?

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

    I've been building my own inventory/ interactabale object system and it functions using a basic node structure (sprite, area2D, etc), and built-in scripts which I'm planning on extending for each unique item. Can anyone help me extrapolate whether I'll run into any limitations with that system as opposed to this one which is based around resources?
    Saving is something I need to consider, I haven't gotten around to learning that part, or resources in general. But from this tutorial I changed my Inventory (which is an autoload) to extend the Resource type, so I should be able to save that with a bit of added functionality?
    One of the only other "advantages" I can see to the resource method, is that you have less in your scene tree, and store objects in the file system, which might be preferable subjectively?
    would appreciate any thoughts

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

      great video btw, even if i'm still figuring it out, I can tell its an absolute gold mine.

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

    How would i access the item type in the script?

  • @Cherry-zg7el
    @Cherry-zg7el 3 роки тому

    I don't know why the line of code at 15:22 gives me a "The getter function isn't defined."
    Where did I go wrong?

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

    Thx

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

    Hey, I have a problem with the get_item(item_name) function in the ItemDatabase. It gives me an error at the if i.name == item_name "Invalid get index 'name' (on base: 'null instance')". I don't really understand the error (since I'm pretty new to Godot), can somebody help me?
    UPDATE: Problem solved. It apparently appended the items from a wrong folder or smth. I just reassigned the folder and it worked. I don't know what the problem actually was.

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

    Is there any plans to make a Godot 4 version of this tutorial? I am stuck with converting this line into the new format: export var _items = Array() setget set_items, get_items. So far I have this: @export var _items: Array but don't know how to get the setget part working.

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

      I think this would work: @export var _items : Array : set = set_items, get = get_items

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

      @@fisher2470 almost, it's @export var _items = Array(): set = set_items, get = get_items

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

      almost finished the godot 4 version

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

    Amazing work! However, I've follow all your tutorial but when I'm launching my UI scene, nothing appear on the screen (no error in the code, just no visual result). Do you know how to resolve this issue ?
    Sorry for the question as you are already giving us a great inventory system, but I don't find where is the issue.
    thanks a lot!

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

      Hi Thomas, do you have your UI as a separate scene? Can you make sure when you run your game that you have the correct scene set as the launch scene in project settings.

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

      @@CodeWithTom Hey thanks for your reply ! Actually I checked the debugger one more time and I simply mistook to give the proper path to my player node. I'm working on fixing that

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

    hey I really like your inventory system, I was so free to add it to my project but I have one issue and I don't know how to fix it. Can you make that the text won't delete every node in the grid? Maybe I'm just stupid but I don't want to have Potion x2 but a texture of the potion in a texture rect inside the grid container.

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

      hi do you find a solution? if so could you give it to me

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

      @@Karmo77 ua-cam.com/video/FHYb63ppHmk/v-deo.html

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

    Hi, this probably won't be seen, but I have an issue. I've followed the tutorial up to 43:00, but when I play the scene, none the label simply does not come up. I have a different name for both the player and the item. Idk what's gone wrong.

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

      Problem fixed. Simply a typo in my code. Really check your scripts, peeps!

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

    why is it when i make a new array in the inventory, it copies all the items in the _items array?

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

    Finally did it, WITH NO WARNINGS😩

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

      what were the problems ? mine keeps crashing at the moment

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

      @@juiceman7649 I don't even know. I rewatched multiple times and I gave up for like 3months. Gave it another shot and retyped everything again and it worked. I guess I missed something but I truly couldn't tell you :(

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

      @@2tired2sleep2 Yeh I've done that with a few tutorials usually I'll just re read over it a bunch till I understand as much as a I can and see if I can find anything that didn't make it work but otherwise sometimes you do just have to type it all out again

    • @2tired2sleep2
      @2tired2sleep2 3 роки тому

      @@juiceman7649 yup. This time I guess I was extra careful. If you want I can send my project and you can disect what I wrote

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

      @@2tired2sleep2 Should be alright for now gonna give it a look over again in the future I feel like it's throttling my laptop to hard trying to process the inventory that it can't even throw an error because it's too much for it to compile, I am running it on a pretty average - low spec laptop once I upgrade it'll hopefully just throw an error but i'll look over it again before then, cheers anyway really appreciate it, just gonna work on some more animation battle mechanics for my game in the mean time and dialogue

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

    Okay, so I went by your video, but for some reason in the "Player.gd" script it throws out an error " Attempt to call function 'new' in base 'null instance' on a null instance." (video time 30:21)

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

      I have the same error did you figure it out?

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

      @@Kaptinkumar Sadly I didn't. I moved on to coding discord bots, from time to time I go back to godot, but most of the time I make maps and stuff like that.

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

    hi , thanks for this , now
    how to have slots and have one item per slot

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

    Question, wouldnt Dictionary be better for item database instead of array? Array works well when you dont have lot of items, but i belive Dictionary is quicker with lots of them, or im wrong?

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

      Hey Nero. Both are perfectly valid options. Arrays are easier to use when you want an inventory with a defined amount of slots and you want to put items in a specific item slot. For example with an array you could easily put an item in the 9th slot by assigning it to inventory [8] (since arrays in Godot start at index 0).
      With regards to speed and performance. I doubt you would ever encounter an inventory large enough to see any meaningful difference in performance, unless you had thousands of inventory items.

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

      @@CodeWithTom i understand using array for players Inventory, im talking about part at 13:07 where you setup Item database and using For Loop, to get Item script variable by name
      instead of:
      items.append(load(...))
      do something like:
      var item = load(...)
      items[item.name] = item
      then
      get_item(item_name):
      return items[item_name]

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

      @@neronim1141 oh apologies. Yes this would potentially be a better solution for the item database for sure 😁

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

    Following this tutorial, followed everything to a tee and yet when I run it says "Invalid get index 'inventory' (on base: Spatial) Version 3.5.1

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

    Hello, thanks for tutorial but I have error that saying that it can't find player node 32:35

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

      same here

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

      @@ksiomix5062 i am also getting that error :(

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

      Oh already fixed it, what i did wrong was that i used /root/world/player but in my world I also have a ysort and my player is a child of the ysort so it should be /root/world/ysort/player

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

      deuwe im fixed that 1 week ago but i forget to swy

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

    SOLVED BEFORE I POSTED, SOLUTION AT END
    let's say i didn't want to save the inventory data in a separate file when it is changed (i'll save it elsewhere). how would you get the UI to update after changing scenes? the GameManager initializes the player once. i have the player.inventory reference passed through via a singleton script. i then reinitialize the player (via its own function) for the GameManager, except instead of loading the inventory from the file, i load it from my previous reference. all this works fine.
    in your initialise_player function in the GameManager, you emit a signal that is listened to by the UI, which connects player.inventory to the UI's _on_player_inventory_changed function to update the display. my problem is that this signal does not appear to be re-emitted when i re-initialize the player, therefore, when i change scenes and reinstantiate the player, nothing i do will make the label in the UI show up. nothing except for manually calling the GameManager's reinitialize function with a hard-coded keystroke - which, again, connects the player.inventory's "inventory_changed" signal to the UI's "_on_player_inventory_changed" function. is it "connecting" late?
    SOLUTION: fixed the issue by moving the UI's player_initialization connection from _ready() to _init().

  • @54m0h7
    @54m0h7 3 роки тому +7

    Edit: Solved it, see edit below. Thanks!
    Mine was saying it couldn't find the inventory.tres file. I created a new resource named that and copied it into my user data, but it's still saying "Invalid Call. nonexistent function 'get_items' in base 'Resource' ". It's highlighting line 23 in the GameManager, the line that says "player.inventory.set_items(existing_inventory.get_items())", so I don't think I created the inventory.tres file correctly, or something. Do you have a solution?
    Edit: Ok, so I copied the ResourceSaver.save(user://inventory.tres") part just above the If statement so it would create a correctly parsed file. It was still giving me the get_items error. I just copied the "get_items" text from the func and pasted it over it and then it suddenly worked. It's like there was a hidden character or something goofy going on there. I'll leave this comment here in case anyone else has this issue. Thanks for the tutorial!

  • @bity-bite
    @bity-bite 4 роки тому

    Can you fix sliding from slopes?

  • @4steroid
    @4steroid 10 місяців тому

    Can anyone help me to make a remove_item function for the inventory? I want to make a shop, so I need to remove items when the player sells them. I'm having trouble reverse engineering the add_item function.

    • @CodeWithTom
      @CodeWithTom  10 місяців тому

      My upcoming FPS series will have a section for inventory management.

    • @shonen991
      @shonen991 20 днів тому

      @@CodeWithTom as far as I can tell, something that never came out. Please. How to remove_item?

  • @Zen-rw2fz
    @Zen-rw2fz 3 роки тому +2

    Any reason why you would prefer this over just creating a dictionary for all items in a standard autoload alongside an inventory array?

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

    Broh this is a great video in general but you should use a dictionary instead of an array for constant time access to those inventory items instead of having to search that array.

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

    FYI, "if it's not a directory, it's definitely a file" is not true on anything other than windows (or even WSL).

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

    At the end,when you pick up the orb the First stack goes 1,2,3 and the second one goes from 1 to 3 whitout taking the ladt orb (i didn't see all the video lol)

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

      I picked up both orbs at the same time because they were close together and had a large collision sphere 😁

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

      @@CodeWithTom Oh,ok 👍

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

    My inventory is now many stacked and unstacked items which don't go away even after I close the game then run it again. Maybe I missed something.

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

      oh i deleted inventory.tres to clear it and it just made a new one upon running

  • @GrimOwlForth
    @GrimOwlForth 9 місяців тому +1

    For those using Godot 4.1 or later, there are a lot of issues you'll run into with the code in this video.

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

      almost finished my code on godot 4 with the changes needed

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

    my label is empty and I don't know what I have done wrong. Where are the "typical beginner mistakes"?
    Ps: I added the control nodes to the player because I wanted the inventory to move with the player

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

      did you fix it? got the same problem

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

    For some reason when i click play, now it dosnt even load up the game or screen

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

      Hi, any error messages?

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

      @@CodeWithTom for some reason there isnt any error messages it just wont load up.

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

      @F - BEATS ye same

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

      Same here also has anyone found a solution?

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

      @@codeziefer9250 I had the same problem and got it working by checking the indentation on line 15 in ItemDatabase.gd (the one that goes "filename = directory.get_next()"). This line needs to be outside the previous "if" condition. Tom has it right in his code at 12:00, so just check if you have the same indentation level as him. Hope it helps!

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

    initialise_player() i have wrote Var Player and Var player_initialised() Yet it says I have not declared initialise_player() in the current class even though I have, I am comparing my script and I see no difference, you also should explain a bit more instead of just typing, help

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

      I have the same issue!

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

      @@2tired2sleep2 Ahh im so confused! I lost all motivation for my project now :( Ill keep looking for tutorials and reply if I find a working one. hopefully it helps.

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

      @@EllisTheMenic3 I feel it, I couldn't figure out inventory for the longest. I watch a few tuts and now I have a botched up script that finally works (half the time). Keep trying bro, watch EVERY VID, read EVERY DOC in the official godot doca

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

      @@2tired2sleep2 Thanks! GG for staying motivated and making it! I have high hopes for you game!

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

    Is this tutorial on github?

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

    Is the code on your github tom?

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

      Hey I'm afraid this one isn't right now, but I'll look to get it up asap!

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

    I have a few errors, and i dont know how to fix them, here they are:
    E 0:00:03.072 load_interactive: Cannot open file 'user://inventory.tres'.
    Condition "err != OK" is true. Returned: Ref()
    scene/resources/resource_format_text.cpp:1228 @ load_interactive()
    GameManager.gd:20 @ initialize_player()
    GameManager.gd:9 @ _process()
    E 0:00:03.171 _load: Failed loading resource: user://inventory.tres.
    Condition "found" is true. Returned: RES()
    core/io/resource_loader.cpp:278 @ _load()
    GameManager.gd:20 @ initialize_player()
    GameManager.gd:9 @ _process()
    it is also saying that
    Invalid get index 'name' (on base: 'String')

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

      E 0:00:03.072 clearly states: [Cannot open file 'user://inventory.tres'] at the end of the error stack. Meaning essentially there is no file named `inventory.tres` at the location (root) where it tried to find it.
      Then E 0:00:03.171 clearly states that it failed to load the same resource, subsequently because it was not found at first. - To resolve this issue you must create the file in question.

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

      Have you found an answer to this i have the same problem. I tried creating an inventory.tres file but problem's still there

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

      I'm having the same issue with _load: Failed loading resource: user://inventory.tres.

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

    29:08 time in vid :P

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

    I don't have a user://inventory.tres file. How do i create one? Please excuse me if my question is silly, I'm new to game development.

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

      I tried creating a new resource file but item.gd defines the resource class.
      get_items is not a function of this class but instead of inventory.gd which extends node.
      I cannot create inventory.tres using the inventory.gd because it's not a resource type.
      What am I doing wrong?

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

      I cant find the items gd script i made and it says my item is a invalid export type any solutions

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

    First

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

    PLease help me!

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

    when you realize you shouldnt have deleted make human why did i delete it

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

    I hard to work through some random bugs for hours that eventually seemed to resolve themselves rip

  • @aleksitjvladica.
    @aleksitjvladica. 4 роки тому

    [05:01] I can not find ItemResource (Item.gd).

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

      When you created your Item.gd script did you change it's type to Resource? Look at the top of your item.gd script, it should say Extends Resource. If not then you won't be able to find it because you never made one.

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

      @@Haku_Hatake how do i do that i tried to solve it and no luck amd also it says invalid export type for my item any fix?

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

    violets are red roses are blue ctrl: C i stole your code too

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

    Why do you create resource? Why not just script with a class_name? Why not new scene?

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

    var item
    var items
    fkng hell...

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

    Please, before starting a 50 min tutorial dont just straight up jump into the code. An explanation of what the system is going to be able to do and what is going to be needed for that would be much appreciated. (To be a bit more blunt: Im not going to watch this video because what I explained above is missing in the first few minutes of the video.)

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

    If someone can put all the code here so i can post it itl be great lol

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

      Update it says that invalid export type and i cant see my items resource script