Outputting an integer count

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.
Post Reply
Message
Author
User avatar
verticalpoint
Newbie
Posts: 4
Joined: Sat Jul 16, 2011 12:55 am
Projects: <rakugakujun> - Japanese textbook accompaniment tool (WIP)
Contact:

Outputting an integer count

#1 Post by verticalpoint »

I am currently working on a game that is intended to be a learning aid for my university's Japanese program. However, due to my lack of experience with ren'py and the python language, I seem to have come upon a stumbling block in regards to how to display a count variable. I have done some research/testing in attempt to try and figure out the problem, but it seems I am truly stumped.

Here is an example of my code:

e "ジョシュさんは車を買いました。"

menu:

"はい、彼を買いました。":

jump batsu1

"いいえ、山田さんの車を借りました。":

jump maru1

label batsu1:
voice "chigaimasu.mp3"
e "この答えは間違いです。"
e "聞いて下さい。"

show josh at rpos
with move

show josh:
zoom 1.0
linear 0.5 zoom 1.10
pause 6.5
linear 0.5 zoom 1.0

voice "sjdemo_josh1.mp3"
j "ああ。隣の山田くんで貸してくれたんだ。山田くんが東京まで運転してくれるんだ。"

hide josh
with dissolve

#"{b}Correct:{/b} %(correct_count)."
python:
incorrect_count = incorrect_count +1;
renpy.say(e, "{b}Incorrect: {/b} %(incorrect_count).")
#"{b}Incorrect: {/b} %(incorrect_count)."

jump q2

So far, I have had the program compiled correctly, but when prompted to show the count, no numbers are displayed. This is the code after I tried to change the call for incorrect count, and it causes the game to crash.

Ideally, I would like to display a count for incorrect/correct answers (dynamically updated based on user's choice) outside of the character's dialogue (like a counter at the top of the screen) and allow for output of this information to a text file/pdf for instructor use.

Thank you in advance for any suggestions you may have. :)

Blue Lemma
Forum Founder
Posts: 2005
Joined: Sat Jan 25, 2003 2:32 pm
Completed: ToL, Shoujo Attack!, Lemma Ten
Projects: [RETIRED FROM FORUM ADMINISTRATION - CONTACT PYTOM WITH ISSUES]
Contact:

Re: Outputting an integer count

#2 Post by Blue Lemma »

I think you need to add an s after %(incorrect_count)

But I'm wondering why you made a "python" block instead of just making variables in Ren'Py :)

For instance, you can say:

Code: Select all

$ incorrect_count = 0
$ incorrect_count += 1
or whatever else and not have to use a python block. You will need the $ sign there when assigning the variables values.

As for the numerical display out of the textbox, you might be looking for DynamicDisplayables (anyone know an easier way?):
http://www.renpy.org/doc/html/displayab ... splayables
(see Ren'Py demo for more info)
“Among those who dislike oppression are many who like to oppress.”
- Napoleon Bonaparte


I've retired from forum administration. I do not add people to the "adult" group, deactivate accounts, nor any other administrative task. Please direct admin/mod issues to PyTom or the other mods : )

User avatar
Showsni
Miko-Class Veteran
Posts: 563
Joined: Tue Jul 24, 2007 12:58 pm
Contact:

Re: Outputting an integer count

#3 Post by Showsni »

For a display outside the textbox, you should just be able to set up a screen to do it.

Code: Select all

screen count:
    frame:
        vbox:
            text ("Correct Count: %d" % correct_count)
            text ("Incorrect Count: %d" % incorrect_count)
Then simpy show screen count when you want it to appear on screen, and hide screen count to remove it.

User avatar
verticalpoint
Newbie
Posts: 4
Joined: Sat Jul 16, 2011 12:55 am
Projects: <rakugakujun> - Japanese textbook accompaniment tool (WIP)
Contact:

Re: Outputting an integer count

#4 Post by verticalpoint »

Thank you for all of the information! Eventually after looking at some examples using ren'py code, I got it to output and keep track of the scores correctly. :D

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Duhop