Expected Statements and Slow Text
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.
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.
Expected Statements and Slow Text
Hi guys I'm currently trying to figure out how to make my default text style slow text (I've looked online but all of the threads so far are really confusing for me) and what my problem is in part of my script.
For the script problem, here's the error file:
I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.
File "game/script.rpy", line 97: expected statement.
spirit = True
^
Ren'Py Version: Ren'Py 6.99.12.4.2187
Basically what I was trying to do was make a certain choice option only show if the player chose a specific thing earlier. The menu itself would still show if the player did not choose the specific thing earlier in the game, it's just that one of the choices would no longer show. In my actual script, I do have the python symbol ($) before the word spirit. Here's my code for what I just explained:
"Are you a spirit?":
$ spirit = True
(So, if the player chooses to ask that, then "spirit" should become true.)
"Are you his guardian?" if spirit == True:
(I also have this as a later choice. Two other questions are also present, but they can be asked no matter what the player did earlier in the game.)
Thanks~
For the script problem, here's the error file:
I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.
File "game/script.rpy", line 97: expected statement.
spirit = True
^
Ren'Py Version: Ren'Py 6.99.12.4.2187
Basically what I was trying to do was make a certain choice option only show if the player chose a specific thing earlier. The menu itself would still show if the player did not choose the specific thing earlier in the game, it's just that one of the choices would no longer show. In my actual script, I do have the python symbol ($) before the word spirit. Here's my code for what I just explained:
"Are you a spirit?":
$ spirit = True
(So, if the player chooses to ask that, then "spirit" should become true.)
"Are you his guardian?" if spirit == True:
(I also have this as a later choice. Two other questions are also present, but they can be asked no matter what the player did earlier in the game.)
Thanks~
Re: Expected Statements and Slow Text
Well this is a brute force method since I am a beginner myself but maybe this works:
Of course you can control what each label does...I guess what I am saying is make 2 labels with 2 menus, with one label only accessible if $ spirit = True. Indentations may not be accurate in my code.
Furthermore, if you want to include the choice but make it unselectable...modify the choice screen to:
Then in the menu:
This thread is the original one viewtopic.php?f=8&t=25453&p=313338&hili ... ce#p313338
Credit to bg_nocturnal
Code: Select all
label start:
a "Yada yada"
b "Yada yada"
c "Now I will branch story into two parts."
if spirit = True:
jump spirittrue
jump spiritfalse
label spirittrue:
menu:
"Are you a spirit?":
jump tostory
"Choice 2":
jump tostory
"Choice 3:
jump tostory
label spiritfalse
menu:
"Choice 2":
jump tostory
"Choice 3:
jump tostory
label tostory:
a "Story continues"
Furthermore, if you want to include the choice but make it unselectable...modify the choice screen to:
Code: Select all
screen choice:
window:
style "menu_window"
xalign 0.5
yalign 0.5
vbox:
style "menu"
spacing 2
for caption, action, chosen in items:
if action:
if " (disabled)" in caption:
$ caption = caption.replace(" (disabled)", "")
button:
action None
style "menu_choice_button"
text caption style "menu_choice"
else:
button:
action action
style "menu_choice_button"
text caption style "menu_choice"
else:
text caption style "menu_caption"
Code: Select all
label spiritfalse:
menu:
"Are you a spirit?" (disabled):
jump tostory
"Choice 2":
jump tostory
"Choice 3:
jump tostory
Credit to bg_nocturnal
Re: Expected Statements and Slow Text
The thing is, the spirit = true code itself isn't working. I keep getting the expected statement error.famakki1 wrote:Well this is a brute force method since I am a beginner myself but maybe this works:
Of course you can control what each label does...I guess what I am saying is make 2 labels with 2 menus, with one label only accessible if $ spirit = True. Indentations may not be accurate in my code.Code: Select all
label start: a "Yada yada" b "Yada yada" c "Now I will branch story into two parts." if spirit = True: jump spirittrue jump spiritfalse label spirittrue: menu: "Are you a spirit?": jump tostory "Choice 2": jump tostory "Choice 3: jump tostory label spiritfalse menu: "Choice 2": jump tostory "Choice 3: jump tostory label tostory: a "Story continues"
Furthermore, if you want to include the choice but make it unselectable...modify the choice screen to:
Then in the menu:Code: Select all
screen choice: window: style "menu_window" xalign 0.5 yalign 0.5 vbox: style "menu" spacing 2 for caption, action, chosen in items: if action: if " (disabled)" in caption: $ caption = caption.replace(" (disabled)", "") button: action None style "menu_choice_button" text caption style "menu_choice" else: button: action action style "menu_choice_button" text caption style "menu_choice" else: text caption style "menu_caption"
This thread is the original one viewtopic.php?f=8&t=25453&p=313338&hili ... ce#p313338Code: Select all
label spiritfalse: menu: "Are you a spirit?" (disabled): jump tostory "Choice 2": jump tostory "Choice 3: jump tostory
Credit to bg_nocturnal
Re: Expected Statements and Slow Text
Instead of true/false, use 0 and 1.
so define...
In the script:
This should work.
I think for text you need to 'assign' in if statement (double equal signs), ie. $ spirit = True, then declare as:
EDIT:
I quickly tested the following code and it works:
so define...
In the script:
Code: Select all
$ spirit = 1
I think for text you need to 'assign' in if statement (double equal signs), ie. $ spirit = True, then declare as:
Code: Select all
if spirit == True: #double equal signs
jump tostory
I quickly tested the following code and it works:
Code: Select all
label start:
scene white
"You've created a new Ren'Py game."
$ spirit = True
if spirit == True: #if you comment the jump and if statement, game will return to main menu.
jump spirit #otherwise game should jump to label spirit
return
label spirit:
"spirit is true"
Re: Expected Statements and Slow Text
I tried that, but it still said "spirit" was undefined.famakki1 wrote:Instead of true/false, use 0 and 1.
so define...
In the script:This should work.Code: Select all
$ spirit = 1
I think for text you need to 'assign' in if statement (double equal signs), ie. $ spirit = True, then declare as:
EDIT:Code: Select all
if spirit == True: #double equal signs jump tostory
I quickly tested the following code and it works:
Code: Select all
label start: scene white "You've created a new Ren'Py game." $ spirit = True if spirit == True: #if you comment the jump and if statement, game will return to main menu. jump spirit #otherwise game should jump to label spirit return label spirit: "spirit is true"
Re: Expected Statements and Slow Text
Can you show your code on how you are defining the variable for 'spirit'?
If you copy and paste the above example into a new project, it works fine, so you can replicate that but I think the issue is related to the way you are defining the variable.
EDIT: Make sure you are using the 'dollar' sign. ie. $ spirit = True since your error is reading:
File "game/script.rpy", line 97: expected statement.
spirit = True
^
If you copy and paste the above example into a new project, it works fine, so you can replicate that but I think the issue is related to the way you are defining the variable.
EDIT: Make sure you are using the 'dollar' sign. ie. $ spirit = True since your error is reading:
File "game/script.rpy", line 97: expected statement.
spirit = True
^
Re: Expected Statements and Slow Text
Here's the code for defining "spirit"
And for the menu:
Code: Select all
"Are you a spirit?":
$ spirit = True
"So, Sera...You're a spirit, right?"
Code: Select all
menu:
"What do you want to talk about?"
"Where do you guys live?":
pn "So do you guys live close to the campus?"
s "Oh! We live together, actually. We're roommates! We live about a mile off campus in this little rental house."
n "Living with Sera is actually awful. Please save me."
s "Oh shut up, you know you looooove me!"
n "A-As if!"
jump finding_out
"Are you two dating?":
pn "So, uh, are you two...dating?"
n "W-WHAAAAT?!"
s "Nonononononono! We're not dating!"
n "E-Ew. No."
s "Besides, I'm like, the most gay person ever. Like, ever. Feel free to call me the Ultimate Gay. And Naois here is about as straight as a circle."
n "S-Sera!"
s "Oh, I'm sorrrrrry. You're sensitive~ Hehehe"
jump finding_out
"Are you his guardian?" if spirit == True:
pn "Are you Naois' Guardian?"
jump naois_guardian
Re: Expected Statements and Slow Text
I don't know what the issue could be, however, I have attached a Renpy project containing your code which is working, which can help I hope.
I do not know if you made this part of menu, but this code can't work unless part of a menu.dIgItayel wrote:Here's the code for defining "spirit"Code: Select all
"Are you a spirit?": $ spirit = True "So, Sera...You're a spirit, right?"
- Attachments
-
- spirittrue.rar
- (333.87 KiB) Downloaded 17 times
Re: Expected Statements and Slow Text
That's basically the exact code I have.famakki1 wrote:I don't know what the issue could be, however, I have attached a Renpy project containing your code which is working, which can help I hope.
I do not know if you made this part of menu, but this code can't work unless part of a menu.dIgItayel wrote:Here's the code for defining "spirit"Code: Select all
"Are you a spirit?": $ spirit = True "So, Sera...You're a spirit, right?"
Code: Select all
menu:
"What do you say?"
"Is this a safe neighborhood?":
pn "So, uh... Is this a safe neighborhood?"
s "Oh! Well, not really if I'm being honest... There's a lot of poverty near here, so there's a lot of crime..."
pn "Does that include-"
s "Yeah. Murder. Look, don't worry about it. Just stay near the campus and don't go seekin' trouble."
jump meet_naois
"Are you a spirit?":
$ spirit = True
"So, Sera...You're a spirit, right?"
jump spirit_sera
Code: Select all
While running game code:
File "game/script.rpy", line 189, in script
menu:
File "game/script.rpy", line 210, in <module>
"Are you his guardian?" if spirit == True:
NameError: name 'spirit' is not defined
- korova
- Veteran
- Posts: 217
- Joined: Sat Jun 27, 2009 5:15 pm
- Completed: Ivy, Chocolate, Time, Clair Obscur
- Projects: Writing exercises, The House [Nano18]
- Tumblr: korova08
- itch: korova
- Location: Normandie, France
- Contact:
Re: Expected Statements and Slow Text
Because it's the only time you actually "define" the variable (= make it exist)dIgItayel wrote: It says it's not defined, but it works just fine when I choose "Are you a spirit?"
If you don't choose "Are you a spirit", the "spirit" variable is not defined.
You'll have to put
Code: Select all
default spirit = False
This way, the variable always exists, and become true only if you choose "Are you a spirit"
Who is online
Users browsing this forum: Bing [Bot], Google [Bot], voluorem