Duplicating identical images for a sewing minigame [SOLVED]

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
strikerofchords
Newbie
Posts: 1
Joined: Tue Apr 15, 2025 10:24 pm
Contact:

Duplicating identical images for a sewing minigame [SOLVED]

#1 Post by strikerofchords »

Hello! I'm a relative newbie at programming and Ren'Py, so my apologies if this is a silly question and/or my code is totally janky. I am currently trying to program a very simplistic sewing minigame where the player follows a sequence of commands to create a bunch of stitches. I'm able to get the sequence and key-presses to go just fine, but my issue comes with displaying a trail of completed stitches behind where the needle and thread are currently. The most I've been able to get is a singular stitch to appear in the previous position, but it simply moves as soon as the show command is re-triggered. Here's the code (apologies if I attach too much or too little, it's my first time making a post like this on here):

Code: Select all

default step = 0		# Tracks which step the player is currently at
default stitchxPos = 1200		# xPosition of the needle
default stitchList1 = ["U","R","L","U","R","L","U","R","L"] # The sequence of stitches

label loopback:
        if step < len(stitchList):
            $ currentStep = stitchList[step]
            $ print(currentStep)
            if currentStep=="U":
                show Needle1 Up at needleThread
                show Point Up at truecenter
                call screen sewingMinigame("up")
            elif currentStep=="R":
                show Needle1 Right at needleThread
                show Point Right at truecenter
                call screen sewingMinigame("right")
            elif currentStep=="L":
                show Needle1 Left at needleThread
                show Point Left at truecenter
                call screen sewingMinigame("left")
            screen sewingMinigame(direction):
                key ("input_"+direction) action Call("miniContinue")
            label miniContinue:
                if currentStep=="U":
                    show stitchDone at needleThread # This is my working solution to my issue
                    $ stitchxPos += -80
                $ step+=1
                jump loopback
        else:
            hide Point
            hide Needle
            return
I know that the show function isn't ideal for solving this problem, but when I used the add function from the screens it failed to loop back, and I couldn't wrap my head around SpriteManagers. I haven't been able to find anyone else in the same scenario as me, so if anyone could help me figure out how to create a trail of duplicate images, I would appreciate it.
Last edited by strikerofchords on Tue May 06, 2025 3:45 pm, edited 1 time in total.

User avatar
jeffster
Eileen-Class Veteran
Posts: 1228
Joined: Wed Feb 03, 2021 9:55 pm
Contact:

Re: Duplicating identical images for a sewing minigame

#2 Post by jeffster »

strikerofchords wrote: Thu Apr 17, 2025 4:35 pm I know that the show function isn't ideal for solving this problem, but when I used the add function from the screens it failed to loop back
With any approach (`show` or `add` or even using cdd) you have to use a cycle to draw all stitches from number 0 to the last one. Something like (show screen ...)

Code: Select all

for i in range(0, step):
    add <the image of the stitch number i>
Then adding another stitch you'll increase `step` and the screen would show the stitches again, with one more.
If the problem is solved, please edit the original post and add [SOLVED] to the title. 8)
All my tutorials, code samples etc. are Public Domain: use them with no restrictions.

User avatar
Andredron
Miko-Class Veteran
Posts: 826
Joined: Thu Dec 28, 2017 2:37 pm
Location: Russia
Contact:

Re: Duplicating identical images for a sewing minigame

#3 Post by Andredron »

Renpy textbook (in Russian). https://disk.yandex.ru/i/httNEajU7iFWHA (all information is out of date) Update 22.06.18

Sawa - a game of the Drow Nation

Honest Critique

Poses in visual novels, or how to hold a character properly in the frame

Help save articles to the webarchive. [/color]

Please save your projects on github, you would know how hard it is to find projects after 7 years...

User avatar
jeffster
Eileen-Class Veteran
Posts: 1228
Joined: Wed Feb 03, 2021 9:55 pm
Contact:

Re: Duplicating identical images for a sewing minigame

#4 Post by jeffster »

PS. Another reference about
strikerofchords wrote: Thu Apr 17, 2025 4:35 pm a sequence of commands to create a bunch of stitches.
- an example of doing that with CDD:
viewtopic.php?t=68969

You might prefer usual images instead of CDDs, but using the "for" loop etc. can be the same.
If the problem is solved, please edit the original post and add [SOLVED] to the title. 8)
All my tutorials, code samples etc. are Public Domain: use them with no restrictions.

Post Reply