Pleevy
Member
- Nov 23, 2024
- 285
- 850
- 103
Just to be sure, that's EXACTLY how it needs to be in the code, after ops: space, -, space, 1. No other changes correct? This will also make me happy because it means the nuts and bolts of the car for at least 2/3 if not more of what "is planned" for its use is ready and someone just needs to quit slacking off and write some content...So what "pop index out of range" means, is that you if you try to 'pop' the 8th element in a list with 7 items, python doesn't understand what you'd like to do. "But MrFluffums", you say, "I thought you said renpy.random.randint(0,len(menu_ops)) would never exceed the size of the list?"
And to that I say that apparently I can't read. I thought randint(0,2) would give either 0 or 1, but never 2. But the documentation (which I read poorly) says that renpy.random.randint(a, b) returns a random integer such that a <= N <= b. This is different from for example the range function in python, range(a,b) returns a range of integers a <= N < b.
Long story short, it's an off-by-one error. Instead of renpy.random.randint(0,len(menu_ops)) it has to be renpy.random.randint(0,len(menu_ops - 1)).
Forgetful does not an idiot make.So it turns out im a forgetful idiot.
Your modified file throws no errors for me.
Wracking my brain on what could be going wrong when I finally remember a tweak i do in stuff I work on.
So yeah. it doesnt error for me because when I was half asleep at some point i added that to my copy of BSC (its part of my template project i use for all my renpy stuff)
So sorry. And fluff already explained why its an error without my 'fixed' version of randint. FWIW its not a bad modification to use as a convenience function. If its not clear it makes calls with no arguments return a pecentile roll. 1-100 inclusive. A call with 1 arg will be 0 - Val, non-inclusive. That way you can do stuff like how i used it with len() and get a legal index value. And when called with more than 1 arg or with keyword args it uses default behavior
You both make me happy, and not only because its not my fault when these things are not working...