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.
-
LiveTurkey
- Regular
- Posts: 106
- Joined: Tue Dec 27, 2016 10:50 pm
- Location: Brooklyn
-
Contact:
#1
Post
by LiveTurkey » Fri Aug 03, 2018 5:32 pm
I have the following imagebutton
Code: Select all
############################## Corridor Four Door Options Screen ######################################
screen hallwayThreeCorridorFourDoorOptions:
imagebutton:
idle "backgrounds/transparent.png"
action [Hide ("hallwayThreeCorridorFourDoorOptions")]
imagebutton:
idle "boxes/corridorFourG.png"
hover "boxes/corridorFourH.png"
action [Hide ("hallwayThreeCorridorFourDoorOptions"), Hide ("hallwayThreeOptions"), Jump ("corridorFour")]
xpos 760
ypos 890
and the following variable
I want something like this to happen
Code: Select all
action [Hide ("hallwayThreeCorridorFourDoorOptions"), Hide ("hallwayThreeOptions"), if (introductionOver ) Jump ("corridorFour") else player "I really shouldn't miss my first class"]
That code fragment doesn't work for multiple reasons. Basically I want inside of the action part of an imagebutton, for it to check a variable. If it's true it does what it is supposed to do. If it is not true, the main character says something and the player is not allowed to go to corridorFour. Is there any way to do this elegantly and without creating a new label just for this check?
-
Remix
- Eileen-Class Veteran
- Posts: 1628
- Joined: Tue May 30, 2017 6:10 am
- Completed: None... yet (as I'm still looking for an artist)
- Projects: An un-named anime based trainer game
-
Contact:
#2
Post
by Remix » Fri Aug 03, 2018 6:17 pm
Almost...
Code: Select all
action [ Hide ("hallwayThreeCorridorFourDoorOptions"),
Hide ("hallwayThreeOptions"),
If( introductionOver,
Jump ("corridorFour"), # True action
Function( renpy.say, "Eileen", "I really shouldn't miss my first class" ) # False action
) ]
-
LiveTurkey
- Regular
- Posts: 106
- Joined: Tue Dec 27, 2016 10:50 pm
- Location: Brooklyn
-
Contact:
#3
Post
by LiveTurkey » Fri Aug 03, 2018 8:02 pm
Remix wrote: ↑Fri Aug 03, 2018 6:17 pm
Almost...
Code: Select all
action [ Hide ("hallwayThreeCorridorFourDoorOptions"),
Hide ("hallwayThreeOptions"),
If( introductionOver,
Jump ("corridorFour"), # True action
Function( renpy.say, "Eileen", "I really shouldn't miss my first class" ) # False action
) ]
Thank you so much!
Is there any way to make the true or false actions longer than one line?
Like for example lets say for the false action I want char A to say something, char B to say something and char c, to say something.
Will this work?
Code: Select all
action [ Hide ("hallwayThreeCorridorFourDoorOptions"),
Hide ("hallwayThreeOptions"),
If( introductionOver,
Jump ("corridorFour"), # True action
Function( renpy.say, "A", "I really shouldn't miss my first class" ) # False action
Function( renpy.say, "B", "I really shouldn't miss my first class" ) # False action
Function( renpy.say, "C", "I really shouldn't miss my first class" ) # False action
) ]
Do I have to include the multiple lines inside a bracket or something?
-
Remix
- Eileen-Class Veteran
- Posts: 1628
- Joined: Tue May 30, 2017 6:10 am
- Completed: None... yet (as I'm still looking for an artist)
- Projects: An un-named anime based trainer game
-
Contact:
#4
Post
by Remix » Fri Aug 03, 2018 8:57 pm
Just put each multi-action in a list []
Code: Select all
action If( condition,
[ multiple true actions with commas between each ],
[ multiple false actions with commas between each ] )
Note though that afaik actions like renpy.say will end the interaction and thus end the action. It would be far better to just Jump to an interim label and do stuff there.
-
LiveTurkey
- Regular
- Posts: 106
- Joined: Tue Dec 27, 2016 10:50 pm
- Location: Brooklyn
-
Contact:
#5
Post
by LiveTurkey » Sat Aug 04, 2018 6:08 pm
Remix wrote: ↑Fri Aug 03, 2018 8:57 pm
Just put each multi-action in a list []
Code: Select all
action If( condition,
[ multiple true actions with commas between each ],
[ multiple false actions with commas between each ] )
Note though that afaik actions like renpy.say will end the interaction and thus end the action. It would be far better to just Jump to an interim label and do stuff there.
I tried implementing your code,
Code: Select all
if(scheduleAquired):
imagebutton:
idle "tempButtons/hallwayThreeHallwayTwoDoorButtonGround.png"
hover "tempButtons/hallwayThreeHallwayTwoDoorButtonHover.png"
action [If(enteredHomeroom,
Show("hallwayThreeHallwayTwoDoorOptions"),
Function( renpy.say, "mc", "I check my map. This is not the way to Homeroom. I can't be late for my first class." )
)]
xpos 950
ypos 300
but my game crashes and it tells me "Exception: Cannot start an interaction in the middle of an interaction, without creating new context"
Am I missing something?
After doing some research it seems to be because I am calling the screen in which this imagebutton is contained and not showing it.
I think I'm supposed to use
Code: Select all
renpy.call_in_new_context(label, *args, **kwargs)
but I'm not sure where or how.
-
LiveTurkey
- Regular
- Posts: 106
- Joined: Tue Dec 27, 2016 10:50 pm
- Location: Brooklyn
-
Contact:
#6
Post
by LiveTurkey » Wed Aug 08, 2018 8:19 pm
The closest I have gotten is the following line
Code: Select all
Function(ui.callsinnewcontext("say", "Eileen", "I really shouldn't miss my first class" )) # False action
but it says it could not find the label "say"
-
Remix
- Eileen-Class Veteran
- Posts: 1628
- Joined: Tue May 30, 2017 6:10 am
- Completed: None... yet (as I'm still looking for an artist)
- Projects: An un-named anime based trainer game
-
Contact:
#7
Post
by Remix » Thu Aug 09, 2018 4:30 am
Well, say is a screen, not a label.
I still say, It would be far better to just Jump to an interim label and do stuff there, rather than try to juggle with contexts while handling an interaction.
Remember that a label is just a reference to a script position, it does not have to include dialogue or sprites. You can jump or call a label just to handle binding a value to a range if you like or to toggle a date or to continue the story....
Users browsing this forum: Google [Bot]