Devlog #15 - UI Implementation and Automation

Devlog #15 - UI Implementation and Automation

Hey there, after UI design and management I'm back with a more practical devlog again, this time about automating some repetitive tasks!

I already went a bit into detail about the design of our UI but I haven't said anything about its implementation yet.
Since this was originally a game-jam game and also the first more ambitious visual novel either of us worked on, the UI implementation is fairly simple and basically boils down to images that are displayed on the UI layer (So no fancy shenanigans with text and custom screens in this case).

However, since things like the date, the time of day, and Teal's mood constantly change, it's a lot of separate images and keeping track of all of them manually can be a bit of a pain.

For example, early on when I was first implementing the UI, the code for showing just the box with the date in the upper left corner looked like this:

show timebox at topleft onlayer screens
show date march3 at topleft onlayer screens with dAppear
show time afternoon at topleft onlayer screens with dAppear

That's kind of a handful to write on every scene change, especially since all of this needs to be hidden again at the end unless you want it to stay on screen the whole time during a location change.

Since I was fairly new to Ren'Py back then I kept it like this for at least one or two weeks (I think), until I found out that you can call labels and pass arguments to them.

This changed a lot for me, because suddenly I could move all the code above into a single label with a few conditional statements and just write one line of code in the script that practically does the same:

call showDate(3, "afternoon")

Calling labels is handy because it basically goes through the label you call and at the end returns to the one you were previously at. Which meant that in this case the label "dayScreen" checks the two parameters that are given and displays the corresponding date and time of day.
This is kind of a hack-y way to do this, though. If I were to do the same again now, I would probably use a custom screen or maybe Python functions, but back then I didn't know any better so this is how it is now :'D

There are other callable "functions" like this. For example the mood-meter, the emotions that pop up, the introductory screen at the beginning of each day, changes of the time of day without day changes, and so on.

They all function in roughly the same way which means that in general, there is at least one big if-statement with all possible dates, times, or emotions that can be called, which is a hassle to write but the important thing is that you only have to write it once.
After that you can enjoy the relative comfort of one-liners that give you access to all the functionality you put into the label you prepared!

Looking back it seems kind of strange why I didn't consider using proper functions, but one upside to using labels this way is that you can just use Ren'Py's normal syntax and aren't forced to use the corresponding Python functions.
Which one is better probably depends on what you want to do, but I think in this case it worked out fairly well.

Anyway, this covers the obvious functionality of these labels but as I was writing the script I realized that there were other things I constantly wrote. For example, on every day change the first two lines usually looked like this:

stop music fadeout(2.0)
call dayScreen(4, "noon")

It's not a whole lot but with almost 30 in-game days, it adds up.
So to make things simpler when writing the script, I moved the line of code that stopped the music into the "dayScreen" label, since that was going to happen on every single day change.

I also added the following to this label, although that's technically more of a balancing issue:

if tMood < 3:
    $tMood = 3

This basically means that even if Teal's mood is as low as it can be, on the next day it will be at 3 again.
Although... since right now there aren't many moments that drastically bring down Teal's mood, I'm not completely sure it if it actually gets used all that often...
Even so, it just felt a bit strange to me that even after sleeping, Teal's mood could still be at its worst, because at least in my experience sleep usually evens things out a bit.

Well, and that's more or less everything I can say about this.
It's not the cleanest way to handle this kind of automation but I hope it was still helpful in some way.

As always, thanks for reading and we'll be back with another devlog next week!

Get //TODO: today

Download NowName your own price

Leave a comment

Log in with your account to leave a comment.