I don't need labels, I just need screens. I only use label start, since it is fundamental.
But I have a problem: the game doesn't save its state. Every time I go back to the screen 'start screen'.
I don't understand, what does saving state depend on? After loading a save I go back to the screen 'start screen'.
I understand that it's pretty easy to use lots of labels that jump to the next label. But how do I properly use only screens?
I wrote a simple code sample that might serve as an example of roughly what I use
Code: Select all
init:
$ blinds = 0
$ players = 0
$ strn = ''
$ val_1 = 0
define val_2 = 0
default val_3 = 0
init:
style frame:
background None
init python:
def create_table(i, x):
global blinds
blinds = i
renpy.hide_screen('choice_table')
renpy.show_screen('choice_players')
change_var(x)
def create_players(i, x):
global players
players = i
renpy.hide_screen('choice_players')
renpy.show_screen('table')
change_var(x)
def start_game(i, x):
global strn
strn = i
renpy.hide_screen('table')
renpy.show_screen('new_game')
change_var(x)
def change_var(x):
global val_1, val_2, val_3
val_1 = x
val_2 = x
val_3 = x
screen choice_table:
add '#111'
frame:
vbox:
text 'SCREEN 1'
for i in [10, 20, 50, 100]:
textbutton str(i) action Function(create_table, i, 1)
screen choice_players:
add '#222'
frame:
vbox:
text 'SCREEN 2'
for i in [1, 3, 5, 7]:
textbutton str(i) action Function(create_players, i, 2)
screen table:
add '#333'
frame:
vbox:
text 'SCREEN 3'
for i in ['a', 'b', 'c', 'd']:
textbutton i action Function(start_game, i, 3)
screen new_game:
add '#444'
text 'start new game'
screen table_info:
zorder 999
frame align(0, .95):
vbox:
text 'SCREEN 0'
text 'blinds ' + str(blinds)
text 'players ' + str(players)
text 'strn ' + strn
text 'val_1 ' + str(val_1)
text 'val_2 ' + str(val_2)
text 'val_3 ' + str(val_3)
label start:
$ Game_running = True
while Game_running:
jump game
label game:
show screen table_info
call screen choice_table