You have unlocked the another piece of the nine heavenly gates of programming. You will be unstoppable in the future. (thanks for the trust by subbing!)
structs are perfects, you can use them in so many ways, the first thing i did when structs came out, was to make a copy of cookie clicker. it was one of my first "real" projects i was making for many years ago, and i remeber how hard it was to keep control of each objects ( yes i made every upgrade as an object so it was easiere to change values ) it took so much time, with structs, 2 hours and you have it all up and running. structs are poerfull, and you can use them for so many odd things too, it do not have to be anything about items or games, but you could make a calculator with structs, i would recommend to do that if you dont feel sure about structs yet ;) believe me, when you learn structs you will fall in love with GM once more. Thanks for an awesome video on this topic that many people are a afraid of
Thank you for this video. And for all the other videos you made. It's always fun to learn something new and try it out in my project. You explain everything so easily and nice
This is great! I add one more step to mine, but it's just a preference thing. I do the constructor like you did, then make a struct specific to the items i.e., itemStruct = { drinkingHorn : new create_item("Drinking horn",spr_Item_0) } items = [itemStruct.drinkingHorn]; I will say that saving an array that has a sprite in it can become a nightmare later because it'll generally save the sprite as it's reference number, but then if you add anything new into the project, that sprite's reference number changes so it won't draw the correct one anymore. But that's a whole different topic to do with saving and there might be a better way to save an array than how I do it.
@@1upIndieCurrently making something now, can probably show you the way I am doing once I am done, and you can tell me if it's dumb or not, plus I might need some help.
Technically yes,.You should be able to create a for loop to "insert" values/create new entries via template literals. I did that with codifcation in one of my games (in a simpler way for randomisation), so that should work here aswell. I need check though if the ${expression} would be causing issues. GameMaker is a bit wonky here. I will give you an update I guess tomorrow or Wednesday on that one.
Sure, I guess I can do a tutorial later on that topic. I assume you want the castlevania/metroidvania item popups that you collect on the way that show briefly? Or do you want to see a simple add to inventory one?
@@1upIndie I would say whatever makes it the most simple. I was thinking kinda along the lines of super Mario bros 3 where you can open up the inventory, choose an item and then the item is removed. Now in smb3 the items don’t really stack, but it’d be nice to see a stack as it’s a highly popular component. I know it would just mean adding a “count” variable to the constructor, but just not sure how to implement it in code :)
@@digitalswordplayHm, I have to think about it. I have bridge here a gap between helping you out and make a general purpose inventory for everybody to use. Your idea has 2 things going for it. 1st stacking internally and 2nd using a menue/popup for use. I guess that could be an interesting video tut in the future (but not this week, got too many things I have to do).
What I do for this is use some of the array functions as well as a count variable in the constructor. For example: if keyboard_check_pressed(vk_space) { //Simply add to the count item[0].count += 1; } else if keyboard_check_pressed(vk_tab) { //Remove from the count if there is 1 or more already there if item[0].count >= 1 item[0].count -= 1; } //Remove the item from the array completely if it's now 0 or less if item[0].count
@@Madworld130 in order to remove a specific item wouldn’t you have to implement a selector of sorts or implement a mouse hover over the item to find it and remove it ?
Constructors are great! However, depending on the use case I'm not a huge fan of using them for items. For instance, in my current project, Items require over a dozen parameters, with some of them being functions. Calling a constructor and trying to pass that many parameters looks horrible.
Well, I just show you a way. At the start of my programming journey I never liked it (because it reminded me of Java) but now I over use constructors because they make my life much easier. So if you have a better or other ways to get to your goal, more power to you. I am not the church of programming and no dogma is being forced here, I am just a developer like you.
Before this I was at arrays. My simple mind has been blown. It all makes sense, thank you.
You have unlocked the another piece of the nine heavenly gates of programming. You will be unstoppable in the future. (thanks for the trust by subbing!)
question: what are the other eight? @@1upIndie
same here dude I've been studying gml and c++ for months but just yesterday understudy arrays
@@PixelKnight93Glad I could be of assistance.
structs are perfects, you can use them in so many ways, the first thing i did when structs came out, was to make a copy of cookie clicker. it was one of my first "real" projects i was making for many years ago, and i remeber how hard it was to keep control of each objects ( yes i made every upgrade as an object so it was easiere to change values ) it took so much time, with structs, 2 hours and you have it all up and running. structs are poerfull, and you can use them for so many odd things too, it do not have to be anything about items or games, but you could make a calculator with structs, i would recommend to do that if you dont feel sure about structs yet ;) believe me, when you learn structs you will fall in love with GM once more. Thanks for an awesome video on this topic that many people are a afraid of
Couldn't agree more. That made my life infinite easier developing.
Thank you for this video. And for all the other videos you made. It's always fun to learn something new and try it out in my project. You explain everything so easily and nice
That's the best part of his tutorials. Being able to implement it into our projects without changing much of the rest of the project
Glad to hear I can help a fellow developer out, keep it up!
Agreed, hey there mate!
@@1upIndie 🙏🙏
Now you gotta know which index belongs to which item :D
Thank you for the info, good video
Yeah, that is a just a tiny bit of important. But you can write a repeat loop and check for the name and get as a return value the index back.
You have been using the same background song for years bro I love it haha.
Yeah, a golden one. Thanks RUclips audio library.
This is great! I add one more step to mine, but it's just a preference thing. I do the constructor like you did, then make a struct specific to the items i.e.,
itemStruct = {
drinkingHorn : new create_item("Drinking horn",spr_Item_0)
}
items = [itemStruct.drinkingHorn];
I will say that saving an array that has a sprite in it can become a nightmare later because it'll generally save the sprite as it's reference number, but then if you add anything new into the project, that sprite's reference number changes so it won't draw the correct one anymore. But that's a whole different topic to do with saving and there might be a better way to save an array than how I do it.
Legit :D. Yeah references can be a fickle, I agree.
I am a genius if this this is the advanced way to do this. Still a great video, love all your dedication to the videos dawg.
Well, maybe you are :D. In that case teach me senpai.
@@1upIndieCurrently making something now, can probably show you the way I am doing once I am done, and you can tell me if it's dumb or not, plus I might need some help.
@@georgehennen Sure, I will be honest with you but in a constructive way. Everybody starts small and that is the way that is. Looking forward to it.
@@gleefuluv No I have not. I actually forgot about this. I can?
amazing as always - is there a way to create the items in a for loop - anything like `string text ${expression} string text` Template literals?
Technically yes,.You should be able to create a for loop to "insert" values/create new entries via template literals. I did that with codifcation in one of my games (in a simpler way for randomisation), so that should work here aswell. I need check though if the ${expression} would be causing issues. GameMaker is a bit wonky here. I will give you an update I guess tomorrow or Wednesday on that one.
legend thank you!@@1upIndie
Any chance you’d be able to build on this and add removing + stacking?
Sure, I guess I can do a tutorial later on that topic. I assume you want the castlevania/metroidvania item popups that you collect on the way that show briefly? Or do you want to see a simple add to inventory one?
@@1upIndie I would say whatever makes it the most simple. I was thinking kinda along the lines of super Mario bros 3 where you can open up the inventory, choose an item and then the item is removed. Now in smb3 the items don’t really stack, but it’d be nice to see a stack as it’s a highly popular component. I know it would just mean adding a “count” variable to the constructor, but just not sure how to implement it in code :)
@@digitalswordplayHm, I have to think about it. I have bridge here a gap between helping you out and make a general purpose inventory for everybody to use. Your idea has 2 things going for it. 1st stacking internally and 2nd using a menue/popup for use. I guess that could be an interesting video tut in the future (but not this week, got too many things I have to do).
What I do for this is use some of the array functions as well as a count variable in the constructor. For example:
if keyboard_check_pressed(vk_space)
{
//Simply add to the count
item[0].count += 1;
}
else if keyboard_check_pressed(vk_tab)
{
//Remove from the count if there is 1 or more already there
if item[0].count >= 1 item[0].count -= 1;
}
//Remove the item from the array completely if it's now 0 or less
if item[0].count
@@Madworld130 in order to remove a specific item wouldn’t you have to implement a selector of sorts or implement a mouse hover over the item to find it and remove it ?
thankyou, its very good video
Thanks.
Constructors are great! However, depending on the use case I'm not a huge fan of using them for items.
For instance, in my current project, Items require over a dozen parameters, with some of them being functions. Calling a constructor and trying to pass that many parameters looks horrible.
Well, I just show you a way. At the start of my programming journey I never liked it (because it reminded me of Java) but now I over use constructors because they make my life much easier. So if you have a better or other ways to get to your goal, more power to you. I am not the church of programming and no dogma is being forced here, I am just a developer like you.