TheGamerSide67 / MentalDisabilitySubmod

A submod for Monika After Story that talks about mental disabilities and philosophy!
5 stars 1 forks source link

Optimising mental_calmdown_idle #4

Closed PencilMario closed 2 years ago

PencilMario commented 2 years ago

I optimized the mental_calmdown_idle a bit and used the mas_input screen for the player to say to Monika, which should make the dialogue more immersive :) But I'm using machine translation and I didn't add emotes... It's still up to you whether to merge or not~

TheGamerSide67 commented 2 years ago

Okay, so I know what the MAS input is doing, it allows the player to type how they are feeling. But I can't make out the notes that are written in a different language. If you can, may you please translate them for me, so I can properly understand more of this code, and hoepfully add this, because I was planning to rework this a while ago.

PencilMario commented 2 years ago

OK, I'll take the time to edit the notes today

PencilMario commented 2 years ago

I've finished translating :)

TheGamerSide67 commented 2 years ago

Quick question. I am still new to code myself, so this may be a stupid question. But if

if says.find(keyword) != -1:

Stop checking as soon as keywords are found

Doesn't this mean that it always wants to check for a change, so couldn't this number also be 0?

And of course another question, how would I go about adding more keywords into this aswell? Do I simply define the words with the key, or do I have to do a bit more?

TheGamerSide67 commented 2 years ago

And I appreciate you being patient with me

PencilMario commented 2 years ago

Machine translation warning, this may contain some difficult to understand code content

if says.find(keyword) != -1: # Stop checking as soon as keywords are found Doesn't this mean that it always wants to check for a change, so couldn't this number also be 0?

str.find() will return the start of the string found (starting at 0, so this can be any number), but -1 if it is not found. %A4XF)9A{~4H9QVI )RWH5J

I don't think finding the exact location is important to me, so I just need to judge whether its found or not

And of course another question, how would I go about adding more keywords into this aswell? Do I simply define the words with the key, or do I have to do a bit more?

I used a list to keep a set of keywords, like this

aSimpleList = ["Keyword1", "Keyword2", "Keyword3"]

To add a new keyword, you simply modify the elements of aSimpleList

aSimpleList = ["Keyword1", "Keyword2", "Keyword3", "NewKeyWord4"]

But you'll have a bit of trouble creating a new set of keywords, but it's not difficult

  1. Create a new list to hold your new keywords. All keywords should be lowercase, as the check_says() function converts what the player says to lowercase.
  2. Modify the check_says() function
# I've omitted some things, otherwise it would be too long
init python:
    # New list of keywords
    KeyWordHappy = ["happy", "cool"]

    def check_says(says):
        says = says.lower()
        for keyword in KeyWordSad:
            if says.find(keyword) != -1:
                # Stop checking as soon as keywords are found
                return "Sad"
        for keyword in KeyWordSuicide:
            if says.find(keyword) != -1:
                # Stop checking as soon as keywords are found
                return "Suicide"

        # This is what you need to add
        for keyword in KeyWordHappy:
            if says.find(keyword) != -1:
                return "Happy"

        # If nothing was found
        return None

When the keyword in KeyWordHappy is found, this function returns "Happy" The for loop function will look for each keyword in the list However, if the keyword in KeyWordSad or KeyWordSuicide is found first, "Sad" or "Suicide" will be returned The return keyword will return the corresponding content and the function will be terminated.

TheGamerSide67 commented 2 years ago

Okay, I think I got this, I will mess around with it a bit in my own code. Once I am comfortable with this, I will certainly add your addition in here. I really appreciate your time with this.

I will reword some of the dialog, since it is a bit wordy and isn't fully Monika's "voice".

PencilMario commented 2 years ago

Just a few cons of the translator, good luck :)

TheGamerSide67 commented 2 years ago

I wish you the best to you aswell, and if you ever have any new ideas just feel free to let me know. You can also find my discord here, to contact me more efficiently! TheGamerSide67#7090

Until then! I am off to tweak this code to make it the best it can be! And again, thank you so much. Every explanation brings me closer to understanding coding a lot better!