this post was submitted on 20 Oct 2024
14 points (100.0% liked)

Python

6400 readers
9 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

πŸ“… Events

PastNovember 2023

October 2023

July 2023

August 2023

September 2023

🐍 Python project:
πŸ’“ Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
Feeds

founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 3 points 1 month ago (3 children)

I'm not a Python programmer but just intuitively it seems like if i==0 will make the first block fall right after it's created. Shouldn't it be if i==25? Or does it work because the loop has time to generate all the other blocks before the first block has time to hit the second one?

[–] monica_b1998 3 points 1 month ago (1 children)

Good question - it's the latter: all the blocks are generated practically instantaneously, whereas it does take a noticeable amount of time for the first block to hit the next one.

if i==25 would only result in the last block falling down, the rest would remain standing.a

[–] [email protected] 3 points 1 month ago (1 children)

Oh that makes sense - apparently bpy.ops has a current context that the transform acts on. Instead could you move the transform call outside of the loop after establishing the first block as the context? That's how I would instinctively do it, to avoid checking i in every iteration when I know it can only be true once. Totally minor critique lol.

[–] monica_b1998 2 points 1 month ago

that makes sense! if I find the time, I'll update it. it needs to updated to a newer Blender version anyway....

load more comments (1 replies)