Quick Actions: Preparations


Getting To Work

The day job is getting frustrating, but at least the actual amount of work today was low even if I'm stuck in meetings from 9p to 1a! This at least affords me time to work on the game. So I'm diving in to work on my quick action buttons. The first thing I needed to do is figure out where exactly to build the functionality. At the moment I'm starting with the HUD prefab. It contains the buttons, so it'll contain the work. Once I figured out where to do the work,  I had to figure out what the actual work is. . . 

First up, a couple of new placeholder functions! One to update the look of the quick action button and another to process the button press. After I had the placeholder functions, it was time to put them to use. So I added a new hook inside my game state check function to update them according to the scene that's active. I actually learned something new too and immediately put it to use. Just like SQL (which I use at my day job all the time) Godot has an "in" operator! So now I can just add new scenes to the list for update when they're added instead of doing a whole bunch of extra "or" operators.

After I had the update trigger setup it was time to actually connect the button signals. This one had me stumped at first but Gemini straightened me out. It's just a simple "bind" instead of the whole "callable" thing I was doing for other buttons with parameters. This actually simplified my connection logic. Of course, I messed up typing out the code properly, so it took me a couple of tries to get it right. But once I did, everything is giving the proper debug messages!

Making It Do

 That was the easy part, the hard part is what comes next. And during this part, I realized my approach for the button pressed wasn't quite right. I really shouldn't be reaching across scripts for data as much as I am and instead I should just connect the button from the HUD prefab to the inventory manager directly. So, my first step was to move the connections around a bit. Then I had to figure out how to deal with updating the buttons' displays. I had a maddening conversation with Gemini about this where it just couldn't fully comprehend the way my systems are interconnected.

In the end I decided to internalize the quick action button assignment variables and add a getter function to the inventory manager for the data. Then I just reach out to that function for the right data. Actually, now that I think about it, maybe I'm doing things a little wrong here. . . I was originally going to return a dictionary, but then I thought differently. Maybe I should return just the item definition. Oops, no! I almost forgot that there could be things other than items assigned. Sticking with a dictionary.

It took a few tries to get it just right. I needed to make it safe from crashes, and had to make sure I had a way to easily detect if nothing is assigned. Now, the getter function receives the state and the button id and returns a dictionary containing the action type and action id or an empty dictionary if no data is found. I still need to build out the function to actually update the button based on the data. And I need to build out the function that is called on button press. But I think that will be tomorrow's problem.

Wrapping Up

I may dive back in later today, but probably not. Next steps are pretty straightforward, although I think they'll take a few tries to get right. I need to build out the function to actually update the look of the quick action buttons. After that, I need to build out the function that is triggered on press. That should be pretty easy to do too, I think. 

The display function will just go through each of the four buttons, one at a time. It will reach out to the inventory manager's getter function, then verify the data it receives. It will then reach out to the data manager for the item data (that's all that's built now, eventually I'll need to build out other systems for other action items). Then update the button display accordingly (just a simple texture swap, probably).

The press function should be pretty similar. It knows which button is pressed, so it'll use the same getter function to retrieve the data and then validate it. When the check is good, it'll reach out to the inventory manager to consume the item. Again, I need more systems in place for dealing with activatable skills, but that's a much later problem. I still haven't even dug into the skill system yet.

Leave a comment

Log in with itch.io to leave a comment.