Devlog 2026-11-24

Back to the grind we go.

So last time we left we needed to continue the pages framework by adding arrows. In the meantime I figured out both a possible obstacle and its solution.

The possible obstacle is that we need something that keeps tabs on what the current menu is, so that when you press the arrows it knows “okay, regenerate this menu, but in this page”. The possible solution to THAT would be having a second container that holds what we currently have.

As a reminder, the current code creates an object that’s basically holding all the buttons. When it is destroyed all the buttons go away with it. In essence, we need to slot THAT inside a different container that carries the information of which menu we were using.

Let’s take it step by step.

First we create a blank node.

Now, before we do anything else, I wanna make sure that the buttons are nestled inside of it properly.

We load it.

We add it to the function.

We test…

There it is.

Now, IN THEORY the next step is that we make the arrow buttons, we tie a signal to menucarrier (who also carries WHICH menu is currently present) and it just executes the function again but with a different page.

Some preliminary steps first…

First we create a variable that will be set during the function that generates everything…

Like this. What this does is access the script we just made and set the variable from there.

Now we need the code to do meth math. The idea is that it checks how many items the list it has carries so it can determine how many pages to generate.

We’ll do this by using Godot’s floor function. For anyone that remembers any math lesson, you’ll remember that normally the rule of thumb is that decimals at .5 and higher get rounded up while lower than .5 get rounded down. What we’re doing is making sure that if any number has a decimal, it gets turned into the smallest non decimal number that’s not smaller than the non-decimal part.

In practical terms: We need the game to indicate that every 15-item intervals means one page. For example: 14/15=0.9333, that gets rounded down to 0; 22/15=1.466, that gets rounded down to 1; 33/15=2.2, that gets rounded down to 2. 0 means 0 pages so no arrows needed, 1 means there’s 1 extra page and so on.

Now, those more math-oriented among you might’ve spotted the first problem: 15/15 = 1 but we need that to be 0 because it’s still in the first page. For that, we use %. What that symbol means is that it checks whatever amount you’re left with after dividing. In this case we can add a check that goes if 15 % istsize == 0 meaning that before the rounding, if the amount is divisible by 15 then just flat out substract 1.

And so we got this: pagecount is the floor of the list size divided by 15, and THEN if the list size is divisible by 15 to begin with substract 1. You might notice there’s also now a variable instead of a 15. I just moved that to something in the variables list just in case.

From there, we add a couple of variables to the holder of holder, one of which initializes when it is created.

Then we add this to the ButtonGenerator function.

With all that preamble done, let’s make some arrow placeholders.

Something like this.

We create a prefab (not a prefab yet in the capture, mind you).

We tie the signals of the buttons to buttoncarrier and… oh right, the middle bar needs numbers…

Like this.

Now let’s add it to the code and make it spawn if the list is big enough that it’s needed.

Loaded.

We add the conditional.

And it crashes because it needs to be a Node2D to have its position changed like we want instead of just being a vague general Holder Of Things.

So we redo that bit.

Son of a bitch, it was a typo.

Fixed.

BAM there it is.

Okay so next we check that it disappears if there’s not enough items… in fact, let’s check with exactly 15 items.

WOOOO.

Right, so last thing I wanna do today is make that number reflect the page count.

We add this to our big ol’ ButtonGenerator…

And there it is. granted it makes no sense as-is but adding a +1 for aesthetic purposes isn’t hard.

Let’s also add functions to these buttons next time.

I’ll start with the arrows, dunno if I’ll make it to the location buttons themselves, but that one’s definitely done before the month ends.



Posted

in

by

Tags: