Page 1 of 1

Loop statement not working.

Posted: Sat Sep 16, 2017 9:05 am
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

Re: Loop statement not working.

Posted: Sat Sep 16, 2017 11:09 am
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")

Re: Loop statement not working.

Posted: Sat Sep 16, 2017 3:15 pm
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.

Re: Loop statement not working.

Posted: Sun Sep 17, 2017 4:54 am
by Fealow
This seems to have done the job i think. thanks.

Edit: miss communication between myself and the coder.

Re: Loop statement not working.

Posted: Sun Sep 17, 2017 8:49 am
by Fealow
Caused a crash

Re: Loop statement not working.

Posted: Sun Sep 17, 2017 9:06 am
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.

Re: Loop statement not working.

Posted: Sun Sep 17, 2017 9:22 am
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!