Inventory: Updates
Let's Get To Work
Okay, I think I have some time to work on the game now. At least, I hope I do. I know there's plans to go out to the store later, but there's no telling when that'll be, so I'm digging in! First step, let's assign some buttons. First, I have to think about how I want to handle this. I ran into some issues previously with my button assignment for the item slot. I had to use a bound callable to be able to pass an argument, and to remove that signal I needed to use the same bound callable (or something like that, I don't fully understand it).
I worry that after I assign the button one signal, I will have issues assigning a new one for a different item. I'd ask Gemini, but I'm connected to a VPN right now in Hong Kong, and Gemini doesn't like that. Anyway, I'll just dig in on my own to see what to do. Actually, before I do, I was thinking about this one thing. . . Setting a variable in my inventory script to note which item is being displayed. If I do that, I won't have to pass an argument with the function call. But then I run the risk of the function firing as the variable changes and setting the buttons wrong or something.
I have other concerns, too. Right now, the item detail container is just there, always showing. I was thinking about maybe hiding it, but then my inventory will go all wacky (maybe) because of the change in screen space. But, I don't necessarily want the data to just show for the item that was most recently selected. To work around this, for now, I've added a new function to clear the item data from the detail panel whenever the inventory screen is refreshed.
My torrents finally finished, so I was able to disconnect from the VPN for a discussion with Gemini about my signal connections. And, as I expected, adding a new connection will not break the old connection. And not only that, but I must know the value of the parameter used to build the connection if I want to break it. Those two things together mean that I will have to add a variable to deal with the item detail display. It's probably better this way.
Added that new variable, set it when we verify the item id is valid by checking that a valid item resource is pulled using it, and reset to null when the panel is cleared. Pretty simple and straightforward. Next up is adding the functions for my buttons to call. Actually, since these buttons now won't need to pass any parameters, the connections can be set in ready! Then I just need to show/hide them in the function that updates the panel (according to the specifics of the tags assigned to the item).
Function Forming
Five new placeholder functions added, one for each button and one for the pulldown. Then, it was time to deal with the actual showing and hiding. It occurred to me that I didn't really need an if statement for this, and instead I just set the visibility on the nodes based on whether the item contains specific tags. This cut down on the lines of code and reduced complexity. What can I say? I'm a simple man. Once that was done I had Gemini look over the code and it found a small error I made.
Now it is finally time to actually figure out how to consume items. I know I need to do something in both my inventory manager and my playerstats manager. My playerstats manager will need to verify the item can actually be removed, luckily my remove item function already has a return for that. But the first thing I need to ask myself is where do I start my consumption? My first thought is to build it inside the playerstats manager. Have it then base its actions on whether the inventory manager returns true on the removal.
After talking to Gemini though, it suggests I start the consumption in my inventory manager, then pass the information along to my playerstats manager to deal with the effects of consuming the item. My original plan was to allow the player to "over consume", meaning that even if they were at full health, they could still use something that heals them. This way, when it comes to food with other effects (regen, energy, haste, whatever) they won't be blocked from using it when they're not hungry.
In the end, I decided to do it the way I originally intended and talked Gemini into backing my approach. It isn't exactly foolproof, but it's simple and straightforward. I also decided to add a default quantity to my item removal function. This way I can just send an item id and it will default to only removing one.
Affecting Effects
Now it's time to adjust my item definitions. Well, one item definition technically. I've only got two consumables in my item list at the moment. My first instinct was to use a dictionary, so I could just call an effect "heal" with a value, but the item structure wasn't built to support this. After a bit of consideration, I decided to stick with the way things are currently built, if only to reduce my workload, lol. This means I'll need to build out a small set of early-game effects that use static values, and another set of effects that will be more dynamic.
With all of these changes, I needed to do some testing (I haven't up to this point). So, I popped into the game and pushed a few buttons and everything up to this point is working just fine. Well, almost. It works the way I built it, but I'm not sure I like the logic for my inventory refresh surrounding the item detail panel. At the moment, every time the screen is refreshed the item detail panel just empties itself. I thought to maybe add a variable to denote when the panel is clear, but then it occurred to me that I can use the existing variable I'm storing the item id in for the panel!
Now, when the refresh is called from wherever it comes from, the inventory screen will clear the detail panel only if the screen is closed or the last item is used. At least, that's how it's supposed to work. . . And that's mostly how it works. The only missing piece is updating the quantity display on the item detail panel. A new function to update the quantity in the item detail panel and some testing later, SUCCESS!!
Next Time
That previous header may have been a little early. I still need to add the actual effects for use. And I need to deal with the quick action button assignments. But so far everything is moving along swimmingly! Next time I should be diving into the quick action button assignments. That one will be a light lift. Then comes the actual item use effects. That will be a bit heavier, but it shouldn't be too hard.
Xenodochium
The future is what you make of it!
| Status | In development |
| Author | Munchmo |
| Genre | Role Playing |
| Tags | 2D, Cozy, Godot, Indie, Life Simulation, Pixel Art, Sci-fi, Singleplayer |
| Languages | English |
More posts
- Effects: Underwhelming2 days ago
- Inventory Manager: Quick Actions3 days ago
- Planning at the Park5 days ago
- Inventory: Item Details6 days ago
- Item Slot: Pushing My Buttons7 days ago
- Inventory: Item Details8 days ago
- DAB: Interacting!9 days ago
- Dynamic: Action Button10 days ago
- Almost Didn't12 days ago
Leave a comment
Log in with itch.io to leave a comment.