### do/every every time until condition becomes true[closed]

#### greatanthony

• Posts: 166
In screenshot of game below...floor blocks and pine blocks are randomly generated , so when there is hard difficulty , a stage arrives when there are only pine blocks, since when ball dies it needs to be created on a floor block. so how to let computer create ball even after 2 hours a floor block appears.

I tried this but this is not working....

« Last Edit: January 11, 2017, 09:40:08 pm by greatanthony »

#### morphman86

• Posts: 141
Do you have more than one ball? Because if I break down that code, what I see is this:

1) Check how many balls are on the scene
2) For each of those balls, do this:
2a) Check if health is above or exactly zero
2b) Create a new ball until a ball exists

In other words, you're checking all alive balls on the scene and for each of those balls, you're checking if they are alive, and if they are not, create a ball.
It's a circular logic that won't work. For a ball to be created, there has to be no balls alive and for balls to be alive, there has to be balls created.

That's at least how I understand your code.

#### greatanthony

• Posts: 166
yes that code doesn't work....( hope you saw screenshots)
and game logic is that : constantly new floor and pine blocks appear...
there is only one ball alive....if it dies it gets created at the lowest floor block available(if no. of lives is above 0 )...but in case it dies and and no. of lives is above 0 and no floor block available ..then what to do??

#### morphman86

• Posts: 141
First off, I just want to point out that you're checking if number of lives is above -1, not 0, since you're using the "greater than or equal to" sign instead of just the "greater than" sign.

If that part of the code does what you want it to do, great. That just means I've misunderstood the logic.

But right now, I don't see much of the floor generation, so I can't tell you where you went wrong with ensuring there's a floor there.

As for the ball generation logic, what I see is this:

You have to have balls active to go through in the foreach block.
If you have balls active, the "repeat until alive" won't trigger at all, since alive and active is the same for the programming purposes.
That means no ball will be created, because there is either already a ball alive, so the "repeat until" block won't trigger, or there is no ball active, so the "for each of type ball" won't trigger.

As for the issue with not having a lowest floor, you could just make sure there's always a floor at the bottom.  Maybe a very short one, that you can use as a starting position of each stage.

#### greatanthony

• Posts: 166
sorry...since i'm new all of it went above my head..... all i want to tell is everything works fine..except that [repeat until]
COULD YOU THINK/SUGGEST ANY WAY THAT WHEN BALL DIES AND IS ELIGIBLE TO BE CREATED AGAIN BUT NO FLOOR BLOCK IS AVAILABLE THEN HOW TO LET COMPUTER WAIT UNTIL FOR A FLOOR BLOCK TO ARRIVE, SO THAT IT CAN CREATE A BALL?

#### shatrugansinha

• Posts: 1
[as ball dies] ===== [your function of creating ball]
(this function will run only once)

so you need to somehow run this function until ball gets recreated.....

• Posts: 166

#### morphman86

• Posts: 141
Right now you're checking if a ball is alive, and if it is, create a ball.

The "Actor of Type" block in your "Repeat until" block is of the type Ball, since it's inside the "Foreach Actor of Type" block for the ball.

I'm also not sure "Repeat Until" is what you want right here. You can switch the "Actor of Type" block out for the variable "Lowest Floor" (if that is an actor), but that will just generate balls over and over again until there's a floor, which will cause an error because it doesn't have a floor to put it on.

What I would suggest is that you do the following (my screen resolution is odd, so I had to copy-paste a lot):

Hope that helped

#### greatanthony

• Posts: 166
[ sorry.... electricity went out in my town...... but i'm lucky today was a 30-minute cut....]

a lots and lots thanks......( you have suggested a solution on an issue which is frustrating me from many days!!)
please clear my doubts regarding this....
1)floor list is list? and floor is actor type ?
2)if [ball] is actor then how to put value of [ball] since that specific actor could not be alive at that time because before that some balls could be created.( depending upon lives)

« Last Edit: January 11, 2017, 08:25:50 am by greatanthony »

#### morphman86

• Posts: 141
After Create [ball] you can put a setter block for the attribute Ball.

Set Ball to Last Created Actor.

#### greatanthony

• Posts: 166
thanks but i tried that but it raise wrong since new floor and pine blocks are created every 2 second from bottom.....so sometime it takes [ball] to be [floor block]

#### greatanthony

• Posts: 166
sorry it's getting more and more complex.....

« Last Edit: January 11, 2017, 09:13:12 am by greatanthony »

#### morphman86

• Posts: 141
If you set the ball to Last Created Actor right after Create Ball, in the same IF block, the last created actor should be the ball, every time.