How do I track points?

A place to discuss things that aren't specific to any one creator or game.
Forum rules
Ren'Py specific questions should be posted in the Ren'Py Questions and Annoucements forum, not here.
Post Reply
Message
Author
m_evergreen
Newbie
Posts: 6
Joined: Tue Jun 05, 2007 8:19 am
Contact:

How do I track points?

#1 Post by m_evergreen » Tue Jun 05, 2007 10:21 am

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

User avatar
PyTom
Ren'Py Creator
Posts: 15478
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:

#2 Post by PyTom » Tue Jun 05, 2007 10:40 am

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
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

Guest

#3 Post by Guest » Tue Jun 05, 2007 10:40 am

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.

Code: Select all

'%(variablename)s'
so for example

Code: Select all

'I have %(dex)s points'

m_evergreen
Newbie
Posts: 6
Joined: Tue Jun 05, 2007 8:19 am
Contact:

#4 Post by m_evergreen » Tue Jun 05, 2007 11:23 am

Thank you PyTom, I thought I'd indented it but my spaces disappeared when I posted. But I've forgotten to indent properly several times since starting to use Ren'Py, and the colons...

Thank you too Guest, that's great to know! I'm pretty sure I'll need your other code as well.

-M

User avatar
Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

#5 Post by Jake » Tue Jun 05, 2007 12:32 pm

m_evergreen wrote:Thank you PyTom, I thought I'd indented it but my spaces disappeared when I posted.
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.

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

User avatar
chronoluminaire
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:

#6 Post by chronoluminaire » Tue Jun 05, 2007 12:59 pm

Just to note: the code Guest provided is used for string variables. For numeric variables, you need to use this version:

Code: Select all

'%(variablename)d'
- 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 :)
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!

Post Reply

Who is online

Users browsing this forum: No registered users