2019-03-12 13:32:27 (edited by Zarvox 2019-03-12 13:32:56)

So,, if I tell bgt, at 6 seconds to play a sound, it will. However if I assign an integer value to 6000 and tell it to do the same thing, btt refuses to listen to it. Why is this?
if(clock==6000)
p.play_stationary("sounds/whatever.ogg",false);
that works, but this doesn't
if(clock==intvar)
p.play_stationary("sounds/whatever.ogg",false);
Also one more question, why does it not play the sound if I am actively pressing keys? If I want even the standard number to work I can't be pressing other keys or else the sound will not be played. Has anyone else experienced or solved these 2 issues?

I will be one day!

Thumbs up

2019-03-12 14:56:48

Hi,

we'd need more of your code to clearly identify your issue, but there already several things which are going wrong here.

Zarvox wrote:

So,, if I tell bgt, at 6 seconds to play a sound, it will. However if I assign an integer value to 6000 and tell it to do the same thing, btt refuses to listen to it. Why is this?
if(clock==6000)
p.play_stationary("sounds/whatever.ogg",false);

I don't know what clock actually is. Is it the result of a timer, so e.g. some_timer.elapsed? In that case, you should always check for a greater result as well, because it is very unlikely that someone or the program executes that command exactly at 6000 ms, its more likely to be executed somewhat above 6000. So, if(clock >= 6000) would be the correct condition here.

Zarvox wrote:

that works, but this doesn't
if(clock==intvar)
p.play_stationary("sounds/whatever.ogg",false);

We'd need more information about intvar. Which data type does it have? Did you initialize it with some value or is it just declared and thus 0?

Zarvox wrote:

Also one more question, why does it not play the sound if I am actively pressing keys? If I want even the standard number to work I can't be pressing other keys or else the sound will not be played. Has anyone else experienced or solved these 2 issues?

It is deffinitely your code to blame here, but since you didn't show that part to us, i'm unable to tell you anything. It is possible though and several games do that already, so more info could help to solve your problem.

Best Regards.
Hijacker

Thumbs up

2019-03-12 15:04:08

The clock variable is an integer that is set to increase every time a timer goes up 1 ms. The intvar  variable is just an integer, although I  I am using an array of values so it changes often.  What I would like it to do is play a sound, then read the next line of a file, then play the next sound, and repeat the process. It’s sort of does it but not very well
This is  part of my rhythm rage level creator project. I am having it play back the level, but it is very unreliable.  And I did try the greater equals method, but it only works with equals equals or else the sound will continue to play nonstop

I will be one day!

Thumbs up

2019-03-12 15:07:48

have a booliant that checks if the sound is still playing to stop it

best regards
never give up on what ever you are doing.

2019-03-12 15:36:09 (edited by Zarvox 2019-03-12 16:01:07)

So I did the grater than or equals method and it turns out to actually work. I never thought it did. However now the last action won't stop playing, so I will try destroying the sound pool after the last action. Update, I can either choose to have it play nonstop, have it play nonstop but be cut off, or not play at all. I do not have any slots assigned to the sounds. So I chose to just use the sound function for the last action and it works.

I will be one day!

Thumbs up

2019-03-12 18:09:20

no you don't increment a variable on timer tick, you check the timer directly. supposing that clock is an instance of the timer object, you could do:
if (clock.elapsed >= 6000)
{
  //code here
}

Doing what you do there is wasteful of CPU cycles.

I'm the captain of this ship,
don't worry about the little clicks,
Everything is working fine,
nevermind that audible whine.

Thumbs up