Ren'Py An artist stuck in front of a programming wall

namiv

Member
Feb 19, 2020
135
62
Good Day Experts
I am a fairly good artist and had my share of story writing and been working on an interesting novel for a year.
nowadays I feel like to put together the art and story into an interactive game.
everything is ready on the paper (the maps, choices, inventories, stats, ....), but this coding is completely opposite to what i was doing my whole life.
I've been learning but my knowledge is far less that my expectations.
For example I wanted to set TIME (I don't need DATE) , but i simply CAN'T.
here's my code:
define Time = 1 == ("Morning")
if Time >= 7:
$Time = Time - 6
else:
return
### I wanted 6 stages in the game, and after every successful action I would add +1 to the time. 6 should be midnight and i expected the above command to reset the value back to morning.
But it won't. I've searched for solutions and I don't understand them and copy pasting them wasn't helpful at all.
What would you suggest to this BRAIN of mine?
 

namiv

Member
Feb 19, 2020
135
62
if Time == 1:
scene bg 1
if Time == 2:
scene bg 2
if Time == 3:
scene bg 3
if Time == 4:
scene bg 4
if Time == 5:
scene bg 5
if Time == 6:
scene bg 6
if Time >= 7:
scene bg 7

This always gives 7 at the end of the script. Means ($Time = Time - 6) didnt function
skot205
 

skot205

Newbie
Mar 19, 2017
25
33
How are you running $Time = Time - 6. Do you call a label or is it placed just ahead of those if-statements?
 
  • Like
Reactions: namiv

recreation

pure evil!
Respected User
Game Developer
Jun 10, 2018
6,272
22,420
First of all, don't use "Time", I'm not sure about python, but time is a global in many programming languages, so better make a unique identifier like "myTime" or "myGameTime" or whatever you like.
the if you set a new value, don't forget to set a space between $ and the variable: $ myTime = ...
You don't need to set time = time - 6, it's enough if you write $ myTime -= 6 (note the minus sign before the equal sign). The same works with +.
If this doesn't help, post the full code where you use it.
 
  • Like
Reactions: toolkitxx and namiv

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,581
2,219
Someone was asking about a similar topic elsewhere, I ended up writing a "period of day" tracking system as an example.
I only split the day into 4 rather than 6... but the core logic should be close enough for you to get a feel for what is possible.

I tried as much as possible to explain things as I went along.

I don't think it's exactly what you are looking for, but it may give you some clues as to how to go about implementing something similar in your game.

Maybe take a look: https://f95zone.to/threads/renpy-time-advance-issue.35438/post-2695277
(click the spoiler for the code).
 
  • Like
Reactions: namiv

namiv

Member
Feb 19, 2020
135
62
Thats almost all of it, throughout menu choices I give +1 to +3 points to Dayparts
after your message (With this edit) I get less bg 7 in the end but still there is a bug
logically i believe there should be NO bg 7 screen should appear


init -1:
define N = Character("Narrator")
define mc = Character("[mc]", color="#0099cc")
define Ashley = Character("Ashley", color="#F084E2")
define Dayparts = 1
if Dayparts >= 7:
$ Dayparts -= 6
label splashscreen:
scene black with fade
with Pause(0.1)
label start:
scene Skipping
$ Dayparts = 1
play music "audio/01BO.mp3"
N "where are you from?"

label WhereAreYouFromMenu:
$ NotFar = False
$ Faraway = False
$ DoesItMatter = False
$ NoneOfYourBusiness = False
$ menuchoices = 0
menu WhereAreYouFrom:
"Not very far!" if NotFar == False:
$ NotFar = True
$ menuchoices += 1
jump NotFar
"Oh far away!" if Faraway == False:
$ Faraway = True
$ menuchoices += 1
jump Faraway
"Does it really matter" if DoesItMatter == False:
$ DoesItMatter = True
$ menuchoices += 1
jump DoesItMatter
"None of your business!" if NoneOfYourBusiness == False:
$ NoneOfYourBusiness = True
jump NoneOfYourBusiness
jump WhereAreYouFrom
label NotFar:
scene BG intro4
$ Dayparts += 1
jump WhereAreYouFrom
label Faraway:
$ Dayparts += 1
jump WhereAreYouFrom
label DoesItMatter:
$ Dayparts += 1
jump WhereAreYouFrom
label NoneOfYourBusiness:
show image "images/EvilLaugh.png" with SuperFlash
$ Dayparts += 1
jump ReachingCastle
label ReachingCastle:
-
-
-
-
-
if Daypartse == 1:
scene bg 1
if Dayparts == 2:
scene bg 2
if Dayparts == 3:
scene bg 3
if Dayparts == 4:
scene bg 4
if Dayparts == 5:
scene bg 5
if Dayparts == 6:
scene bg 6
if Dayparts >= 7:
scene bg 7
label GameEnd:
return



recreation
 

skot205

Newbie
Mar 19, 2017
25
33
Ok. If I read this correctly you never actually run if Dayparts >= 7: $ Dayparts -= 6.
You have to trigger it from your code somehow. You could use either a function or a label.
Code:
label ResetDayparts:
    if Dayparts >= 7:
        Dayparts -= 6
    return
And then add
Code:
call ResetDayparts
to your code after every time you increment Dayparts.

You could further optimize the code, but I tried to make as few changes as possible.
 
  • Like
Reactions: Cul and namiv

namiv

Member
Feb 19, 2020
135
62
It worked
I happened to try every alternative and didnt recieve any bg 7 at all.
Thanks I was about to give up
Life saver!:love:(y)