Another question about indexError

slik4x4

New Member
Nov 3, 2019
14
5
So, working on fixing some bug for myself in some elses game. Harem Camp is the game.

Here is the error message:

You don't have permission to view the spoiler content. Log in or register now.

Here is the code i think:

You don't have permission to view the spoiler content. Log in or register now.

python line referenced:

You don't have permission to view the spoiler content. Log in or register now.

I have been able to fix a few things on my own, but this is just 2 much.

Thanks
 

shark_inna_hat

Active Member
Game Developer
Dec 25, 2018
705
2,765
Python:
if option1>len(option):
    $ alexa_char.chat=0
replace it with:
Python:
if option1 >= len(option):
    $ alexa_char.chat=0
len() returns the size of on object, but if you use that value as an index you're off by one, because the index starts at 0. Lets say you have 'option=[0,1,2,3,4,5,6,25]', 'len(options)' will return 8, but there is no item at index 8 so 'option[8]' raises a IndexError ( option.index(25) - index of the last element- returns 7).
 
  • Like
Reactions: slik4x4

slik4x4

New Member
Nov 3, 2019
14
5
Thanks alot. I figured it was something simple I wasn't seeing. The developer has a separate script for each character and this line was wrong in all of them.

I don't know anything really about code, so looking for examples of similar problems and reading was not quite enough. I find that real life "hands on" is what I need to learn anymore.

Thanks again for your time.