[SOLVED]Dynamic Generating Grid

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
WhisperedLullaby
Newbie
Posts: 2
Joined: Sun Jan 07, 2018 8:06 pm
Contact:

[SOLVED]Dynamic Generating Grid

#1 Post by WhisperedLullaby »

I'm currently learning Ren'Py so please excuse me if this is not a great question.

I'm making a custom screen to display something. What it is, isn't really that important as I'm just 'playing' around, but I seem to be doing something incorrectly.

I want to create a grid inside a frame that dynamically generates. What I have so far is this:

Code: Select all

screen ok_collected: 
    tag menu

    add Movie(size=(1920, 1080))
    on "show" action Play("movie", "movies/bg_static.webm", loop=True)
    on "hide" action Stop("movie")
    on "replace" action Play("movie", "movies/bg_static.webm", loop=True)
    on "replaced" action Stop("movie")

    frame: 
        style "collected_frame"
        xpadding 100
        ypadding 100
        xalign 0.5
        yalign 0.5
        
        
        $ i = 0
        $ x = 24
        $ yGrid = x / 6
        grid 6 yGrid spacing 100:
            while $ i > $ x:
                imagebutton auto "images/button_%s.png" focus_mask None action ShowMenu('load')
                $ i += 1



    textbutton _("Return"):
        style "return_button"

        action Return()

style collected_frame:
    background Frame("images/frame_bg.jpg")
Manually placing the 24 buttons in, of course, works however when using this code it gives me the error:

Code: Select all

I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.


File "game/collected.rpy", line 22: u'while' is not a keyword argument or valid child for the grid statement.
    while $ i > $ x:
         ^

Ren'Py Version: Ren'Py 6.99.13.2919
Fundamentally I must have something wrong, but I can't seem to find anything in the documentation or in the cookbook links here on the forums. Any insight into this would be greatly appreciated.
Last edited by WhisperedLullaby on Sun Jan 07, 2018 9:12 pm, edited 1 time in total.

philat
Eileen-Class Veteran
Posts: 1910
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Dynamic Generating Grid

#2 Post by philat »

The error message is telling you. While is not a valid statement in screen language. You also shouldn't include the $ sign in the statement. $ sign means the LINE is a python statement.

Code: Select all

        default i = 0
        default x = 24
        default yGrid = x / 6
        grid 6 yGrid spacing 100:
            for i in range(x):
                imagebutton auto "images/button_%s.png" focus_mask None action ShowMenu('load')

WhisperedLullaby
Newbie
Posts: 2
Joined: Sun Jan 07, 2018 8:06 pm
Contact:

Re: Dynamic Generating Grid

#3 Post by WhisperedLullaby »

Thank you so much! This helped with understanding the syntax a lot. I appreciate the help!

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]