If statements help? {solved}

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
shojozombie
Newbie
Posts: 11
Joined: Thu Jan 28, 2016 8:06 am

If statements help? {solved}

#1 Post by shojozombie » Tue Apr 19, 2016 3:38 pm

Greetings internet :)

I'm using Ren'py for a uni project. The game is a detective game! I have a character select screen, where if you pick a character it displays their "background check", before the player goes to interview them. I have four characters on this screen.

I'm very new to Ren'py + Python in general, and was hoping for some help figuring out how to do the following:

I want the game to remember if a player has looked at a background check. Then, once they have looked at all 4 background checks, I would like a new option available that let's the player begin interviews.

Upon click of that button, a screen will pop up that is reminiscent of the character select screen, but it’s now night time and the character buttons have disappeared. The narrator/PC will talk to themselves saying something like, “I think I’ve done enough research. It’s time to see them face to face.” On the last click, the scene will then fade out and a ‘thanks for playing!’ will come up (it IS a uni project xD!)

This is the current working script, by which I mean it has no errors :P *yay* Sorry if it's too much, I'm not sure what you'll need to see and not see so I'm just dropping everything ._. Very grateful for your help <3

Code: Select all

# You can place the script of your game in this file.

# Declare images below this line, using the image statement.
# eg. image eileen happy = "eileen_happy.png"

#General game images
image Intro = "Intro Wide camera.png"
image hijabi = "modernmuslim.png"
image father = "christiandadman.jpg"
image chineseteen = "chineselateteens.png"
image veteran = "Veteran.png"
image filesscreen = "headshots.jpg"
image filesnighttime = "PC_Desk_Night.jpg"

#Daieba related images
image Daiebasfile = "Daieba file.jpg"
image Daieba_SM = "Daieba Facebook.png"
image Daieba_work = "Daieba workplace.jpg"
image Daieba_child = "Daieba child.jpg"
image Daieba_car = "Daieba car.jpg"

#Niu related images
image Niusfile = "Niu file.jpg"
image Niu_Relationships = "Niu relationships.jpg"
image Niu_Uni = "Niu university.jpg"
image Niu_SM = "Niu Instagram.jpg"
image Niu_Travel = "Niu travel.jpg"

#Fred related images
image Fredsfile = "Fred file.jpg"
image Fred_Relationships = "Fred family.jpg"
image Fred_work = "Fred workplace.jpg"
image Fred_Travel = "Fred travel.jpg"
image Fred_SM = "Fred Grindr.jpg"

#Evan related images
image Evansfile = "Evan file.jpg"
image Evan_Relationships = "Evan family.jpg"
image Evan_work = "Evan work.jpg"
image Evan_Travel = "Evan travel.jpg"
image Evan_SM = "Evan social media.jpg"

#General screen
screen files: #Preparing the imagemap
    imagemap:
        ground "headshots.jpg"
        hover "headshots_hover.jpg"
        
        hotspot (476, 247, 191, 242) clicked Jump("hijabi") #top left of picture x + y position, then image dimensions
        hotspot (1006, 247, 196, 242) clicked Jump("chinese")
        hotspot (737, 247, 196, 242) clicked Jump("blackguy")
        hotspot (1277, 247, 193, 242) clicked Jump("oldguy")


#Daieba screen
screen Daiebasbackgroundcheck:
    imagemap:
        ground "D_Background_Daieba.jpg"
        hover "D_Background_Daieba_Hover.jpg"
        
        hotspot (1020, 71, 108, 107) clicked Jump("zoomFacebook")
        hotspot (1021, 209, 107, 108) clicked Jump("zoomWork")
        hotspot (1021, 347, 106, 105) clicked Jump("zoomWithKid")
        hotspot (1021, 485, 109, 107) clicked Jump("zoomCar")
        hotspot (16, 18, 152, 80) clicked Jump("Back_To_Character_Select")
        
#Niu screen
screen Niusbackgroundcheck:
    imagemap:
        ground "D_Background_Niu.jpg"
        hover "D_Background_Niu_Hover.jpg"
        
        hotspot (1020, 71, 108, 107) clicked Jump("zoomInstagram")
        hotspot (1021, 209, 107, 108) clicked Jump("zoomUni")
        hotspot (1021, 347, 106, 105) clicked Jump("zoomFamily")
        hotspot (1021, 485, 109, 107) clicked Jump ("zoomTravel")
        hotspot (16, 18, 152, 80) clicked Jump("Back_To_Character_Select")
        
#Fred screen
screen Fredsbackgroundcheck:
    imagemap:
        ground "D_Background_Fred.jpg"
        hover "D_Background_Fred_Hover.jpg"
        
        hotspot (1020, 71, 108, 107) clicked Jump("zoomGrindr")
        hotspot (1021, 209, 107, 108) clicked Jump("zoomFreelance")
        hotspot (1021, 347, 106, 105) clicked Jump("zoomFamilyFredly")
        hotspot (1021, 485, 109, 107) clicked Jump ("zoomTravelFred")
        hotspot (16, 18, 152, 80) clicked Jump("Back_To_Character_Select")
        
#Evan screen
screen Evansbackgroundcheck:
    imagemap:
        ground "D_Background_Evan.jpg"
        hover "D_Background_Evan_Hover.jpg"
        
        hotspot (1020, 71, 108, 107) clicked Jump("zoomEvanFB")
        hotspot (1021, 209, 107, 108) clicked Jump("zoomEWork")
        hotspot (1021, 347, 106, 105) clicked Jump("zoomEFamily")
        hotspot (1021, 485, 109, 107) clicked Jump ("zoomETravel")
        hotspot (16, 18, 152, 80) clicked Jump("Back_To_Character_Select")
        
#Daiebasbackgroundcheck is a to-be-declared screen of her files, where a bunch of files related to her display including photos and background information.
#They all have one of these. It includes a back button to get to the character select screen

# The game starts here.

label start:
    scene Intro
    #$ HIJAB = "Muslim woman"
    #$ CDM = "The father"
    #$ CTG = "The teen"
    #$ VET = "Veteran"
    #Dynamic character 'HIJAB', etc have been set.
    
    "Public place. Middle of the day."
    "You'd think this would be an easy case to solve."
    "Who should I look into first?"
    jump filesscreen

label filesscreen:
    call screen files #Displaying the imagemap
        
#Daieba related shenanigans

label hijabi:
    scene Daiebasfile
    "This is Daieba Aasima. 31 years old. One child."
    call screen Daiebasbackgroundcheck
        
    label zoomFacebook:
        scene Daieba_SM
        "This is her social media account. She has several hundered friends and posts many pictures of her baby. It shows her family relationships, her love of cats, and a lot of posts complaining about the day nursery."
        "She leaves her toddler there when she goes to work."
        call screen Daiebasbackgroundcheck
    
    label zoomWork:
        scene Daieba_work
        "This is Daieba's workplace. She returned to work recently after having finally secured a nursery place for her child. The jewellery store was one street away from where we found the body in the shopping centre."
        call screen Daiebasbackgroundcheck
        
    label zoomWithKid:
        scene Daieba_child
        "This is Daieba's child. Just under two years old. Attends Rainbow Babies nursery about half an hours drive from the centre."
        "Daeiba informed us she takes on more hours where she can at work to provide for her child."
        call screen Daiebasbackgroundcheck
        
    label zoomCar:
        scene Daieba_car
        "This is her license plate. Car is second or third hand, and 'big enough for a booster seat, not big enough for the weekly shop'."
        call screen Daiebasbackgroundcheck
        
    label Back_To_Character_Select:
        scene filesscreen
    
jump filesscreen
        
#Niu related shenanigans

label chinese:
    scene Niusfile
    "This is Niu Willard. 19. Student."
    call screen Niusbackgroundcheck
        
    label zoomInstagram:
        scene Niu_SM
        "We found Niu's Instagram account, where she keeps a mix of a food and fashion blog."
        call screen Niusbackgroundcheck
    
    label zoomUni:
        scene Niu_Uni
        "Niu studies politics full time. She tells us she has only ever held seasonal work."
        call screen Niusbackgroundcheck
        
    label zoomFamily:
        scene Niu_Relationships
        "Apparently quite close with her grandmother, who simply adores her girlfriend also."
        call screen Niusbackgroundcheck
        
    label zoomTravel:
        scene Niu_Travel
        "'F***ing overpriced train tickets', on Niu's good word. She lives in this city for university so travels home by train."
        call screen Niusbackgroundcheck
        
    label Back_To_Character_Select:
        scene filesscreen
        
jump filesscreen

#Fred related shenanigans

label blackguy:
    scene Fredsfile
    "This is fred. 40, divorced, freelancer."
    call screen Fredsbackgroundcheck
    
    label zoomGrindr:
        scene Fred_SM
        "Fred's only *social media* presence is a dating app."
        "Apparently the work of daughter Adanna, who had a 'field day' setting up the profile for him."
        call screen Fredsbackgroundcheck
        
    label zoomFreelance:
        scene Fred_work
        "'It's all a midlife crisis really.'"
        "'Me and my wife got divorced, I quit my job and went freelance.'"
        "'I write from home for numerous websites so I can look after my daughter too.'"
        call screen Fredsbackgroundcheck
        
    label zoomFamilyFredly:
        scene Fred_Relationships
        "As mentioned, Fred and his wife, a woman named Melanie a couple of years younger than him are now separated."
        "He informs us the divorce was totally amicable and she was very understanding when he came out."
        "They have joint custody of their daughter Adanna, but Adanna lives with Fred most of the time in the old family home, which is closer to school."
        call screen Fredsbackgroundcheck
        
    label zoomTravelFred:
        scene Fred_Travel
        "'As part and parcel of the midlife crisis, I'm building a bike in the garage.'"
        "Fred doesn't currently drive a vehicle and gets around using public transport or walking."
        call screen Fredsbackgroundcheck
        
    label Back_To_Character_Select:
        scene filesscreen

jump filesscreen

#Evan related shenanigans
    
label oldguy:
    scene Evansfile
    "This is Evan Rhydderch, 58."
    call screen Evansbackgroundcheck
    
    label zoomEvanFB:
        scene Evan_SM
        "Evan doesn't have a personal social media, but does have a small Facebook business page for his work."
        call screen Evansbackgroundcheck
        
    label zoomEWork:
        scene Evan_work
        "He is self employed as a gardener. He says he fell into it by accident."
        "It was an easy way to keep his legs moving after his discharge from the army."
        call screen Evansbackgroundcheck
    
    label zoomEFamily:
        scene Evan_Relationships
        "Evan's parents are in their mid eighties, and are in a residential care home."
        "He has one child, a daughter. She teaches English abroad."
        call screen Evansbackgroundcheck
        
    label zoomETravel:
        scene Evan_Travel
        "'I use it for hauling the work equipment mostly.'"
        "He owns a minivan, mostly full of lawnmowers, spades and rakes."
        call screen Evansbackgroundcheck
        
    label Back_To_Character_Select:
        scene filesscreen

jump filesscreen

return

Last edited by shojozombie on Sun Apr 24, 2016 4:35 pm, edited 1 time in total.

User avatar
Kate
Regular
Posts: 197
Joined: Thu Sep 19, 2013 6:10 pm
Projects: Blackout
Organization: Moonlight Otome
Location: United States
Contact:

Re: If statements help?

#2 Post by Kate » Tue Apr 19, 2016 4:05 pm

You'll want a combination of If statements and flags. When the player clicks on the person's profile, use a flag such as Profile_Name_seen and set it to True. (You'll have to declare it up at the top of the file. That's the easiest and neatest way to track flags.)
Here's an example flag:

Code: Select all

$dawn = False
It's that simple. And set it to true. You can set it to true the same way you declare it false at first. Just do it stacked under the options that the player must choose to have seen the screen.

Code: Select all

if $Profile_Name_seen == True

#Whatever happens if it's true
else
#let them see the profile for the first time.
There are other things, including saving it as persistent data, but that's not necessary for such a function.
I hope this answers your question fully.
Current Project:
Blackout [VN][Romance][GxB][Mystery][Suspense] http://lemmasoft.renai.us/forums/viewto ... 43&t=34118
"It is the duty of authors to make the fantastic seem ordinary and the ordinary seem fantastic." - K. Auer

shojozombie
Newbie
Posts: 11
Joined: Thu Jan 28, 2016 8:06 am

Re: If statements help?

#3 Post by shojozombie » Wed Apr 20, 2016 6:19 am

Hi Kate,

Thanks for the response :) I think I understand how to lay it out for each person, but I'm not sure still what to do to make Ren'py only go to the second screen if all 4 flags are true?

Thank-you,
Paige

Onishion
Veteran
Posts: 295
Joined: Mon Apr 20, 2015 10:36 am
Contact:

Re: If statements help?

#4 Post by Onishion » Wed Apr 20, 2016 8:02 am

Well, two possible ways. You can either use a line that says " if FlagVariable1 == True and FlagVariable2 == True and FlagVariable3 == True and FlagVariable4 == True:" and have the result be after that. That works, and might not be awful for only four variables, but it is getting a bit unwieldy. I will also point out that you can ask "if FlagVariable1:" or "if not FlagVariable1:", and those work identically to "if FlagVariable1 == True" and "if FlagVariable1 != True:", and are easier plain English.

But anyway, that's one way to do it, just ask whether all of the variables are true at once. The other method would be to set two variables, so when they view a profile, you'd have:

Code: Select all

default FlagVariable1  = False
default FlagCountVariable = 0

#stuff happens. . .
$ FlagVariable1 = True
$ FlagCountVariable += 1 #this adds one to the number each time it's seen, put both of these lines after they see a file

if FlagCountVariable >= 4:
    #do whatever you want done when they've seen all four. Put this check wherever they end up after viewing the files, before they start the loop over again. 
There are yet other methods, but those get more complicated.

shojozombie
Newbie
Posts: 11
Joined: Thu Jan 28, 2016 8:06 am

Re: If statements help?

#5 Post by shojozombie » Wed Apr 20, 2016 8:29 am

Onishion wrote:Well, two possible ways. You can either use a line that says " if FlagVariable1 == True and FlagVariable2 == True and FlagVariable3 == True and FlagVariable4 == True:" and have the result be after that. That works, and might not be awful for only four variables, but it is getting a bit unwieldy. I will also point out that you can ask "if FlagVariable1:" or "if not FlagVariable1:", and those work identically to "if FlagVariable1 == True" and "if FlagVariable1 != True:", and are easier plain English.

But anyway, that's one way to do it, just ask whether all of the variables are true at once. The other method would be to set two variables, so when they view a profile, you'd have:

Code: Select all

default FlagVariable1  = False
default FlagCountVariable = 0

#stuff happens. . .
$ FlagVariable1 = True
$ FlagCountVariable += 1 #this adds one to the number each time it's seen, put both of these lines after they see a file

if FlagCountVariable >= 4:
    #do whatever you want done when they've seen all four. Put this check wherever they end up after viewing the files, before they start the loop over again. 
There are yet other methods, but those get more complicated.
~

Hi Onishion,

I attempted the first way, but I get this error message:
I'm sorry, but an uncaught exception occurred.

While running game code:
File "game/script.rpy", line 274, in script
menu:
SyntaxError: invalid syntax (game/script.rpy, line 275)

-- Full Traceback ------------------------------------------------------------

Full traceback:
File "game/script.rpy", line 274, in script
menu:
File "C:\Users\user\Desktop\renpy-6.99.8-sdk\renpy-6.99.8-sdk\renpy\ast.py", line 1450, in execute
choice = renpy.exports.menu(choices, self.set)
File "C:\Users\user\Desktop\renpy-6.99.8-sdk\renpy-6.99.8-sdk\renpy\exports.py", line 814, in menu
if renpy.python.py_eval(condition) ]
File "C:\Users\user\Desktop\renpy-6.99.8-sdk\renpy-6.99.8-sdk\renpy\python.py", line 1489, in py_eval
code = py_compile(code, 'eval')
File "C:\Users\user\Desktop\renpy-6.99.8-sdk\renpy-6.99.8-sdk\renpy\python.py", line 512, in py_compile
raise e
SyntaxError: invalid syntax (game/script.rpy, line 275)

Windows-7-6.1.7601-SP1
Ren'Py 6.99.8.959
Murder Mystery Mall 0.0

I have this code on the bottom after the code placed at the top.

Code: Select all

menu:
    "I've seen what I need to see." if $Daiebaseen == True and if $Fredseen == True and $if Niuseen == True and $if Evanseen == True: #Won't show if player hasn't seen all BKchecks
        scene filesnighttime
I also have this set up for all characters:

Code: Select all

label oldguy:
    #$ Clicked_Evansfile = True
    scene Evansfile
    "This is Evan Rhydderch, 58."
    call screen Evansbackgroundcheck
    $Evanseen = True
._. /weeps

User avatar
mobychan
Veteran
Posts: 275
Joined: Fri Apr 24, 2015 6:31 am
Projects: The Chosen - Sakura Pink & Gentian Blue
Organization: Foresoft
Location: Germany
Contact:

Re: If statements help?

#6 Post by mobychan » Wed Apr 20, 2016 8:46 am

Renpy knows "if" you never have to use $ with "if"s

(and you didn't even use it consistenly, sometimes before, sometimes after the if)

btw:
You can use the code tag for error messages as well, it's mostly better visible that way.

shojozombie
Newbie
Posts: 11
Joined: Thu Jan 28, 2016 8:06 am

Re: If statements help?

#7 Post by shojozombie » Wed Apr 20, 2016 8:57 am

mobychan wrote:Renpy knows "if" you never have to use $ with "if"s

(and you didn't even use it consistenly, sometimes before, sometimes after the if)

btw:
You can use the code tag for error messages as well, it's mostly better visible that way.
Hey mobychan,

Ah, that's just typos. Giant headache coming on while doing this xP thanks for pointing them out, but correcting them just gave me another syntax error.

Current bit of code:

Code: Select all

menu:
    "I've seen what I need to see." if Daiebaseen == True and if Fredseen == True and if Niuseen == True and if Evanseen == True: #Won't show if player hasn't seen all BKchecks
        scene filesnighttime
Error:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 274, in script
    menu:
SyntaxError: invalid syntax (game/script.rpy, line 275)

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/script.rpy", line 274, in script
    menu:
  File "C:\Users\user\Desktop\renpy-6.99.8-sdk\renpy-6.99.8-sdk\renpy\ast.py", line 1450, in execute
    choice = renpy.exports.menu(choices, self.set)
  File "C:\Users\user\Desktop\renpy-6.99.8-sdk\renpy-6.99.8-sdk\renpy\exports.py", line 814, in menu
    if renpy.python.py_eval(condition) ]
  File "C:\Users\user\Desktop\renpy-6.99.8-sdk\renpy-6.99.8-sdk\renpy\python.py", line 1489, in py_eval
    code = py_compile(code, 'eval')
  File "C:\Users\user\Desktop\renpy-6.99.8-sdk\renpy-6.99.8-sdk\renpy\python.py", line 512, in py_compile
    raise e
SyntaxError: invalid syntax (game/script.rpy, line 275)

Windows-7-6.1.7601-SP1
Ren'Py 6.99.8.959
Murder Mystery Mall 0.0
275 is the line with the 4 if True's on :/

User avatar
mobychan
Veteran
Posts: 275
Joined: Fri Apr 24, 2015 6:31 am
Projects: The Chosen - Sakura Pink & Gentian Blue
Organization: Foresoft
Location: Germany
Contact:

Re: If statements help?

#8 Post by mobychan » Wed Apr 20, 2016 9:17 am

Remove the "if"s after the "and"s.
Totally forgot to tell you those are wrong too XD

Code: Select all

menu:
    "I've seen what I need to see." if Daiebaseen == True and Fredseen == True and Niuseen == True and Evanseen == True: #Won't show if player hasn't seen all BKchecks
        scene filesnighttime
You can even shorten it to this:

Code: Select all

menu:
    "I've seen what I need to see." if Daiebaseen and Fredseen and Niuseen and Evanseen #Won't show if player hasn't seen all BKchecks
        scene filesnighttime

shojozombie
Newbie
Posts: 11
Joined: Thu Jan 28, 2016 8:06 am

Re: If statements help?

#9 Post by shojozombie » Wed Apr 20, 2016 9:54 am

mobychan wrote:Remove the "if"s after the "and"s.
Totally forgot to tell you those are wrong too XD

Code: Select all

menu:
    "I've seen what I need to see." if Daiebaseen == True and Fredseen == True and Niuseen == True and Evanseen == True: #Won't show if player hasn't seen all BKchecks
        scene filesnighttime
You can even shorten it to this:

Code: Select all

menu:
    "I've seen what I need to see." if Daiebaseen and Fredseen and Niuseen and Evanseen #Won't show if player hasn't seen all BKchecks
        scene filesnighttime
Ahoy mobychan,

Thanks for your patience! Very new to this as you might have gathered.

I fixed to your suggestions, but now get:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 274, in script
    menu:
  File "game/script.rpy", line 275, in <module>
    "I've seen what I need to see." if Daiebaseen == True and Fredseen == True and Niuseen == True and Evanseen == True: #Won't show if player hasn't seen all BKchecks
NameError: name 'Daiebaseen' is not defined

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/script.rpy", line 274, in script
    menu:
  File "C:\Users\user\Desktop\renpy-6.99.8-sdk\renpy-6.99.8-sdk\renpy\ast.py", line 1450, in execute
    choice = renpy.exports.menu(choices, self.set)
  File "C:\Users\user\Desktop\renpy-6.99.8-sdk\renpy-6.99.8-sdk\renpy\exports.py", line 814, in menu
    if renpy.python.py_eval(condition) ]
  File "C:\Users\user\Desktop\renpy-6.99.8-sdk\renpy-6.99.8-sdk\renpy\python.py", line 1490, in py_eval
    return py_eval_bytecode(code, globals, locals)
  File "C:\Users\user\Desktop\renpy-6.99.8-sdk\renpy-6.99.8-sdk\renpy\python.py", line 1485, in py_eval_bytecode
    return eval(bytecode, globals, locals)
  File "game/script.rpy", line 275, in <module>
    "I've seen what I need to see." if Daiebaseen == True and Fredseen == True and Niuseen == True and Evanseen == True: #Won't show if player hasn't seen all BKchecks
NameError: name 'Daiebaseen' is not defined

Windows-7-6.1.7601-SP1
Ren'Py 6.99.8.959
Murder Mystery Mall 0.0
Code relating to this variable:
(Right at the start)

Code: Select all

#Flags
$Daiebaseen = False
$Fredseen = False
$Niuseen = False
$Evanseen = False
And

Code: Select all

label hijabi:
    scene Daiebasfile
    "This is Daieba Aasima. 31 years old. One child."
    call screen Daiebasbackgroundcheck
    $Daiebaseen = True
        
    label zoomFacebook:
        scene Daieba_SM
        "This is her social media account. She has several hundered friends and posts many pictures of her baby. It shows her family relationships, her love of cats, and a lot of posts complaining about the day nursery."
        "She leaves her toddler there when she goes to work."
        call screen Daiebasbackgroundcheck
    
    label zoomWork:
        scene Daieba_work
        "This is Daieba's workplace. She returned to work recently after having finally secured a nursery place for her child. The jewellery store was one street away from where we found the body in the shopping centre."
        call screen Daiebasbackgroundcheck
        
    label zoomWithKid:
        scene Daieba_child
        "This is Daieba's child. Just under two years old. Attends Rainbow Babies nursery about half an hours drive from the centre."
        "Daeiba informed us she takes on more hours where she can at work to provide for her child."
        call screen Daiebasbackgroundcheck
        
    label zoomCar:
        scene Daieba_car
        "This is her license plate. Car is second or third hand, and 'big enough for a booster seat, not big enough for the weekly shop'."
        call screen Daiebasbackgroundcheck
        
    label Back_To_Character_Select:
        scene filesscreen
    
jump filesscreen
Frustrating as hell. I know it's going to be something really obvious isnt it? xD

User avatar
mobychan
Veteran
Posts: 275
Joined: Fri Apr 24, 2015 6:31 am
Projects: The Chosen - Sakura Pink & Gentian Blue
Organization: Foresoft
Location: Germany
Contact:

Re: If statements help?

#10 Post by mobychan » Wed Apr 20, 2016 10:00 am

It doesn't know about your variable.

try removing this:

Code: Select all

$Daiebaseen = False
$Fredseen = False
$Niuseen = False
$Evanseen = False
and add this somewhere central (above label start or something):

Code: Select all

default Daiebaseen = False
default Fredseen = False
default Niuseen = False
default Evanseen = False
No indentation and not inside a label or something

shojozombie
Newbie
Posts: 11
Joined: Thu Jan 28, 2016 8:06 am

Re: If statements help?

#11 Post by shojozombie » Wed Apr 20, 2016 10:10 am

mobychan wrote:It doesn't know about your variable.

try removing this:

Code: Select all

$Daiebaseen = False
$Fredseen = False
$Niuseen = False
$Evanseen = False
and add this somewhere central (above label start or something):

Code: Select all

default Daiebaseen = False
default Fredseen = False
default Niuseen = False
default Evanseen = False
No indentation and not inside a label or something
GAH xD That fixes 'visible' errors, however now when I press the return to character select button, the game goes back to the start screen ._. I was having this trouble and my workaround was the 'jump filesscreen' after each person that you see in the OP.

*Gives virtual cake for help*

User avatar
mobychan
Veteran
Posts: 275
Joined: Fri Apr 24, 2015 6:31 am
Projects: The Chosen - Sakura Pink & Gentian Blue
Organization: Foresoft
Location: Germany
Contact:

Re: If statements help?

#12 Post by mobychan » Wed Apr 20, 2016 10:38 am

Your indentation with those labels seems to be off, adjust it so the label keyword doesn't have any indentation.

in this case it doesn't recognize "jump filesscreen" as part of the Back_To_Character_Select label because of indentation as well.

Code: Select all

    label Back_To_Character_Select:
        scene filesscreen
    
jump filesscreen
Renpy will end the game as soon as nothing else is there to be executed, which is the case with this indentation

shojozombie
Newbie
Posts: 11
Joined: Thu Jan 28, 2016 8:06 am

Re: If statements help?

#13 Post by shojozombie » Wed Apr 20, 2016 10:59 am

mobychan wrote:Your indentation with those labels seems to be off, adjust it so the label keyword doesn't have any indentation.

in this case it doesn't recognize "jump filesscreen" as part of the Back_To_Character_Select label because of indentation as well.

Code: Select all

    label Back_To_Character_Select:
        scene filesscreen
    
jump filesscreen
Renpy will end the game as soon as nothing else is there to be executed, which is the case with this indentation
I really appreciate you sticking with me! Again, fixing indents fixed errors, but now I'm back to where I was before I started this whole process! I get to the character screen and despite clicking on all 4 of them, I don't get the new scene afterwards. Full code just because I have no idea where to point you ><' sorry.

Code: Select all

# You can place the script of your game in this file.

# Declare images below this line, using the image statement.
# eg. image eileen happy = "eileen_happy.png"

#Flags
default Daiebaseen = False
default Fredseen = False
default Niuseen = False
default Evanseen = False

#General game images
image Intro = "Intro Wide camera.png"
#image hijabi = "modernmuslim.png"
#image father = "christiandadman.jpg"
#image chineseteen = "chineselateteens.png"
#image veteran = "Veteran.png"
image filesscreen = "headshots.jpg"
image filesnighttime = "PC_Desk_Night.jpg"

#Daieba related images
image Daiebasfile = "Daieba file.jpg"
image Daieba_SM = "Daieba Facebook.png"
image Daieba_work = "Daieba workplace.jpg"
image Daieba_child = "Daieba child.jpg"
image Daieba_car = "Daieba car.jpg"

#Niu related images
image Niusfile = "Niu file.jpg"
image Niu_Relationships = "Niu relationships.jpg"
image Niu_Uni = "Niu university.jpg"
image Niu_SM = "Niu Instagram.jpg"
image Niu_Travel = "Niu travel.jpg"

#Fred related images
image Fredsfile = "Fred file.jpg"
image Fred_Relationships = "Fred family.jpg"
image Fred_work = "Fred workplace.jpg"
image Fred_Travel = "Fred travel.jpg"
image Fred_SM = "Fred Grindr.jpg"

#Evan related images
image Evansfile = "Evan file.jpg"
image Evan_Relationships = "Evan family.jpg"
image Evan_work = "Evan work.jpg"
image Evan_Travel = "Evan travel.jpg"
image Evan_SM = "Evan social media.jpg"

#General screen
screen files: #Preparing the imagemap
    imagemap:
        ground "headshots.jpg"
        hover "headshots_hover.jpg"
        
        hotspot (476, 247, 191, 242) clicked Jump("hijabi") #top left of picture x + y position, then image dimensions
        hotspot (1006, 247, 196, 242) clicked Jump("chinese")
        hotspot (737, 247, 196, 242) clicked Jump("blackguy")
        hotspot (1277, 247, 193, 242) clicked Jump("oldguy")


#Daieba screen
screen Daiebasbackgroundcheck:
    imagemap:
        ground "D_Background_Daieba.jpg"
        hover "D_Background_Daieba_Hover.jpg"
        
        hotspot (1020, 71, 108, 107) clicked Jump("zoomFacebook")
        hotspot (1021, 209, 107, 108) clicked Jump("zoomWork")
        hotspot (1021, 347, 106, 105) clicked Jump("zoomWithKid")
        hotspot (1021, 485, 109, 107) clicked Jump("zoomCar")
        hotspot (16, 18, 152, 80) clicked Jump("Back_To_Character_Select")
        
#Niu screen
screen Niusbackgroundcheck:
    imagemap:
        ground "D_Background_Niu.jpg"
        hover "D_Background_Niu_Hover.jpg"
        
        hotspot (1020, 71, 108, 107) clicked Jump("zoomInstagram")
        hotspot (1021, 209, 107, 108) clicked Jump("zoomUni")
        hotspot (1021, 347, 106, 105) clicked Jump("zoomFamily")
        hotspot (1021, 485, 109, 107) clicked Jump ("zoomTravel")
        hotspot (16, 18, 152, 80) clicked Jump("Back_To_Character_Select")
        
#Fred screen
screen Fredsbackgroundcheck:
    imagemap:
        ground "D_Background_Fred.jpg"
        hover "D_Background_Fred_Hover.jpg"
        
        hotspot (1020, 71, 108, 107) clicked Jump("zoomGrindr")
        hotspot (1021, 209, 107, 108) clicked Jump("zoomFreelance")
        hotspot (1021, 347, 106, 105) clicked Jump("zoomFamilyFredly")
        hotspot (1021, 485, 109, 107) clicked Jump ("zoomTravelFred")
        hotspot (16, 18, 152, 80) clicked Jump("Back_To_Character_Select")
        
#Evan screen
screen Evansbackgroundcheck:
    imagemap:
        ground "D_Background_Evan.jpg"
        hover "D_Background_Evan_Hover.jpg"
        
        hotspot (1020, 71, 108, 107) clicked Jump("zoomEvanFB")
        hotspot (1021, 209, 107, 108) clicked Jump("zoomEWork")
        hotspot (1021, 347, 106, 105) clicked Jump("zoomEFamily")
        hotspot (1021, 485, 109, 107) clicked Jump ("zoomETravel")
        hotspot (16, 18, 152, 80) clicked Jump("Back_To_Character_Select")
        
#Daiebasbackgroundcheck is a to-be-declared screen of her files, where a bunch of files related to her display including photos and background information.
#They all have one of these. It includes a back button to get to the character select screen

# The game starts here.

label start:
    scene Intro
    #$ HIJAB = "Muslim woman"
    #$ CDM = "The father"
    #$ CTG = "The teen"
    #$ VET = "Veteran"
    #Dynamic character 'HIJAB', etc have been set.
    
    "Public place. Middle of the day."
    "You'd think this would be an easy case to solve."
    "Who should I look into first?"
    jump filesscreen

label filesscreen:
    call screen files #Displaying the imagemap
        
#Daieba related shenanigans

label hijabi:
    scene Daiebasfile
    "This is Daieba Aasima. 31 years old. One child."
    call screen Daiebasbackgroundcheck
    $Daiebaseen = True
        
label zoomFacebook:
    scene Daieba_SM
    "This is her social media account. She has several hundered friends and posts many pictures of her baby. It shows her family relationships, her love of cats, and a lot of posts complaining about the day nursery."
    "She leaves her toddler there when she goes to work."
    call screen Daiebasbackgroundcheck
    
label zoomWork:
    scene Daieba_work
    "This is Daieba's workplace. She returned to work recently after having finally secured a nursery place for her child. The jewellery store was one street away from where we found the body in the shopping centre."
    call screen Daiebasbackgroundcheck
        
label zoomWithKid:
    scene Daieba_child
    "This is Daieba's child. Just under two years old. Attends Rainbow Babies nursery about half an hours drive from the centre."
    "Daeiba informed us she takes on more hours where she can at work to provide for her child."
    call screen Daiebasbackgroundcheck
        
label zoomCar:
    scene Daieba_car
    "This is her license plate. Car is second or third hand, and 'big enough for a booster seat, not big enough for the weekly shop'."
    call screen Daiebasbackgroundcheck
        
label Back_To_Character_Select:
    scene filesscreen
    jump filesscreen
        
#Niu related shenanigans

label chinese:
    #$ Clicked_Niusfile = True
    scene Niusfile
    "This is Niu Willard. 19. Student."
    call screen Niusbackgroundcheck
    $Niuseen = True
        
label zoomInstagram:
    scene Niu_SM
    "We found Niu's Instagram account, where she keeps a mix of a food and fashion blog."
    call screen Niusbackgroundcheck
    
label zoomUni:
    scene Niu_Uni
    "Niu studies politics full time. She tells us she has only ever held seasonal work."
    call screen Niusbackgroundcheck
        
label zoomFamily:
    scene Niu_Relationships
    "Apparently quite close with her grandmother, who simply adores her girlfriend also."
    call screen Niusbackgroundcheck
        
label zoomTravel:
    scene Niu_Travel
    "'F***ing overpriced train tickets', on Niu's good word. She lives in this city for university so travels home by train."
    call screen Niusbackgroundcheck
        
label Back_To_Character_Select:
    scene filesscreen
    jump filesscreen

#Fred related shenanigans

label blackguy:
    #$ Clicked_Fredsfile = True
    scene Fredsfile
    "This is fred. 40, divorced, freelancer."
    call screen Fredsbackgroundcheck
    $Fredseen = True
    
label zoomGrindr:
    scene Fred_SM
    "Fred's only *social media* presence is a dating app."
    "Apparently the work of daughter Adanna, who had a 'field day' setting up the profile for him."
    call screen Fredsbackgroundcheck
        
label zoomFreelance:
    scene Fred_work
    "'It's all a midlife crisis really.'"
    "'Me and my wife got divorced, I quit my job and went freelance.'"
    "'I write from home for numerous websites so I can look after my daughter too.'"
    call screen Fredsbackgroundcheck
        
label zoomFamilyFredly:
    scene Fred_Relationships
    "As mentioned, Fred and his wife, a woman named Melanie a couple of years younger than him are now separated."
    "He informs us the divorce was totally amicable and she was very understanding when he came out."
    "They have joint custody of their daughter Adanna, but Adanna lives with Fred most of the time in the old family home, which is closer to school."
    call screen Fredsbackgroundcheck
        
label zoomTravelFred:
    scene Fred_Travel
    "'As part and parcel of the midlife crisis, I'm building a bike in the garage.'"
    "Fred doesn't currently drive a vehicle and gets around using public transport or walking."
    call screen Fredsbackgroundcheck
        
label Back_To_Character_Select:
    scene filesscreen
    jump filesscreen

#Evan related shenanigans
    
label oldguy:
    #$ Clicked_Evansfile = True
    scene Evansfile
    "This is Evan Rhydderch, 58."
    call screen Evansbackgroundcheck
    $Evanseen = True
    
label zoomEvanFB:
    scene Evan_SM
    "Evan doesn't have a personal social media, but does have a small Facebook business page for his work."
    call screen Evansbackgroundcheck
        
label zoomEWork:
    scene Evan_work
    "He is self employed as a gardener. He says he fell into it by accident."
    "It was an easy way to keep his legs moving after his discharge from the army."
    call screen Evansbackgroundcheck
    
label zoomEFamily:
    scene Evan_Relationships
    "Evan's parents are in their mid eighties, and are in a residential care home."
    "He has one child, a daughter. She teaches English abroad."
    call screen Evansbackgroundcheck
    
label zoomETravel:
    scene Evan_Travel
    "'I use it for hauling the work equipment mostly.'"
    "He owns a minivan, mostly full of lawnmowers, spades and rakes."
    call screen Evansbackgroundcheck
        
label Back_To_Character_Select:
    scene filesscreen
    jump filesscreen
    
menu:
    "I've seen what I need to see." if Daiebaseen == True and Fredseen == True and Niuseen == True and Evanseen == True: #Won't show if player hasn't seen all BKchecks
        show filesnighttime


return
I have to go to a fairly long meeting now, but I'll be checking this ASAP. Thank-you again, really.

Onishion
Veteran
Posts: 295
Joined: Mon Apr 20, 2015 10:36 am
Contact:

Re: If statements help?

#14 Post by Onishion » Wed Apr 20, 2016 3:33 pm

The problem as I see it, the game begins at Start, then runs in order down to "filescreen,"

1. You have multiple labels that are "Back_To_Character_Select." This is useless, since if you called it it would go to the first one or something weird. Either don't make labels of these, or make each label unique.

2. Nothing ever seems to lead back to the menu at the bottom. I'm not sure how you expect the game to get there.

I don't use screens like this (not that it's necessarily bad, just saying I don't have a ton of experience with that part), but I think something along these lines would at least point you in the right direction:

Code: Select all

label filesscreen:
    if Daiebaseen == True and Fredseen == True and Niuseen == True and Evanseen == True: #Won't show if player hasn't seen all BKchecks
        "I've seen what I need to see." 
        show filesnighttime
    call screen files #Displaying the imagemap
This way, each time they return to that label, it checks if they meet the conditions, and if they have it kicks them loose, if not, they go back into the cycle. There seem to be more efficient ways to do some of the other stuff, but this should at least get you started.

shojozombie
Newbie
Posts: 11
Joined: Thu Jan 28, 2016 8:06 am

Re: If statements help?

#15 Post by shojozombie » Sun Apr 24, 2016 4:35 pm

Bah! Hopefully when I get the time to work on this after coursework hand ins I'll be able to use all your suggestions properly! Thanks for trying to help a noob folks :)

Post Reply

Who is online

Users browsing this forum: Google [Bot]