Script inside screen executed in order

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
User avatar
Lezalith
Regular
Posts: 82
Joined: Mon Dec 21, 2015 6:45 pm
Contact:

Script inside screen executed in order

#1 Post by Lezalith » Tue Dec 22, 2015 5:16 pm

Hey everyone,
I need a little help with this. Sadly, this is more Python-y than Ren'py-y thing.

I have a screen.
There are variables stated when entering the screen: Activation, Affection, Mid, PointsA, PointsB, SetA, SetB, NewPointsA, NewPointsB.
There is a bar inside the screen, representing the PointsA or PointsB variables (Depending if SetA = 1 or SetB = 1).
What I need to do, I need to run a "script", which will do the following actions:

Start if Activation = 1
Mid = (1+Affection)*6
(Affection is further counted from 2 variables, but I feel like that can be done outside of the script)

If SetA = 1
NewPointsA = PointsA + Mid

(Following into)
PointsA = NewPointsA

(Same thing with B)
If SetB = 1
NewPointsB = PointsB + Mid

(Following into)
PointsB = NewPointsB

It is pretty straight forward. Mid is counted from few variables, then added to already existing variable, depending on which one is set (A or B).
What I need is to divide the "adding" process into 3 to 5 parts, and "play" them all, so the bar representing PointsA or PointsB will change 3 to 5 times, increasing.

Example: Let's say Mid = 5. SetA = 1, thus PointsA is the value that will be increased. PointsA already = 5.
PointsA would increase to 6, decreasing Mid to 4. Bar increases.
PointsA would increase to 7, decreasing Mid to 3. Bar increases.
PointsA would increase to 8, decreasing Mid to 2. Bar increases.
PointsA would increase to 9, decreasing Mid to 1. Bar increases.
PointsA would increase to 10, decreasing Mid to 0. Bar increases.
The game can now continue.

I guess I could do this on my own, I just don't know how to write code so it processes in order, not all at once. Guess I could do jump after each line of action with variable, so it would be somewhat done in order, but there has to be an easier way.

Also, how do you set a variable so it can be only equal to 0 and greater?

philat
Eileen-Class Veteran
Posts: 1853
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Script inside screen executed in order

#2 Post by philat » Tue Dec 22, 2015 6:37 pm

You're looking for AnimatedValue. Search the forums and documentation on how to use it.

Post Reply

Who is online

Users browsing this forum: Google [Bot], _ticlock_