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.
-
jackmcbarn
- Newbie
- Posts: 7
- Joined: Wed Feb 24, 2016 3:56 pm
- Github: jackmcbarn
-
Contact:
#1
Post
by jackmcbarn » Tue Dec 29, 2020 3:28 pm
I have a screen like this:
Code: Select all
screen my_screen(should_be_modal):
modal should_be_modal
text "Hello World"
If I do
show screen my_screen(False), I get
NameError: name 'should_be_modal' is not defined. What do I have to do to make a screen that's modal sometimes, depending on its parameters?
-
Per K Grok
- Miko-Class Veteran
- Posts: 882
- Joined: Fri May 18, 2018 1:02 am
- Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
- itch: per-k-grok
- Location: Sverige
-
Contact:
#2
Post
by Per K Grok » Tue Dec 29, 2020 3:40 pm
jackmcbarn wrote: ↑Tue Dec 29, 2020 3:28 pm
I have a screen like this:
Code: Select all
screen my_screen(should_be_modal):
modal should_be_modal
text "Hello World"
If I do
show screen my_screen(False), I get
NameError: name 'should_be_modal' is not defined. What do I have to do to make a screen that's modal sometimes, depending on its parameters?
You could try
Code: Select all
default should_be_modal=False
screen my_screen(should_be_modal):
modal should_be_modal
text "Hello World"
-
Imperf3kt
- Lemma-Class Veteran
- Posts: 3636
- Joined: Mon Dec 14, 2015 5:05 am
- Location: Your monitor
-
Contact:
#3
Post
by Imperf3kt » Tue Dec 29, 2020 3:51 pm
The way above doesn't appear to work for me, throws an error that the parameter has no value and if I try to forcefully give it a value within the screen itself it returns
Code: Select all
I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.
File "game/script.rpy", line 98: a non-constant keyword argument like 'modal should_be_modal' is not allowed after a python block.
modal should_be_modal
^
A simpler approach, would be to use
show screen for when you want the screen non-modal and
call screen when you want the screen to be modal.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project:
GGD Mentor
Free Android GUI - Updated occasionally
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py
-
_ticlock_
- Veteran
- Posts: 393
- Joined: Mon Oct 26, 2020 5:41 pm
-
Contact:
#4
Post
by _ticlock_ » Tue Dec 29, 2020 5:55 pm
Based on the errors, it seems that modal is "processed" at initialization, thus it can be only constant.
I also tried this:
Code: Select all
screen my_screen(should_be_modal):
if should_be_modal:
modal True
text "Hello World"
No errors this way, but the screen is not modal even if
should_be_modal = True.
Using
show statements with
modal True still make the screen modal and you won't be able to interact with other displayable or dialogues.
You can try using two identical screens (one modal, the other is not). However, it is better to find another approach to do what you want.
-
RicharDann
- Veteran
- Posts: 284
- Joined: Thu Aug 31, 2017 11:47 am
-
Contact:
#5
Post
by RicharDann » Wed Dec 30, 2020 10:19 am
The method with default should_be_modal outside of the screen seems to work, but you can't use it as argument to the screen.
Code: Select all
default should_be_modal = True
screen my_screen():
modal should_be_modal
textbutton "Return" action [Hide('my_screen'), Return()]
label start:
show screen my_screen()
"Right now the screen is modal."
"Right now the screen is hidden." # if you pressed the Return button
"Let's set should_be_modal to False and try again."
$ should_be_modal = False
show screen my_screen()
"Now it's not modal."
The most important step is always the next one.
Users browsing this forum: Bing [Bot]