Print command and Ren'Py

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
Argeus_the_Paladin
Veteran
Posts: 264
Joined: Sat Feb 26, 2011 9:36 am
Projects: Rzeczpospolita Polska 1647
Location: Κωνσταντινούπολη, Βασιλεύα των Ρωμαύων
Contact:

Print command and Ren'Py

#1 Post by Argeus_the_Paladin »

I have a quick question: Is the Python print command usable in Ren'Py?

Thanks beforehands!
One Province Minor - 120 class variables and still counting!

Because there is no such thing as too many variables.

User avatar
Alex
Lemma-Class Veteran
Posts: 3093
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Print command and Ren'Py

#2 Post by Alex »

If you mean <print> command that shows text onscreen, then in Ren'Py it will be <text> command or its equivalent <ui.text()>
http://www.renpy.org/doc/html/text.html ... isplayable
http://www.renpy.org/wiki/renpy/doc/reference/Text

Argeus_the_Paladin
Veteran
Posts: 264
Joined: Sat Feb 26, 2011 9:36 am
Projects: Rzeczpospolita Polska 1647
Location: Κωνσταντινούπολη, Βασιλεύα των Ρωμαύων
Contact:

Re: Print command and Ren'Py

#3 Post by Argeus_the_Paladin »

Not sure if that's what I'm looking for.

The situation here is that I need to combine the for statement with the if clause and use it as a condition to display text. The problem is, to use an if clause in a for statement I have to use a python block, which pretty much negates the entire standard Ren'Py dialogue display.

The question above is what I thought could have been a workaround if it existed. Any tips will be very welcome.
One Province Minor - 120 class variables and still counting!

Because there is no such thing as too many variables.

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

Re: Print command and Ren'Py

#4 Post by PyTom »

Yes, it works, although it's somewhat hard to see the output.

On linux, run your game on the command line, and the output goes to the command line. On windows, drag your game to console.exe, and you can see the output. Not sure about mac.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Argeus_the_Paladin
Veteran
Posts: 264
Joined: Sat Feb 26, 2011 9:36 am
Projects: Rzeczpospolita Polska 1647
Location: Κωνσταντινούπολη, Βασιλεύα των Ρωμαύων
Contact:

Re: Print command and Ren'Py

#5 Post by Argeus_the_Paladin »

Hmm... seems that it isn't a good workaround then. I'll try to fins another way.

Thanks anyway.
One Province Minor - 120 class variables and still counting!

Because there is no such thing as too many variables.

User avatar
Alex
Lemma-Class Veteran
Posts: 3093
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Print command and Ren'Py

#6 Post by Alex »

Could you show your code? 'Cause you can use <renpy.say(e, "Hello world!")> in python block.

Argeus_the_Paladin
Veteran
Posts: 264
Joined: Sat Feb 26, 2011 9:36 am
Projects: Rzeczpospolita Polska 1647
Location: Κωνσταντινούπολη, Βασιλεύα των Ρωμαύων
Contact:

Re: Print command and Ren'Py

#7 Post by Argeus_the_Paladin »

I have found a simpler workaround that does not have to involve the for statement. Thanks for the suggestion anyway! I'm sure it will be of use later on.
One Province Minor - 120 class variables and still counting!

Because there is no such thing as too many variables.

Argeus_the_Paladin
Veteran
Posts: 264
Joined: Sat Feb 26, 2011 9:36 am
Projects: Rzeczpospolita Polska 1647
Location: Κωνσταντινούπολη, Βασιλεύα των Ρωμαύων
Contact:

Re: Print command and Ren'Py

#8 Post by Argeus_the_Paladin »

Sorry, I take back the last statement. My workaround did not work.

Here's the code in question:

Code: Select all

                python:
                    for ore in mine1.available_ore:
                        if ore.ore_mined:
                           "You mined some [ore.ore_item.name]."
                            successful_mining = True
                        else:
                            pass
                
What I want to achieve is to pop up a message announcing that the player has mined every ore that she has mined, but only if she has successfully mined it. I cannot find find any alternative to that after much brainstorming. That, and the renpy.say command apparently returned a "syntax error" message.
One Province Minor - 120 class variables and still counting!

Because there is no such thing as too many variables.

User avatar
Alex
Lemma-Class Veteran
Posts: 3093
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Print command and Ren'Py

#9 Post by Alex »

Hm, <renpy.say> should work (it will look like character talking about mined ore) - what's the actual code you used?
Also, you might mess with tooltips - http://www.renpy.org/doc/html/screen_ac ... l#tooltips
Or you could make a screen, that has text line "You mined some [my_text_var]." and show it with different values of
"my_text_var". http://www.renpy.org/doc/html/screen_py ... -functions

Code: Select all

screen my_scr:
    tag my_scr
    zorder 100

    key "mouseup_1" action Return("smth")
    
    default my_text_var = "dirt"

    frame:
        background Frame("my_frame_bg.png", 7, 7)
        xminimum 200 xmaximum 200
        yminimum 100 ymaximum 100
        xalign 0.5 yalign 0.5

        vbox:
            xfill True
            text "You mined some [my_text_var]." xalign 0.5
            null height 30
            text "Click to continue" size 10 xalign 1.0

label start:
    $ available_ore = ["gold", "iron", "silver"]
    "..."
    python:
        for ore in available_ore:
            renpy.call_screen("my_scr", my_text_var=ore)

    "...?"

Argeus_the_Paladin
Veteran
Posts: 264
Joined: Sat Feb 26, 2011 9:36 am
Projects: Rzeczpospolita Polska 1647
Location: Κωνσταντινούπολη, Βασιλεύα των Ρωμαύων
Contact:

Re: Print command and Ren'Py

#10 Post by Argeus_the_Paladin »

Here's the code I tried:

Code: Select all

             python:
                    for ore in mine1.available_ore:
                        if ore.ore_mined:
                            <renpy.say("You mined some [ore.ore_item.name].")>
                            successful_mining = True
                        else:
                            pass
and

Code: Select all

            python:
                    for ore in mine1.available_ore:
                        if ore.ore_mined:
                            <renpy.say>("You mined some [ore.ore_item.name].")
                            successful_mining = True
                        else:
                            pass
Both result in a syntax error.
One Province Minor - 120 class variables and still counting!

Because there is no such thing as too many variables.

User avatar
Alex
Lemma-Class Veteran
Posts: 3093
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Print command and Ren'Py

#11 Post by Alex »

Khm, you don't need < and > in your code :oops: (I used them in my post instead of code-tag, sorry for misleading you).

Argeus_the_Paladin
Veteran
Posts: 264
Joined: Sat Feb 26, 2011 9:36 am
Projects: Rzeczpospolita Polska 1647
Location: Κωνσταντινούπολη, Βασιλεύα των Ρωμαύων
Contact:

Re: Print command and Ren'Py

#12 Post by Argeus_the_Paladin »

Ah, that solves it. Looks like it works now.

Thanks again!
One Province Minor - 120 class variables and still counting!

Because there is no such thing as too many variables.

Post Reply

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot]