RenPy Indentation Explanation

buttfan

Member
Feb 24, 2021
151
193
I've been tinkering around in an existing game (Rogue-Like Evolution if it matters) and making little changes for my own amusement, but recently ran into a curious situation, RebPy started trying to decide what blocks things should be in, and stranger still, it started doing it to code that had worked fine.

For example in the sex cycle code I fiddled about with the menu a little, and suddenly it doesn't like the IF statements below and outside the menu, despite that I hadn't touched any of them, I was only fiddling around in the menu. If I start moving around the IF blocks to be inside other IF blocks it seems happy, except that it breaks the actual logic. It is like RenPy is second guessing the coder, and I am confident it isn't smart enough to do that.

So I'm trying to understand how it decides this sort of thing, and if anyone can explain it.

Thanks.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,963
16,203
So I'm trying to understand how it decides this sort of thing, and if anyone can explain it.
It decide absolutely nothing, period.

If a line end by ":", then it imply a block, and everything in this block will need to have an higher indentation, all at the same level. Everything that will fallback to the previous indentation level will be outside of the block.

Python:
block:
   inside
   the
   block
outside
the
block
And, with the fact that tabulation aren't valid characters, that's all there's to know, and to do.
 

buttfan

Member
Feb 24, 2021
151
193
It decide absolutely nothing, period.
Huh, well I'm glad to hear it isn't *supposed* to be trying to decide such things, although that does still leave the question of what the hell it's doing now?

Well, I think maybe I'll import back in the original code and then try my changes again, maybe something got futzed in there and I'm not seeing it.

Might see if Notepad++ has an option to show hidden control characters too.

And, with the fact that tabulation aren't valid characters, that's all there's to know, and to do.
Yeah, RenPy has made that abundantly clear, I still forget that sometimes.

And it is also case sensitive in commands and (I think) variables, which is a little unusual.

A lot of habits I developed while working in other languages are causing trouble for me here.
 

buttfan

Member
Feb 24, 2021
151
193
Soooo.... found the problem, a missing pair of quotation marks 250 lines before the reported mismatch, in a completely different function. :oops:

Oy vey.
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,963
16,203
Huh, well I'm glad to hear it isn't *supposed* to be trying to decide such things, although that does still leave the question of what the hell it's doing now?
It's not a supposition, he can't, period. As for the question, the answer is always, "what you told it to do".


Soooo.... found the problem, a missing pair of quotation marks 250 lines before the reported mismatch, in a completely different function. :oops:
It's a machine not an AI. It don't think, just blindly follow your lead.
This sometimes lead to an error happening way before it's detected, but it's precisely because it just follow blindly what it's told.

A missing quotation mark mean that the string is not no finished, but that, only a human can know it, not a machine. What mean that for the machine, the error will happen when it finally found what it assume to be the quotation mark ending the string.
 

buttfan

Member
Feb 24, 2021
151
193
This is true.
Computers are extremely stupid, they only do exactly what you tell them to do, no matter how stupid that may be.

However, I have used software - professional level stuff - that was *supposed* to build database queries, entire databases, even entire programs, all based on your basic directions. Any time I looked at the results, it has been utter crap; the messiest, most inefficient code you'll ever find.

I remember in university a professor telling us that there was no need to bother trying to write efficient code, the compiler wiill take whatever you do and make it clean and efficient. "Oh, okay," I thought. But a few hours later I'm thinking "wait a minute... bullshit!"

My point being, just because computers are too stupid to do this shit right, doesn't mean the programmer who built the software isn't stupid enough to think the computer *can* do it. This is what I had assumed was going on, but not that it was literally the computer's fault, but rather the fault of the guy who built the parser.

Fortunately I was wrong, it isn't as stupidly designed as I thought. This is good to know.

There is an old saying, "to err is human... but to really fuck things up you need a computer."
Not that the computer itself is the problem, but the combination of computer stupidity and human stupidity can be truly epic.

There is another saying that applies, and fits this case very well.
"Computers are like old testament gods, lots of rules, and no mercy."
 
  • Like
Reactions: osanaiko