Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How does indentation work? What are blocks?

blocks indentation
0
Posted

How does indentation work? What are blocks?

0

A lot of the time you’ll need to understand how Ren’Py and Python’s blocks work, especially if you’re trying to include example code in your game. Both Ren’Py-script and Python are sensitive to indentation – this is how blocks are created. In the above image, each of the coloured lines spanning one or more text lines shows a ‘block’. These blocks are nested within each other, and each ‘belong’ to a certain line that starts the block. So in the example image, the menu choices “Say hello” and “Ignore her” both ‘belong’ to – and depend upon – the ‘menu:’ line. Lines inside a block must all be indented more than the line that ‘owns’ the block. So all the lines which are part of the menu in the example must be indented more than the line with “menu:” on. If two lines are both at the same level – both depend immediately on the same block-starting line – then they must have the same indentation. You must indent or un-indent lines only to control which block they are in, as Ren’Py and Python w

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123