Page 1 of 1

Huge library game concept, with daily reading limitation

Posted: Mon Apr 28, 2025 2:28 pm
by Matt_VoxPrima
Hello!

We're designing a huge medieval library in our game that contains 270 books.

Now, I want to make a mechanic where the player can only read 5 books per day Variable["Theodor.Books_Max"]

And each time the player reads a book he hasn't already read (ex.: Library.Book_EpicOfGilgamesh bool) then I increment Variable["Theodor.Books_Read"] by one. This works fine.

Now, I'm struggling to find the correct way to configure these conditions. It seems any solution I try to apply results in the dialogue box being blank and unable to continue...

Re: Huge library game concept, with daily reading limitation

Posted: Mon Apr 28, 2025 3:07 pm
by Tony Li
Hi,

270 books is a lot of conversations to link. It might be better to handle it in code.

For example -- although you may already be doing this -- you can increment the variable in C#:

Code: Select all

// Call this at the start of each new day:
void StartNewDay() => DialogueLua.SetVariable("Theodor.Books_Read", 0);

// Call this when trying to read a book:
void TryToReadBook(string bookConversationTitle)
{
    int numNewBooksReadToday = DialogueLua.GetVariable("Theodor.Books_Read").asInt;
    var bookVariableName = $"Library.Book_{bookConversationTitle}";
    var hasReadBookBefore = DialogueLua.GetVariable(bookVariableName).asBool;
    if (!hasReadBookBefore)
    {
        if (numNewBooksReadToday >= 5)
        {
            DialogueManager.StartConversation("Can't Read More Books Today");
            return; // Exit early. Can't read any more today.
        }
        else
        {
            // Increment # new books read and mark this book as read:
            numNewBooksReadToday++;
            DialogueLua.SetVariable("Thedor.Books_Read", numNewBooksReadToday );
            DialogueLua.SetVariable(bookVariableName, true);
        }
    }
    DialogueManager.StartConversation(bookConversationTitle);
}

Re: Huge library game concept, with daily reading limitation

Posted: Mon Apr 28, 2025 3:29 pm
by Matt_VoxPrima
I don't mind the monkey work. :) I was dividing my conversations like alleys in an actual library: Library/History, Library/Theology, Library/NaturalScience, etc.

But ok I'll show this to my programmer. Thanks!

Re: Huge library game concept, with daily reading limitation

Posted: Mon Apr 28, 2025 3:50 pm
by Tony Li
Alleys is smart -- it reduces the number of nodes whose Conditions you need to check when starting the conversation. But it'll be even more efficient if your programmer can implement something like the idea above. And it might be more scalable if you add or remove books.

Re: Huge library game concept, with daily reading limitation

Posted: Mon Apr 28, 2025 4:05 pm
by Matt_VoxPrima
but just for my own curiosity, was there something wrong with using

Variable["Theodor.Books_Read"] < Variable["Theodor.Books_Max"]

for the books that can be read and

Variable["Theodor.Books_Read"] >= Variable["Theodor.Books_Max"]

for when the daily limit has been attained or surpassed?

I'm curious as to why the dialogue manager didn't know what node to pick and returned blank.

Re: Huge library game concept, with daily reading limitation

Posted: Mon Apr 28, 2025 5:03 pm
by Tony Li
That should work in concept. Maybe there's a typo or something. You could temporarily add a Lua Console to the scene. Then press ~+L to open it, and enter:

Code: Select all

return Variable["Theodor.Books_Read"] >= Variable["Theodor.Books_Max"]
to see what it returns (true or false).

Re: Huge library game concept, with daily reading limitation

Posted: Mon Apr 28, 2025 5:42 pm
by Matt_VoxPrima
Oh wowww that's a thing?!?

That's going to be very helpful! THank you again!