If I want to keep track of something in my game as a number and add and subtract from it what is the proper method? Would this be right?
$ dex = 10
menu exercise:
"dance":
$ dex = dex + 3
"walk":
$ dex = dex + 1
"sit and watch people":
$ dex = dex - 2
Would that set dex to 13, 11 and 8 respectively? Or will it just give me a bunch of errors? If it won't work what's the proper format?
Thank you,
-M
How do I track points?
Forum rules
Ren'Py specific questions should be posted in the Ren'Py Questions and Annoucements forum, not here.
Ren'Py specific questions should be posted in the Ren'Py Questions and Annoucements forum, not here.
-
- Newbie
- Posts: 6
- Joined: Tue Jun 05, 2007 8:19 am
- Contact:
- PyTom
- Ren'Py Creator
- Posts: 16096
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
That'll work when indented properly:
Code: Select all
$ dex = 10
menu exercise:
"dance":
$ dex = dex + 3
"walk":
$ dex = dex + 1
"sit and watch people":
$ dex = dex - 2
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
That woudl work, you could use this also. It does exactly the same thing so it's just a matter of preference
$ dex = 10
menu exercise:
"dance":
$ dex += 3
"walk":
$ dex += 1
"sit and watch people":
$ dex -= 2
and you'll get the same effect.
On another note if you ever want to check the value in game you can use this in the game and it will read out the value as dialoge.
so for example
$ dex = 10
menu exercise:
"dance":
$ dex += 3
"walk":
$ dex += 1
"sit and watch people":
$ dex -= 2
and you'll get the same effect.
On another note if you ever want to check the value in game you can use this in the game and it will read out the value as dialoge.
Code: Select all
'%(variablename)s'
Code: Select all
'I have %(dex)s points'
-
- Newbie
- Posts: 6
- Joined: Tue Jun 05, 2007 8:19 am
- Contact:
It's a quirk of HTML - which web pages are marked up in - that any amount of whitespace in the source document is displayed as a single breaking space when rendered. This allows people to write indented and easy-to-edit HTML without it looking weird when people see the document.m_evergreen wrote:Thank you PyTom, I thought I'd indented it but my spaces disappeared when I posted.
Thus, if you want to display carefully spaced text (such as indented code) on the web you need to use something like the 'preformatted text' element (<pre>), which is accessed on the forum using the 'code' tag.
Server error: user 'Jake' not found
-
- Eileen-Class Veteran
- Posts: 1153
- Joined: Mon Jul 07, 2003 4:57 pm
- Completed: Elven Relations, Cloud Fairy, When I Rule The World
- Tumblr: alextfish
- Skype: alextfish
- Location: Cambridge, UK
- Contact:
Just to note: the code Guest provided is used for string variables. For numeric variables, you need to use this version:
- the "d" is short for "decimal". But actually you often won't need that, for internal counters - you can include any amount of Ren'Py code in the branches of your "if" statement, including "jump"s to special bonus bits of script
Code: Select all
'%(variablename)d'
I released 3 VNs, many moons ago: Elven Relations (IntRenAiMo 2007), When I Rule The World (NaNoRenO 2005), and Cloud Fairy (the Cute Light & Fluffy Project, 2009).
More recently I designed the board game Steam Works (published in 2015), available from a local gaming store near you!
More recently I designed the board game Steam Works (published in 2015), available from a local gaming store near you!
Who is online
Users browsing this forum: No registered users