passwords

A place to discuss things that aren't specific to any one creator or game.
Forum rules
Ren'Py specific questions should be posted in the Ren'Py Questions and Annoucements forum, not here.
Post Reply
Message
Author
bozance
Regular
Posts: 61
Joined: Thu Feb 12, 2009 12:19 am
Contact:

passwords

#1 Post by bozance »

Sorry for all the noobie questions. Here is one more.

Assuming the multi-game persistent data thing might be too complex to pull off (I have another post on that), is there a way to prompt users for passwords in Renpy? I've seen posts about this but I'm not sure if they referred to IF in general. I'm interested in making different passwords lead to different conditions.

If there is some way to save data from one game and load that save file to another game, that would still be the preferred solution, but I'm not expecting to be able to do that. Or can I?

That's all from me, thanks for your help.

BOZANCE

LVUER
King of Lolies
Posts: 4538
Joined: Mon Nov 26, 2007 9:57 pm
Completed: R.S.P
Location: Bandung, West Java, Indonesia
Contact:

Re: passwords

#2 Post by LVUER »

You coul use multipersistent data/variables to achieve similar result.
"Double the princesses, quadruple the fun!" - Haken Browning (SRW-OG Endless Frontier)

DeviantArt Account
MoeToMecha Blog (under construction)
Lolicondria Blog (under construction) <- NSFW

KimiYoriBaka
Miko-Class Veteran
Posts: 636
Joined: Thu May 14, 2009 8:15 pm
Projects: Castle of Arhannia
Contact:

Re: passwords

#3 Post by KimiYoriBaka »

well, I'm not sure how you would generate the passwords, but to prompt for them you would just use renpy.input()

somehow though, it does seem like multipersistent data would be easier.

bozance
Regular
Posts: 61
Joined: Thu Feb 12, 2009 12:19 am
Contact:

Re: passwords

#4 Post by bozance »

I would prefer to use multipersistent, though I'm having trouble making it work.

Are multipersistent variables not used like regular variables? In the example below, Game 2 always starts the same way regardless of whether I turned the lights on or off in Game 1. These are literally the full texts of my test games so any input would be welcome.

GAME 1
init:
$ mp = MultiPersistent("bozance")
$ mp.lights = False
label start:
"Turn on lights?"
menu:
"No.":
jump off
"Yes.":
jump on

label off:
"Lights are still off."

label on:
$ mp.lights = True
$ mp.save()
"You turn on the lights."


GAME 2

init:
$ mp = MultiPersistent("bozance")

label start:
if mp.lights = True:
"The lights are on."
else:
"The lights are off."

Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

Re: passwords

#5 Post by Jake »

bozance wrote:

Code: Select all

    if mp.lights = True:
You've got the right idea about MultiPersistent, but try "==" instead of "=" when you're checking a value. "==" is the comparison operator, while "=" only ever assigns the value on the right to the value on the left.
Server error: user 'Jake' not found

bozance
Regular
Posts: 61
Joined: Thu Feb 12, 2009 12:19 am
Contact:

Re: passwords

#6 Post by bozance »

Even with that typo corrected the data doesn't seem to persist. Is there something basic I'm not doing? I only see one page on this in the tutorials and it seems straightforward enough, but I'm obviously missing something. Do I have to call out the multipersistent variables in the Game 2 initblock?

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: passwords

#7 Post by PyTom »

Are you calling mp.save()?

Really, is this data that should be persisting between multiple games? Or is this just normal persistent data, that is shared between multiple plays of a a single game?
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

bozance
Regular
Posts: 61
Joined: Thu Feb 12, 2009 12:19 am
Contact:

Re: passwords

#8 Post by bozance »

Not even sure what "calling" save means. Apologies if I should know better.

I'm interested in preserving a state from one game to another totally different game. So if lights are on when you complete game 1, they're on at start of game 2. I haven't left anything out in my example... what you see is literally what I've got for this test.

Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

Re: passwords

#9 Post by Jake »

The reason that you're only ever getting "The lights are on" in the second game is that you've only actually saved the multi-persistent data in the branch where the player turns the lights on. So they might start off by default, but that never gets saved - only if the player turns the lights on does the var get saved so that it shows up in the other game. You need to save whenever you make a change to a multi-persistent variable.

So I guess you must have selected 'on' the first time, and it's saved that, and since then it's been reporting as 'on' every time because it never gets overwritten by anything else... otherwise you'd have got an error telling you that 'mp.lights' doesn't exist, if you'd run the second game before ever turning the lights on in the first one.


("Calling" is how we refer to the act of invoking a method - giving the computer the instruction to perform a particular function. So when you type:

Code: Select all

  $ mp.save()
you're 'calling' the save method.)
Server error: user 'Jake' not found

bozance
Regular
Posts: 61
Joined: Thu Feb 12, 2009 12:19 am
Contact:

Re: passwords

#10 Post by bozance »

Still no luck when I add the $mp.save() to both conditions. Lights are always off in the second game. I must be missing something really simple. This is what I have (see below); if anyone can solve this, I will reward them handsomely with positive vibes and well wishes (I'm a little short on money these days unfortunately).

Do I need to save Game 1 as I'm playing it? I don't really see how that would work as I can't load anything for Game 2.

GAME 1

init:
$ mp = MultiPersistent("bozance")
$ mp.lights=False

label start:
"Turn on lights?"
menu:
"No.":
jump off
"Yes.":
jump on

label off:
$mp.save()
"Lights are still off."

label on:
$mp.save()
$mp.lights==True
"You turn on the lights."

GAME 2

init:
$ mp = MultiPersistent("bozance")

label start:
if mp.lights==True:
"The lights are on."
else:
"The lights are off."

Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

Re: passwords

#11 Post by Jake »

bozance wrote:

Code: Select all

label on:
    $mp.save()
    $mp.lights==True
Now you've moved the:

Code: Select all

    $mp.save()
to before the part where you set the variable for lights-on. So when you save, the variable hasn't been set yet, so it's still the default 'False' you set in the init block. Move the 'save' to after you set the variable, and it should work.


On a related note: it's a good idea, when you're posting blocks of code, to enclose them in 'code' tags; there's a button in the editor between 'Quote' and 'List' for it. Like that the spacing and indentation is preserved, which is relevant for Ren'Py/Python code.
Server error: user 'Jake' not found

Wintermoon
Miko-Class Veteran
Posts: 701
Joined: Sat May 26, 2007 3:41 pm
Contact:

Re: passwords

#12 Post by Wintermoon »

bozance wrote: $mp.lights==True
This doesn't set a variable. It checks if the variable has been set, and discards the result. Use this instead:

Code: Select all

    $mp.lights=True

bozance
Regular
Posts: 61
Joined: Thu Feb 12, 2009 12:19 am
Contact:

Re: passwords

#13 Post by bozance »

Yes yes YES!!!!!

HAAAA!!!

Thank you for your insights. I wasn't confident in proceeding with what I'm doing without figuring this out. You can tell I'm a newbie. Thank you VERY VERY MUCH!!!

bozance
Regular
Posts: 61
Joined: Thu Feb 12, 2009 12:19 am
Contact:

Re: passwords

#14 Post by bozance »

Wow, I just read my response (see above) and I think I come across as a bit nuts. But I really am excited... I've been trying to get a conditional novel going for years and finally settled upon Renpy to do so, and believe it or not this issue was at the heart of whether I could do what I really want to do.

Thanks again to all who posted to this thread. My exuberance is indeed real, if a bit nutty.

Post Reply

Who is online

Users browsing this forum: No registered users