Ren-Py Question

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
Enerccio
Miko-Class Veteran
Posts: 616
Joined: Thu Oct 26, 2006 4:23 pm
Projects: My Teacher; Songs of Araiah; Something new; Possible Cross Bomber?
Location: Slovakia, Kosice
Contact:

Ren-Py Question

#1 Post by Enerccio » Fri Oct 27, 2006 2:03 pm

How do you make random number in renpy?

And can you create something like CCG room where players can see al images he unlocked?

And why changes i made to code are not visible or nothing? :shock: :shock: :shock:

User avatar
Enerccio
Miko-Class Veteran
Posts: 616
Joined: Thu Oct 26, 2006 4:23 pm
Projects: My Teacher; Songs of Araiah; Something new; Possible Cross Bomber?
Location: Slovakia, Kosice
Contact:

#2 Post by Enerccio » Fri Oct 27, 2006 3:20 pm

Noone will help? Looks like it isnt compiling my scripts, how can i compile scripts? :(

User avatar
DaFool
Lemma-Class Veteran
Posts: 4171
Joined: Tue Aug 01, 2006 12:39 pm
Contact:

#3 Post by DaFool » Fri Oct 27, 2006 3:37 pm

All the text files that end with .rpy in the /game directory (/demo/game in 5.6.2) are automatically compiled into .rpyc files when you launch the game.

You can find CG gallery code in the /extras directory, if I remember correctly. Just copy the .rpy file into /game, and modify as you please.

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

#4 Post by Jake » Fri Oct 27, 2006 3:56 pm

Enerccio wrote:Noone will help?
Hey, hey, calm down - maybe no-one saw your post yet... ;-)
Enerccio wrote:How do you make random number in renpy?
It depends what kind of random number you want. In programmer's terms, the renpy.random object implements the Python random interface.

In layman's terms, by way of example, if you want a random whole number between 1 and 6, for example, you can write code like this:

Code: Select all

    "I roll the die..."
    
    $ dieRoll = renpy.random.randint(1,6)
    
    "Looks like I rolled a %(dieRoll)s..."
Enerccio wrote:And can you create something like CCG room where players can see al images he unlocked?
It's certainly more than possible...

There's a gallery.rpy file in the extras directory. Copy it into the /demo/game subdirectory of where you installed Ren'Py, then run the demo for an example of how one might set such a gallery up.
Enerccio wrote:And why changes i made to code are not visible or nothing?
...
Looks like it isnt compiling my scripts, how can i compile scripts? :(
Firstly, make sure you're editing the right file - going through the launcher should make sure of this, of course - add your new code to the end of the game.rpy file that it opens when you hit 'Edit Script'. Make sure that you're saving the file before launching to make sure that Ren'Py is using the right version of the script.

If that's where you're editing and what you're doing, then there's one thing that's worth a check - go into the subfolder of Ren'Py that has the same name as your project, then into the 'game' subfolder, and delete any file with the extension .rpyc (noting the 'c' on the end).
- sometimes, Ren'Py seems to not notice that scripts have changed since the last time it compiled them. The 'rpyc' files are the compiled versions of the .rpy scripts, so deleting them forces Ren'Py to recompile from the source scripts.

If the compiled versions don't appear when you run Ren'Py, you might have the wrong project selected in the launcher, or be looking at the wrong directory.
Server error: user 'Jake' not found

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

#5 Post by PyTom » Fri Oct 27, 2006 3:57 pm

Please give people more then an hour and a half to respond to your requests. Some of us have day jobs, and we're all doing this for free, so we can't give immediate support.

Are you editing script.rpy, saving it, and then re-launching Ren'Py? That's how you get changes to show up. If that's not working for some reason, you may want to try deleting the .rpyc files in your game directory.

To generate a random integer, you use renpy.random.randint. For example, to generate a random integer that will be 1, 2, 3, or 4, you can do:

Code: Select all

$ result = renpy.random.randint(1, 2, 3, 4)
Note that you often want to use renpy.random.choice instead, as it lets you pick a random string from a list... which you could then jump to. Example:

Code: Select all

$ target = renpy.random.choice(["likely", "likely", "likely", "unlikely"])
jump expression target
DaFool mentioned the gallery script, although that's a more advanced usage. (So be sure you get regular old Ren'Py working before trying out the gallery.)

Jake's example should read %(dieRoll)d rather than %(dieRoll)s, just due to some typing issues.
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

User avatar
Enerccio
Miko-Class Veteran
Posts: 616
Joined: Thu Oct 26, 2006 4:23 pm
Projects: My Teacher; Songs of Araiah; Something new; Possible Cross Bomber?
Location: Slovakia, Kosice
Contact:

#6 Post by Enerccio » Fri Oct 27, 2006 6:15 pm

Ok so i try to copile this

Code: Select all

    # Declare images used by this game.
    image city1 = "#c0c0c0"
    image airport = "#c0c0c2"

    # Declare characters used by this game.
    $ p = Character('Mike Stood', color="#c8ffc8")
    $ ga1 = Character('Hot Passport checker', color="#c8ffff")


# The game starts here.
label start:

    scene airport

    p "Finaly in Japan."

    p "My name is Mike Stood and i have been choosen for the exchange program to Japan high school."
    
    ga1 "."

and got this:

Code: Select all

I'm sorry, but an exception occured while executing your Ren'Py
script.

ParseError: On line 12 of c:\Documents and Settings\Enerccio\Desktop\renpy-5.6.2-full\renpy-5.6.2\Exchange Student/game/script.rpy: indentation mismatch.

While parsing c:\Documents and Settings\Enerccio\Desktop\renpy-5.6.2-full\renpy-5.6.2\Exchange Student/game/script.rpy.

-- Full Traceback ------------------------------------------------------------

  File "C:\Documents and Settings\Enerccio\Desktop\renpy-5.6.2-full\renpy-5.6.2\renpy\bootstrap.py", line 164, in bootstrap
  File "C:\Documents and Settings\Enerccio\Desktop\renpy-5.6.2-full\renpy-5.6.2\renpy\main.py", line 162, in main
  File "C:\Documents and Settings\Enerccio\Desktop\renpy-5.6.2-full\renpy-5.6.2\renpy\script.py", line 392, in load_script
  File "C:\Documents and Settings\Enerccio\Desktop\renpy-5.6.2-full\renpy-5.6.2\renpy\script.py", line 138, in __init__
  File "C:\Documents and Settings\Enerccio\Desktop\renpy-5.6.2-full\renpy-5.6.2\renpy\script.py", line 261, in load_file
  File "C:\Documents and Settings\Enerccio\Desktop\renpy-5.6.2-full\renpy-5.6.2\renpy\script.py", line 204, in load_file_core
  File "C:\Documents and Settings\Enerccio\Desktop\renpy-5.6.2-full\renpy-5.6.2\renpy\parser.py", line 1344, in parse
  File "C:\Documents and Settings\Enerccio\Desktop\renpy-5.6.2-full\renpy-5.6.2\renpy\parser.py", line 242, in group_logical_lines
  File "C:\Documents and Settings\Enerccio\Desktop\renpy-5.6.2-full\renpy-5.6.2\renpy\parser.py", line 230, in gll_core
ParseError: On line 12 of c:\Documents and Settings\Enerccio\Desktop\renpy-5.6.2-full\renpy-5.6.2\Exchange Student/game/script.rpy: indentation mismatch.

While parsing c:\Documents and Settings\Enerccio\Desktop\renpy-5.6.2-full\renpy-5.6.2\Exchange Student/game/script.rpy.

Ren'Py Version: Ren'Py 5.6.2a
Where is problem, in my code or somewhere else? :(

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

#7 Post by Jake » Fri Oct 27, 2006 6:55 pm

Enerccio wrote:

Code: Select all

ParseError: On line 12 of c:\Documents and Settings\Enerccio\Desktop\renpy-5.6.2-full\renpy-5.6.2\Exchange Student/game/script.rpy: indentation mismatch.
Where is problem, in my code or somewhere else? :(
It looks to be in your code... kinda. Python - and thus Ren'Py, which is based on Python - is rather picky about indentation; you have to use spaces to indent your lines, and you have to indent each line in the same 'block' by the same number of spaces. While the general layout of the sample you posted there looks OK, and if I copy and paste it into the template script here it runs fine, there's probably some extra space/s or tabs instead of spaces somewhere which the engine is picking up.

Open the editor, look at line 12, and double-check the indentation. It's probably easiest to delete all the empty space at the beginning of the line and replace it with space characters to the same depth as the surrounding block, just to be sure.

(Oh, and if you haven't got the 'init:' at the beginning, that won't help either...)




[EDIT: What would be really useful with these tracebacks would be if the error included the text of the line which generated the error...]
Server error: user 'Jake' not found

Post Reply

Who is online

Users browsing this forum: Google [Bot], _ticlock_