# Stopping the adding of a cube

Hi there.

Here I can not yet solve a simple problem - how to stop adding (moving) a cube, provided that one cube is already in this place? The conditions of the pulse mode are necessary.

example - cube_birth01.blend (474.4 KB)

Thank you for attention.

use a property?

``````if not 'cube_added' in own:
``````

As if the problem is … let’s say if an object overcomes a certain distance, a new cube was added to the new position, but only once. Probably what you wrote does not quite fit.
Probably I need to rephrase the question - can I check the given coordinates for the presence of a cube (object) there, and if there is not, create it?

This will be hard, because in normal conditions you do not know if there is a cube.

What you can do is add a cube, store it location in a list, then loop trough the list and check the position with the new cube’s position, then if that position is in the list skip adding cube and go to next position.

What are you trying to make?

Should use a near or collision sensor, in the code check if that sensor is true, if so don’t create a cube.

Also you will need to enable a collision type for the object.

if you add a cube, set a property = cube object.

``````if spawner.get("newobj", None) != None:
dist = spawner.getDistanceTo(spawner["newobj"])
if dist > 2:
spawner["newobj"] = None

else:
# run code to add new cube
• How to do this - the code?
• an infinite level of tiles (objects of a fixed size), based on the position of the player.
• thank you for a very interesting (new for me in the knowledge ) code, but it is not entirely suitable for my task… maybe, I need to think more.

Ah ok, not gonna write that for you, but here is an example.

``````
position_list = []

def build(cont):

own = cont.owner
spawner = own.scene.objects['spawner']

if not position_list:
return

if not spawner.worldPosition in position_list:

own = cont.owner
spawner.worldPosition.y += 1.0
``````

in this case, the list only stores location of the cubes you have spawned, so you can use it later.
but this is basically the basics to add cubes in a straight line.

You can add an in range() check to add squares, but to keep it around the player is a completely other story.
best is to look into resources, should be some scripts there ready to go. for example: dig world problem

• you wrote - “is an example” - I can use it as a tutorial to create my own example with the license CC0? For example, for me the concept of “return” is new …
• you wrote - “best is to look into resources” - if someone has laid out the code in response to a question (part), it will still work, and then you can catch on. But basically on the forum ready-made solutions (files) - there is completely copyright of the owner. Search for everyone and ask … I can, but it’s very difficult.
In general, in some forums clearly spelled out - the answers of users under the license - such and such.
Thank you for attention.

People and their license issues lol, yes of course use it anyway you see fit,

The return breaks up/stops a function for a frame, if i would not have added the return, then in the first frame it would execute all the code, now with the return it will execute the first part on the first frame, then on frame 2 it will execute the rest of the code and skipping the first code block, because at frame 2 the position_list got an entry.

Yes and no, if someone shares a solution to the public then everyone may use it, the code/blends/etc are automatically licensed as a public one. and you can simply add credits to the one who made it. Just don’t brag about it that you are the maker of the code, because if you do then you are breaking the public rules.

If i am right the link i posted has what you want/need, so you can PM @VegetableJuiceF and ask if you may use it, if you aren’t sure about it.

• Thank you for permission to access, and an explanation.
• yes, because the Law says differently, and for this there is a CC0 license. If you do not specify a license, then all the work of the copyright to owner - it’s not I came up with, it’s an international Law.

Thank you for attention.

No problem,

It is also used to pass information(variables) to other functions like this:

``````def give_answer():
answer = 'yes you may use anything'

``````

Also if you use BGE module in your python scripts then they are licensed under GPL keep that in mind.