Loop statement not working.

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
Fealow
Newbie
Posts: 9
Joined: Sat Sep 16, 2017 8:56 am
Contact:

Loop statement not working.

#1 Post by Fealow »

So I have this code here:

Code: Select all

if not renpy.music.get_playing(channel='music') == "out_and_about.ogg": 
     imagebutton auto "gui mainmap%s" xpos 0 ypos 0 focus_mask True action [Play("music", loop=1.777, "out_and_about.ogg"), Jump("lbl_townmap_setup")
else:
      imagebutton auto "gui mainmap%s" xpos 0 ypos 0 focus_mask True action Jump("lbl_townmap_setup")
the problem is that the "loop=1.777" part is not working, seems like its being ignored.

The idea is that this track will play when the player hits the map button and continues to play without stopping if the player transistions to another location that uses the same music file or if they hit the map button again. All of the code that does that is working fine, but in this particular part of the code the loop statement is just not doing anything.

Any thoughts?

Thanks

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: Loop statement not working.

#2 Post by Divona »

Look like "loop" is taking Boolean instead of value.

Code: Select all

loop
    If this is True, the tracks will loop while they are the last thing in the queue.
Instead, do this:

Code: Select all

if not renpy.music.get_playing(channel='music') == "out_and_about.ogg": 
    imagebutton auto "gui mainmap%s" xpos 0 ypos 0 focus_mask True action [Play("music", "<loop=1.777>out_and_about.ogg"), Jump("lbl_townmap_setup")
else:
    imagebutton auto "gui mainmap%s" xpos 0 ypos 0 focus_mask True action Jump("lbl_townmap_setup")
Completed:
Image

Fealow
Newbie
Posts: 9
Joined: Sat Sep 16, 2017 8:56 am
Contact:

Re: Loop statement not working.

#3 Post by Fealow »

Divona wrote: Sat Sep 16, 2017 11:09 am Look like "loop" is taking Boolean instead of value.

Code: Select all

loop
    If this is True, the tracks will loop while they are the last thing in the queue.
Instead, do this:

Code: Select all

if not renpy.music.get_playing(channel='music') == "out_and_about.ogg": 
    imagebutton auto "gui mainmap%s" xpos 0 ypos 0 focus_mask True action [Play("music", "<loop=1.777>out_and_about.ogg"), Jump("lbl_townmap_setup")
else:
    imagebutton auto "gui mainmap%s" xpos 0 ypos 0 focus_mask True action Jump("lbl_townmap_setup")
Ah I see! Thank you for the suggestion and supplying a possible fix. I'll give it a try when I can and will post back at a later date.

Fealow
Newbie
Posts: 9
Joined: Sat Sep 16, 2017 8:56 am
Contact:

Re: Loop statement not working.

#4 Post by Fealow »

This seems to have done the job i think. thanks.

Edit: miss communication between myself and the coder.
Last edited by Fealow on Sun Sep 17, 2017 8:53 am, edited 2 times in total.

Fealow
Newbie
Posts: 9
Joined: Sat Sep 16, 2017 8:56 am
Contact:

Re: Loop statement not working.

#5 Post by Fealow »

Caused a crash
Last edited by Fealow on Sun Sep 17, 2017 9:22 am, edited 2 times in total.

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: Loop statement not working.

#6 Post by Divona »

It works perfectly fine on a new project. Do check that it's not somewhere else that causing the problem. You could drop the traceback and a code here and I'll see what went wrong.
Completed:
Image

Fealow
Newbie
Posts: 9
Joined: Sat Sep 16, 2017 8:56 am
Contact:

Re: Loop statement not working.

#7 Post by Fealow »

SOLVED

there was a stray = in the code that caused problems and we needed to put the loop in the if statement as well.

Thanks for your assistance!

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Kocker