@@Kezarus I would say it's too early for that, 2.3 just came out and I myself have been trying to figure out good practices, let alone best practices 😄
@@GameMakerStation, I have the same struggle in the past versions too. And it's always a good reminder of good things that could be done. Or done ina a better way. But thanks for the content, mate! I will stay tunned for more. =]
It didnt impreved much, in the previous version you can still create a variable in the object then changing it in the level editor ( ex: bulletType = bullet1, bullet2...bullet3...etc.. "instance_create"bulletType " )... Anyway if you could make a tutorial about better animations that would make day :D... An animation action/soundEffect shouldnt play on a key press or animBegin or animEnd, but instead on a specific frame of that animation.
Big thanks for all your videos on game maker studio 2.3, these have been very helpful for converting my project and getting started with the new version's features.
Follow up, with this new system, once you collect an item ie the bow in your example, how would you loop through the list to find it if you needed to know that it exists in the inventory?
You can store the item reference (from the enum) in the inventory list, and just pull the data from the global structs whenever you need them. So this way you can check the enum reference in any slot in the list.
Hey Gurpreet, I want to stack items using this method. Would you be able to tell me if I'm on the right track? 1. Declare "amount" in the constructor. 2. Add "1" as the amount in the struct for a potion. 3. In the player step event, loop through the inventory to see if potion is already in the inventory. 4. If item is in inventory, += 1 to potion else { add function } 5. Draw GUI event: within loop for displaying text for item, add second draw text line to display item amount. Thoughts?
Thanks for the tutorial! It would be nice if there were English subtitles too, so I can better understand what you do, unfortunately I can't understand spoken English.
I know the Draw GUI event in the inventory object doesn't matter as much since that's just testing to see the structs but I'm trying to do that myself and for some reason, even though I've copied your script 1:1, it's showing two lines of the same item.
great tutorial, very easy to understand, much apreciated! however i'm having some trouble applying this to my game and was hoping you could shed some light: so i have saved my constructors into global variables as you did. i then ad those variables (constructors for knife and gun) into my inventory ds_list. now on a weapon switch, i want to apply all the variables from my ds_list entry for gun to the calling object (sprites, current_ammo etc.). normaly i'd run the constructor function like scr_gun(); but how can i do this with my ds_list entry? cheers
This is awesome! Just one question. I've made an inventory system that uses ds_grids to organize all the info about items, ending up with hundreds of functioning but disorienting lines. I use this method: var item = inv_grid[# 0, ii] var item_name = info_grid[# 0, item] -> draw_text(item_name) var item_description = info_grid[# 1, item] -> draw_text(item_description) var item_color = info_grid[# 2, item] -> draw_text(item_color) and so on for all other values, like price, level, power, etc... How could I adapt my system to get all the values from the structs instead? Thank you for any advice!
Are you using json_encode? I don't think that saves structs. The GMS 2.3.1 beta has functions for saving/loading structs/arrays (json_stringify() and json_parse()). Do note that the beta may corrupt your project, so tread carefully.
Hey man, I'm having some issues with converting my project to 2.3, and I thought you might be able to help. Do you offer any personal assistance with this stuff? Thanks!
It's used to get an item from a DS List. For regular arrays you'd use inventory[i], but for DS Lists, you put the "|" in there to tell GML that it's a DS List, and not an array.
You can add a "count" variable to the item struct. When adding an item to the inventory, first check if it already exists there, and then simply increase the count instead of adding a new struct. I have a separate (albeit older) video on stackable inventory, it uses arrays but the same concept can be applied to structs. ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-Eh39oeDk76Y.html
Great job on explaining how structs and constructors work... but in the context of this video, this approach makes little sense. You briefly mention that at the end of the video, that basically you are creating a bunch of data structures for every single instance of every item in the game, even though those items' variables are static. This is highly inefficient and bad advice. Your alternative method makes more sense, each item template gets a struct but not each instance of an item. However, even than, you are simply using arrays once again, defeating the purpose of using structs really. I don't think structs are useful for most inventory systems. Arrays or data structures are better approaches. However, I do want to point out a case where you WOULD want to use constructors for an inventory system. If you have a complex upgrading system for your weapons/armors than a constructor approach would work wonders, since every single instance of a weapon IS unique in that case, they can all hold unique information about their upgrade path and what not. Likewise for games that have randomized weapons, like "Broadsword" can spawn as "Swift Broadsword" or "Deadly Broadsword" with stat differences and additional effects. So it really comes down to what your individual game NEEDS. Don't use a programming technique that is counter-intuitive to the problem you're trying to solve or feature you're trying to implement. There are many different tools in the toolbox that a programmer needs to learn how to use, but it's also just as important learning WHEN to use which tool. Anyway that's just me nitpicking. Overall a solid tutorial for those who want to learn the basics of structs in GMS2.