Oh no, you're right! Unfortunately I've already finished uploading/editing the next episode, but I'll put this in the one after that. Thank you for letting me know!
Done! Caught up with the series in under 3 days :P A few little bugs I can't quite seem to fix yet. But I have to time to take care of that between now and next episode :D
Excellent stuff, but I think you may have missed something; for the "draw_text_ext_color" for the item name and description, the UI width needs to be '(inv_UI_width*scale) - (x_buffer*2*scale)' (at around the 11 minute mark). You annotated the *scale for the 'inv_UI_width' but not for the 'x_buffer*2.' Or rather, if you did, the video pans too quickly to spot it. Again, amazing video, and I feel like I'm learning enough to troubleshoot an issue like this! That's proof of good instruction!
I don't know if it is only in my game. But when I held over an empty inventory slot my time cycle text's font changed to a bigger one. I fixed that mistake by changing the used font in the daycycle draw gui event :)
The code used to 'drop' an item seems like the kind of thing that would be put into a function in coding language like C# since there is so much reused code, is that something that would be viable in Game Maker? Can "scripts" be used as void-returning functions? I'm not sure if maybe that would be a bigger drag on performance than just retyping the code like in this tutorial?
help needed this code here only referenced once. do i need this yet ? also no mouse button is working now not sure where i went wrong not sure if one } is in wrong place in step event as i needed to put one so i put it at bottom. any idea where i might of gone wrong ?
One question... How do we reset a slot in the grid to it's starting point? Like it doesn't contain a crop. Right now I destroy the crop when it collides with my players attack damage object. It disappears but when I try to plant something else in that space it still thinks the previous crop is there.
Okay crap I was just clearing all the crop instances data... It worked, I could plant where the previous plant was, but can also plant over top of existing plants lol I guess I need to set the specific cell that the plant was in back to -1? Can't quite get it... YET lol
Good to be back on it :D I did notice something. When I drop many items from the inventory in the game world (either via the previous way or the way I learned in this video) while not moving. I saw that it all worked fine, but the lerp radius only goes three quarters of a circle. I'm talking about the random direction each item moves away from the player on the game world ground. I tried to make a dense circle around my player by dropping a bunch of items, but I could not "fill" the complete circle, so to say. I fixed it because it's an easy fix (in the obj_item Create event, changed var itemdir = irandom_range(0, 259); into var itemdir = irandom(360);) I am totally unsure if this is only on my end, or if others have noticed. Maybe I'm missing something and this was intended for some reason. Either way, I am wondering why the seemingly perfect irandom_range did not work as well. It should? Probably a weird angle coordinate glitch I guess :)
Oh I keep forgetting to revisit this - no this was a complete slip on my part! In one of the previous videos where we first code this, I was pointing out that the angle 360 is the same as 0, since it's the same as coming through circle. So then I proceeded to say, "so we only need to go to 259" instead of "359". My apologies - and thank you for pointing this out Robin!!
Also, change the 'r = 2' for item collection radius to something like 8. I could run from items going certain directions, even if I stopped, they wouldn't be 'close enough' to be picked up.
I know this is late, but hopefully it will help someone else! The else { mouse_in_inventory = false; } section detects when the mouse is outside of the inventory, so you can add code there. Basically what's happening is the m_slotx and the m_sloty variables aren't updated when you're outside of the inventory, so it keeps displaying whatever was last selected. You can fix that easy by setting them to something like -1. I put in the following line of code inside the else statement: m_slotx = -1; m_sloty = -1;
Thanks for the awesome videos. You're the best! This is a fun series to follow. I had one issue where the mouse directly over the first row of items in the inventory was still selected as indicated by being highlighted and I could also click to pick up the item even though I wasn't on it. It only happens on the top first row and only when above it. I was able to figure out a solution but since I didn't see any comments or hear you comment about it I just wanted to know if you can reproduce the same thing in your game or if it's just me.
As I was building the system I remember encountering a few errors like that. It was usually because of something in the logic of getting the mouse's position and translating it to the grid co-ordinates. It could even be as small as leaving off a "-1" or having ">" instead of ">=". I'd suggest just carefully combing through that section!
I am running into an issue where the numbers can go into the negative when I drop them outside of the inventory. Any idea's where I might have gone wrong?
I did too, but tinkered and i think this is the piece of code that it was. else if(ss_item != item.none) { //drop the item into the game world if(mouse_check_button_pressed(mb_middle)){ inv_grid[# 1, selected_slot] -= 1; //destroy the inventory item if it was the last one if(inv_grid[# 1, selected_slot] == 0){ inv_grid[# 0, selected_slot] = item.none; }
Yes! At the moment I'm planning to do saving after we've implemented a couple more systems, so we have more complicated information to save (player stats, quest stages, etc).
Someone please help, I keep having this problem where my text goes up and I can't find a single piece of information out there telling me how to fix it
You need to use draw_set_valign(fa_top) before you draw the text, this way the vertical alignment of the text will be fixed at the top anchor instead of the middle anchor
I just had this same issue. Check your Z and i numbers under item names and item descriptions so they match. var z = 0; i = 0; for the names, and var z = 1; i = 0; for the descriptions
copy and past this it shout fix it description = iinfo_grid[# 0, iitem] +": "+ iinfo_grid[# 1, iitem]; i also have a problem if you could help just find my comment if thats ok .
Another amazing tutorial. I look forward to each. Have you ever considered becoming a coding teacher? I do have two questions though and that is how you can make it drop the whole stack at a time. I see how to pickup_slot = 0 but then how to you change the dropped item number into anything higher than 1? Also is it normal for the moue to have to be a good deal outside of the inventory to drop the item (though only on the left side)? It seems to need to be a slot outside the inventory to be considered not in invnetory.
Thanks so much :). I've always enjoyed teaching/tutoring, and I suppose this is my outlet! Q1) In the item dropping code, instead of just doing "-1", you would want to take away whatever the number of items that is currently stored in that slot. So you would access inv_grid[# 1, selected_slot] to get that number. It may be useful to store that number in a temporary variable so that you can use it later when you need to spawn the items, probably as a repeat loop, where the number of times you repeat is equal to that same number. Q2) Hmm, no! That sounds like there's a problem with the code that detects where the inventory is (near the top of the Step event), or with dropping the item. Hope that helps!
Seriously ... some of the best tuts with GMS2 on YT.
Totally agree =O!
Your tutorials are very useful! Thank You for your help!
Perhaps I missed it, but I don't think I saw you set up a ds_grid_destroy() line in the Clean Up event for the new ds_items_info data structure.
Oh no, you're right! Unfortunately I've already finished uploading/editing the next episode, but I'll put this in the one after that. Thank you for letting me know!
Done! Caught up with the series in under 3 days :P
A few little bugs I can't quite seem to fix yet. But I have to time to take care of that between now and next episode :D
Nice tutorial! I usually use Json to store item descriptions and other things :)
Cheers! This is actually what I'm planning to end up doing! :)
Excellent stuff, but I think you may have missed something; for the "draw_text_ext_color" for the item name and description, the UI width needs to be '(inv_UI_width*scale) - (x_buffer*2*scale)' (at around the 11 minute mark).
You annotated the *scale for the 'inv_UI_width' but not for the 'x_buffer*2.' Or rather, if you did, the video pans too quickly to spot it.
Again, amazing video, and I feel like I'm learning enough to troubleshoot an issue like this! That's proof of good instruction!
I don't know if it is only in my game. But when I held over an empty inventory slot my time cycle text's font changed to a bigger one. I fixed that mistake by changing the used font in the daycycle draw gui event :)
is anyone else having a problem where when there text is supposed to go to the next line in the item info, it goes up instead of down
The code used to 'drop' an item seems like the kind of thing that would be put into a function in coding language like C# since there is so much reused code, is that something that would be viable in Game Maker? Can "scripts" be used as void-returning functions? I'm not sure if maybe that would be a bigger drag on performance than just retyping the code like in this tutorial?
Curious about this too - Were you able to find out?
help needed this code here only referenced once. do i need this yet ? also no mouse button is working now not sure where i went wrong not sure if one } is in wrong place in step event as i needed to put one so i put it at bottom. any idea where i might of gone wrong ?
One question... How do we reset a slot in the grid to it's starting point? Like it doesn't contain a crop. Right now I destroy the crop when it collides with my players attack damage object. It disappears but when I try to plant something else in that space it still thinks the previous crop is there.
Figured it out! Just waiting on saving the crop data to a save file! Been trying to figure it out but haven't gotten it yet...
Okay crap I was just clearing all the crop instances data... It worked, I could plant where the previous plant was, but can also plant over top of existing plants lol I guess I need to set the specific cell that the plant was in back to -1? Can't quite get it... YET lol
Good to be back on it :D I did notice something. When I drop many items from the inventory in the game world (either via the previous way or the way I learned in this video) while not moving. I saw that it all worked fine, but the lerp radius only goes three quarters of a circle. I'm talking about the random direction each item moves away from the player on the game world ground. I tried to make a dense circle around my player by dropping a bunch of items, but I could not "fill" the complete circle, so to say. I fixed it because it's an easy fix (in the obj_item Create event, changed var itemdir = irandom_range(0, 259); into var itemdir = irandom(360);) I am totally unsure if this is only on my end, or if others have noticed. Maybe I'm missing something and this was intended for some reason. Either way, I am wondering why the seemingly perfect irandom_range did not work as well. It should? Probably a weird angle coordinate glitch I guess :)
Oh I keep forgetting to revisit this - no this was a complete slip on my part! In one of the previous videos where we first code this, I was pointing out that the angle 360 is the same as 0, since it's the same as coming through circle. So then I proceeded to say, "so we only need to go to 259" instead of "359". My apologies - and thank you for pointing this out Robin!!
Oh right! It's 359 haha. I am NOT good with numbers... That makes sense. No problem :)
Also, change the 'r = 2' for item collection radius to something like 8. I could run from items going certain directions, even if I stopped, they wouldn't be 'close enough' to be picked up.
Does someone know how to make so when the mouse is outside the inventory it does not select a slot?
no
I know this is late, but hopefully it will help someone else!
The else { mouse_in_inventory = false; } section detects when the mouse is outside of the inventory, so you can add code there.
Basically what's happening is the m_slotx and the m_sloty variables aren't updated when you're outside of the inventory, so it keeps displaying whatever was last selected. You can fix that easy by setting them to something like -1. I put in the following line of code inside the else statement:
m_slotx = -1; m_sloty = -1;
Thanks for the awesome videos. You're the best! This is a fun series to follow. I had one issue where the mouse directly over the first row of items in the inventory was still selected as indicated by being highlighted and I could also click to pick up the item even though I wasn't on it. It only happens on the top first row and only when above it. I was able to figure out a solution but since I didn't see any comments or hear you comment about it I just wanted to know if you can reproduce the same thing in your game or if it's just me.
As I was building the system I remember encountering a few errors like that. It was usually because of something in the logic of getting the mouse's position and translating it to the grid co-ordinates. It could even be as small as leaving off a "-1" or having ">" instead of ">=". I'd suggest just carefully combing through that section!
Great vid!
Those items descriptions XD
And I think the player didn't digest the artichoke =x 15:28
Great stuff! Thanks!
I am running into an issue where the numbers can go into the negative when I drop them outside of the inventory. Any idea's where I might have gone wrong?
I did too, but tinkered and i think this is the piece of code that it was.
else if(ss_item != item.none) {
//drop the item into the game world
if(mouse_check_button_pressed(mb_middle)){
inv_grid[# 1, selected_slot] -= 1;
//destroy the inventory item if it was the last one
if(inv_grid[# 1, selected_slot] == 0){
inv_grid[# 0, selected_slot] = item.none;
}
Another amazing tutorial. Are you going to cover save and load the entire game and items you have? It would be awesome. Thank you!
Yes! At the moment I'm planning to do saving after we've implemented a couple more systems, so we have more complicated information to save (player stats, quest stages, etc).
You are the best!
Someone please help, I keep having this problem where my text goes up and I can't find a single piece of information out there telling me how to fix it
You need to use draw_set_valign(fa_top) before you draw the text, this way the vertical alignment of the text will be fixed at the top anchor instead of the middle anchor
Woo! This is so cool!
Great stuff!
when i run the game and open my inventory i get a error and it says this: unable to convert string ". " to float, any help?
I just had this same issue. Check your Z and i numbers under item names and item descriptions so they match. var z = 0; i = 0; for the names, and var z = 1; i = 0; for the descriptions
KamaruAshamae thank you, that seemed to work, I had the description z = 0;
copy and past this it shout fix it description = iinfo_grid[# 0, iitem] +": "+ iinfo_grid[# 1, iitem]; i also have a problem if you could help just find my comment if thats ok .
Always very good !!
as of this video we still havent used spr_inv_items_rows = sprite_get_height(spr_inv_items)/cell_size;
Another amazing tutorial. I look forward to each. Have you ever considered becoming a coding teacher?
I do have two questions though and that is how you can make it drop the whole stack at a time. I see how to pickup_slot = 0 but then how to you change the dropped item number into anything higher than 1? Also is it normal for the moue to have to be a good deal outside of the inventory to drop the item (though only on the left side)? It seems to need to be a slot outside the inventory to be considered not in invnetory.
Thanks so much :). I've always enjoyed teaching/tutoring, and I suppose this is my outlet!
Q1) In the item dropping code, instead of just doing "-1", you would want to take away whatever the number of items that is currently stored in that slot. So you would access inv_grid[# 1, selected_slot] to get that number. It may be useful to store that number in a temporary variable so that you can use it later when you need to spawn the items, probably as a repeat loop, where the number of times you repeat is equal to that same number.
Q2) Hmm, no! That sounds like there's a problem with the code that detects where the inventory is (near the top of the Step event), or with dropping the item.
Hope that helps!
Love the tutorials, any plans to make a tutorial on a quest system?
Yes! As we move on to NPCs, I'll be introducing a quest system.
TOP VIDEO!!!
thank you for gamemaker video
If only it was for Game Maker Studio 1.4 :(