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.
n "Forget about about the space journey and your job for a moment."
n "What was you favorite hobby as child?"
menu:
"Knowledge on Animals & Plants" if homeworld = "planet":
python:
player.skills.append(['Knowledge on Animals & Plants', 1])
n "Tell me, what were you doing on the spaceship travelling to A1 again?"
menu:
"I work as a mechanist.":
python:
player.skills.append(['Mechanics', 3])
"I work as a pilot.":
python:
player.skills.append(['IT', 3])
Attachments
Last edited by marionline on Thu Nov 12, 2020 1:24 pm, edited 1 time in total.
When you need to do an equality comparison with if statement, you must use two equal signs (==).
Additionally, if you only need one expression you can invoke functions or any python expression in the script directly by using a $ sign before the expression instead of a python block.
label summary:
$ home_name = renpy.input("What was this [homeworld] called?")
$ home_name = home_name.strip()
if home_name == "":
$ home_name = "HOMEWORLD"
else:
povname "My home is called [home_name]!"
n "All right. You name is [player.name] and you lived at a [homeworld] called [home_name]."
n "Tell me, what were you doing on the spaceship travelling to A1 again?"
menu:
"I work as a mechanist.":
python:
player.skills.append(['Mechanics', 3])
"I work as a pilot.":
python:
player.skills.append(['IT', 3])
"I'm a botanist.":
python:
player.skills.append(['Knowledge on Animals & Plants', 3])
"I'm a linguist.":
python:
player.skills.append(['Research', 3])
"I'm a soldier.":
python:
player.skills.append(['Shooting', 3])
"I work as a janitor.":
python:
player.skills.append(['Planning Ahead', 3])
"I'm the vicecaptain!":
python:
player.skills.append(['Persuasion', 3])
"I work as a diplomat.":
python:
player.skills.append(['Diplomacy', 3])
"Uhm... I just snug onboard...":
python:
player.skills.append(['Hiding & Sneeking', 3])
n "Oh, really?"
n "I'm a bit speechless about that..."
n "Ehm..."
n "Forget about about the space journey and your job for a moment."
n "What was you favorite hobby as child?"
menu:
"Knowledge on Animals & Plants" if homeworld == "planet":
$ player.skills.append(['Knowledge on Animals & Plants', 1])
"Fencing" if homeworld == "planet":
$ player.skills.append(['Fencing', 1])
"Fistfighting" if homeworld == "planet":
$ player.skills.append(['Fistfighting', 1])
"Hunting" if homeworld == "planet":
$ player.skills.append(['Hunting', 1])
"Discovery" if homeworld == "planet":
$ player.skills.append(['Discovery', 1])
"Charisma" if homeworld == "planet":
$ player.skills.append(['Charisma', 1])
"Planning Ahead" if homeworld == "spaceship":
$ player.skills.append(['Planning Ahead', 1])
"Knowledge on certain costumes" if homeworld == "spaceship":
$ player.skills.append(['Knowledge on certain costumes', 1])
"Evasion" if homeworld == "spaceship":
$ player.skills.append(['Evasion', 1])
"Diplomacy" if homeworld == "spaceship":
$ player.skills.append(['Diplomacy', 1])
"Handling Shock or Trauma" if homeworld = "spaceship":
$ player.skills.append(['Handling Shock or Trauma', 1])
"Shooting" if homeworld == "spaceship":
$ player.skills.append(['Shooting', 1])
"Mechanics" if homeworld == "Moon Dome":
$ player.skills.append(['Mechanics', 1])
"MartialArts" if homeworld == "Moon Dome":
$ player.skills.append(['MartialArts', 1])
If you look at the traceback and the description of the error, it usually points to the specific line number where the error occurred. In the first case it was in line 263 of your script.rpy file. If you use a text editor like Atom you can see the lines numbered usually to the left to help you quickly locate what is causing the problem.