How to make a location memory system?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
cuteankle
Newbie
Posts: 17
Joined: Sun Jun 25, 2023 11:04 am
itch: python
Contact:

How to make a location memory system?

#1 Post by cuteankle »

Code: Select all

label newday:
    show screen DayDisplay
    
    call statlock
    if energy == 3:
        call morning
    elif energy == 2:
        call day
    elif energy == 1:
        call night
    else:
        if extra_rest == True:
            $ energy = 3
            $ extra_rest = False
            call monthchange
            call daychange
        elif extra_rest == False:
            $ energy = 2
            call monthchange
            call daychange 
         
label morning:

    if location == house_street:
        jump house_street
    elif location == house_yard:
        jump house_yard
    else:
        scene room_morning
        menu:
            "caridor":
                jump caridor
            "mirror":
                jump mirror
            "school":
                jump school       
            "relex":
                $ energy -= 1

    return

label day:

    if location == house_street:
        jump house_street
    elif location == house_yard:
        jump house_yard
    else:
        scene room_day
        menu:
            "caridor":
                jump caridor
            "mirror":
                jump mirror
            "work":
                jump work_supermarket        
            "relex":
                $ energy -= 1

    return

    return

label night:
    scene room_night

    if location == house_street:
        jump house_street
    elif location == house_yard:
        jump house_yard
    else:
        menu:
            "caridor":
                jump caridor
            "Mirror":
                jump mirror
            "Relax":
                $ energy -= 1
            "Sleep":
                $ energy -= 1
                $ extra_rest = True
                "You zzz-zz-z-zzzz-z"


    return

How to make a good location memory system out of this, so that when resting at another location, energy is taken away and the character stays in the same place without teleporting home?

I tried writing:

$ location = 0
$ house = 1
$ yard = 1

If you came, for example, to the house, it worked there:
$ location = house
"Go to the yard":
$ location = 0 or $house = 0
$ location = yard
"Go home"
$ location = 0 or $ yard = 0

But for some reason, when switching to a new cycle, if I am not in the house, I am thrown into it, although it is indicated that when leaving the house it turns off, I do not understand how to make a system that will allow me to have dozens of locations and not bug.

Post Reply

Who is online

Users browsing this forum: No registered users