Questions about dating sim code

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.
Message
Author
xMichi
Regular
Posts: 35
Joined: Fri May 30, 2014 4:17 am
Contact:

Questions about dating sim code

#1 Post by xMichi » Fri May 30, 2014 5:16 am

Hi, so I am actually totally new to making otome games, and I'm kind of understanding the basics so far, but while trying to plan things out I ran into a few troubles.
I have used this tutorial already, so that kinda explains the kind of stuff that I do know.

I wanted to make routes using a flag.
Like

Code: Select all

$ charAroute = False
Like first you play the game and can gain points for all the characters, and I wanted to make it so that once you have, for example, 50 points with a character, that you "unlock" a situation... where you can choose an answer that puts the flag on True. (For example if there are 50 points for char A, an extra situation will be unlocked and you can go to a location that you can't go to if you don't have the points yet. There you get a situation with a question and one answer will leave it on false, and the other answer will put it on true and make you jump to the route.)

but... I have no idea how I would be able to do something like that. Unlocking a scene if your points reach a certain number.

Edit:

What I require is a kind of code that unlocks an option as soon as it reaches a certain amount of relationship-points.
Just an extra option that you can simply put into a menu.
For example if you can decide , normally between "going to place A" or "going to place B", and then if you have achieved those points, that it'll show you a "going to place C" option too.
I also want it to show every time until you've clicked it once (you'll be forced to choose something in that situation and after that it won't be needed anymore, so it should disappear once used.)
And I want to know where to put the code.

Could anyone explain me how to do these things?

Thank you in advantage ^^

Edit 2: I changed the question a bit. Hopefully it's understandable ^^
Edit 3: problem solved/questions answered, thank you :3
Last edited by xMichi on Sat May 31, 2014 2:03 pm, edited 4 times in total.

User avatar
Broodelin
Regular
Posts: 193
Joined: Wed May 14, 2014 9:26 pm
Completed: A Harder Battle
Projects: Too many to list
Location: Eagleland
Contact:

Re: Questions about dating sim code

#2 Post by Broodelin » Fri May 30, 2014 5:23 am

If you want to have the route flags set to false, put that second bit of code right after your start label. It's just the easiest and causes the least confusion.

Setting the routes to true after that can be done anytime afterwards. :)

xMichi
Regular
Posts: 35
Joined: Fri May 30, 2014 4:17 am
Contact:

Re: Questions about dating sim code

#3 Post by xMichi » Fri May 30, 2014 5:42 am

I know where I should put the route flag, and I know that I can activate that whenever I want, but it's not what I was asking about.
I want to know if there is a code what will unlock an event as soon as you have reached those points. But not that you HAVE to go there, but that there will be a extra option to go there for example.
(If you choose that option then, I can simply activate the code after the right choice)

and I am worried, if there is a code that can do that, if that won't mess up the rest of the game.
I mean, if I had a code like that, where do I need to put that code?
I also wonder if, once again if a code like that exists, I have to put it in one certain point of the game, or if I can just make it appear in the next time you choose what to do today. (Preferably that the option will be shown everyday until you either decide to not go for it , so it'll go away again, or decide to take the route, and that you jump on that route from there on, and then it can, obviously also disappear since you choose already. Not sure how to do something like this either).

And for example if you are already are in the route, I wondered if... if you have too much negative points and you go below 50 points again, if you will drop out of the route.
And if so, if it's possible to stay in that route anyway.

I hope I explained it a bit better this time ^^

User avatar
Broodelin
Regular
Posts: 193
Joined: Wed May 14, 2014 9:26 pm
Completed: A Harder Battle
Projects: Too many to list
Location: Eagleland
Contact:

Re: Questions about dating sim code

#4 Post by Broodelin » Fri May 30, 2014 5:48 am

Ah, I see. My apologies! :)

My friend did something similar in her project, and I'll contact her to see if I can post some code samples for you.

xMichi
Regular
Posts: 35
Joined: Fri May 30, 2014 4:17 am
Contact:

Re: Questions about dating sim code

#5 Post by xMichi » Fri May 30, 2014 5:51 am

Oh okay, I hope so, thank you for wanting to help me ^^

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Questions about dating sim code

#6 Post by xela » Fri May 30, 2014 7:31 am

Everything is possible, just post exactly what you require and you'll get a straight answer.
Like what we're doing? Support us at:
Image

xMichi
Regular
Posts: 35
Joined: Fri May 30, 2014 4:17 am
Contact:

Re: Questions about dating sim code

#7 Post by xMichi » Fri May 30, 2014 8:21 am

What I require is a kind of code that unlocks an option as soon as it reaches a certain amount of relationship-points.
Just an extra option that you can simply put into a menu.
For example if you can decide , normally between "going to place A" or "going to place B", and then if you have achieved those points, that it'll show you a "going to place C" option too.
I also want it to show every time until you've clicked it once (you'll be forced to choose something in that situation and after that it won't be needed anymore, so it should disappear once used.)
And I want to know where to put the code.

(Oh. I now notice how much simpler I could have put this down... Oops.)

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Questions about dating sim code

#8 Post by xela » Fri May 30, 2014 11:35 am

Code: Select all

init python:
    def mod_c(value):
        global c
        global c_path_complete
        c = c + value
        if not c_path_complete and c >= 75:
            c_path_complete = True

label start:
    $ c = 0
    $ c_path_complete = False

In a fork point in one of your game labels:

menu:
    "Place A":
        "Do something"
    "Place B":
        "Do something"
    "Place C" if c_path_complete:
        "Do something"
Not tested but the code is basic and it should work, you can add more path like d, e, f etc... whenever you need to increase or decrease c, just put in your label code:

Code: Select all

    $ mod_c(1)
    $ mod_c(-2)
and so on. Once c reaches 75, option will become available and will stay available.

There are many ways to go here and many ways to get all of the approaches you've requested in the first post but this will do what's required.
Like what we're doing? Support us at:
Image

xMichi
Regular
Posts: 35
Joined: Fri May 30, 2014 4:17 am
Contact:

Re: Questions about dating sim code

#9 Post by xMichi » Fri May 30, 2014 7:26 pm

Thank you so much.
Do I put this in the script or options or anything?
Will it appear again though ? After it's clicked... the day after for example. Or will it disappear once seen?

xMichi
Regular
Posts: 35
Joined: Fri May 30, 2014 4:17 am
Contact:

Re: Questions about dating sim code

#10 Post by xMichi » Fri May 30, 2014 7:28 pm

xela wrote:
Not tested but the code is basic and it should work, you can add more path like d, e, f etc... whenever you need to increase or decrease c, just put in your label code:

Code: Select all

    $ mod_c(1)
    $ mod_c(-2)

Wait so how exactly does this part work?;o

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Questions about dating sim code

#11 Post by xela » Sat May 31, 2014 4:39 am

init python part you can put whereever you like, I'd create a new file called functions.rpy and put it there to keep the program clean.

label start bit you can put in script.rpy, label start will already be there.

mod_c bit you need to put whereever that is required by your game, I expect there will be quite a few places.
xMichi wrote:
xela wrote:
Not tested but the code is basic and it should work, you can add more path like d, e, f etc... whenever you need to increase or decrease c, just put in your label code:

Code: Select all

    $ mod_c(1)
    $ mod_c(-2)

Wait so how exactly does this part work?;o
It works like you've asked, lets say player reached some point in the game and deserves 5 new relashanship points with C character. You put $ mod_c(5) in that label and just that happens. If total points reach 75, flag will be set to True and remain that way even if point go below 75 again (as you've requested).

Basically mod_c is a function that makes sure that everything is in one place and code cleaner and better readable. You can extand that function to work with all characters or make dedicated setup for every character like so:

Code: Select all

init python:
    def mod_a(value):
        global a
        global a_path_complete
        a = a + value
        if not a_path_complete and a >= 75:
            a_path_complete = True

label start:
    $ a = 0
    $ a_path_complete = False
and have one for every character in the game.
Like what we're doing? Support us at:
Image

xMichi
Regular
Posts: 35
Joined: Fri May 30, 2014 4:17 am
Contact:

Re: Questions about dating sim code

#12 Post by xMichi » Sat May 31, 2014 12:24 pm

Oh wait,

does this also mean that

Code: Select all

$ a = 0
stands for the character love points?

Code: Select all

$ characterpoints = 0
like this?

and that

Code: Select all

 
$ mod_c(1)
$ mod_c(-2)
is the same kind of code as

Code: Select all

$ characterpoints +=2
? ;o

xMichi
Regular
Posts: 35
Joined: Fri May 30, 2014 4:17 am
Contact:

Re: Questions about dating sim code

#13 Post by xMichi » Sat May 31, 2014 12:46 pm

And with this code:

Code: Select all

init python:
    def mod_c(value):
        global c
        global c_path_complete
        c = c + value
        if not c_path_complete and c >= 75:
            c_path_complete = True
global c , does the c stand for the c in c = 0 that you put under label start?
and c_path_complete, is that a name that you could change?

also

c = c + value
the first c, is that also the c from c = 0? as in the character?

so would I have to make the code for another character like this?

Code: Select all

init python:
    def mod_a(value):
        global a
        global a_path_complete
        a = a + value
        if not a_path_complete and a >= 75:
            a_path_complete = True
like this? ;o (and then for every character)

and under the start label just like

Code: Select all

    $ a = 0
    $ a_path_complete = False
    $ b = 0
    $ b_path_complete = False
    $ c = 0
    $ c_path_complete = False
    $ d = 0
    $ d_path_complete = False
    $ e = 0
    $ e_path_complete = False
    $ f = 0
    $ f_path_complete = False
this?

and...

Code: Select all

$ mod_c(1)
this just after you gain a point for character c?

If I'm not making a mistake here, then I wonder about something
the mod_c thingy ;o
is that connected to c = 0 because of the "global c" in the first code?
Or not? ;o

Sorry if this sounds stupid, but I still have to learn D:


( and just wondering but why the " if not" ? ;o what does that do exactly?)

xMichi
Regular
Posts: 35
Joined: Fri May 30, 2014 4:17 am
Contact:

Re: Questions about dating sim code

#14 Post by xMichi » Sat May 31, 2014 1:27 pm

Oh ^^ I tested it out and I think I get it now, thank you so much :3
it works ^^ Really I am very happy right now, thank you ^^

But I still wonder what the "if not" does ;o

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Questions about dating sim code

#15 Post by xela » Sat May 31, 2014 1:47 pm

if not c_path_complete means: execute the next bit of code for as long as c_path_complete variable returns a negative boolean value (False/0/""/None/[] etc).

More understandable way in this case would be if c_path_complete == False: and it would do the same thing.
Like what we're doing? Support us at:
Image

Post Reply

Who is online

Users browsing this forum: No registered users