File: demo_persistent.rpy

package info (click to toggle)
renpy 6.10.2.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 19,468 kB
  • ctags: 5,383
  • sloc: python: 17,801; ansic: 7,116; makefile: 127; sh: 15
file content (37 lines) | stat: -rw-r--r-- 1,083 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
init:
    $ mp = MultiPersistent("demo.renpy.org")

label demo_persistent:

    "Ren'Py supports per-game and multi-game persistent data."

    "Persistent data can store flags and other per-game information that should be shared between plays of a single game."
    
    # per-game persistent data example.
    python:
        if persistent.plays is None:
            persistent.plays = 1
        else:
            persistent.plays += 1

        plays = persistent.plays
        
    "For example, I can tell you that you've see this line %(plays)d time(s) since you cleared the per-game persistent data."

    "Multipersistent data is shared between games, which lets one game unlock features in a second."

    "A sequel might play differently if the player has beaten the first game."
    
    # multipersistent data example.
    python:
        if mp.plays is None:
            mp.plays = 1
        else:
            mp.plays += 1

        mp.save()
        plays = mp.plays

    "According to the multipersistent data, you've seen this line %(plays)d times total."

    return