List index out of range?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
Husky
Newbie
Posts: 22
Joined: Fri May 01, 2015 12:32 pm
Contact:

List index out of range?

#1 Post by Husky »

Code: Select all

screen peter():
    zorder -1
    imagemap:
        ground "ramki/talking-frame.png"
        hover "ramki/talking-frame_hover.png"
        
    hotspot (62, 511, 251, 65) clicked Return("talk")
    hotspot (480, 509, 253, 71) clicked Return("investigate")
    hotspot (357, 508, 86, 91) clicked Return("exit")

screen altar():
    zorder -1
    imagemap:
        ground "BG/altar.png"
        hover "BG/altar_hover.png"
        
    hotspot (529, 122, 156, 154) clicked Return("redlight")
    hotspot (347, 456, 166, 93) clicked Return("heart_screen")
    hotspot (2, 413, 215, 186) clicked Return("exit")

(...)


label altar_dungeon:
    if "altar_dungeon" not in visited:
        $ visited.append("altar_dungeon")
        [A lot of dialogs here]
        show peter normal
        menu petertalk:
            peter "Blabla."
            
            "One option":
                jump petertalk
                
            "Second Option":
                jump petertalk
                
            "Third option
                jump petertalk      
                
            "That's all":
                jump peter
                
    else:
        label peter:
            show peter normal
            call screen peter
            $result = _return
            if result == "talk":
                jump petertalk
                
            if result == "investigate":
                call screen altar
                $result = _return
                
                if result == "heart_screen":
                    if "heart_screen" not in visited:
                        $ visited.append("heart_screen")
                        "Blabla."
                    else:
                        "Blabla."
                        
                if result == "redlight":
                    if "redlight" not in visited:
                        $ visited.append("redlight")
                        "Blabla."
                    else:
                        "Blabla."
                        
                if result == "exit":
                    jump peter
                    
            if result == "exit":
                scene castle_underground with fade
                jump castle_underground


I thought, it will be working, because it seems logical to me. But I still get an error. I hope, it's quite clear to get the point how it is supposed to work. Just like in Phoenix Wright, where when you approach a character the second, third and so time, you have an option to talk, to give something to that character and to investigate the background. So I made two screens.

One with my character - Peter. He should be visible during the choosing between talking with him and investigating the background. And there's also a button to go back to the previous location.

The other screen is the background itself. And it has some clickable elements and one exit, which should go back to the previous screen.

What have I done wrong?

philat
Eileen-Class Veteran
Posts: 1909
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: List index out of range?

#2 Post by philat »

Well, what line is triggering the out of index?

Husky
Newbie
Posts: 22
Joined: Fri May 01, 2015 12:32 pm
Contact:

Re: List index out of range?

#3 Post by Husky »

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/rozdzial1.rpy", line 1078, in script
    call screen peter
  File "renpy/common/000statements.rpy", line 457, in execute_call_screen
    store._return = renpy.call_screen(name, *args, **kwargs)
  File "game/rozdzial1.rpy", line 30, in execute
    screen peter():
IndexError: list index out of range

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/rozdzial1.rpy", line 1078, in script
    call screen peter
  File "D:\DOWNLOAD\renpy-6.18.3-sdk\renpy\ast.py", line 1641, in execute
    self.call("execute")
  File "D:\DOWNLOAD\renpy-6.18.3-sdk\renpy\ast.py", line 1659, in call
    renpy.statements.call(method, parsed, *args, **kwargs)
  File "D:\DOWNLOAD\renpy-6.18.3-sdk\renpy\statements.py", line 144, in call
    return method(parsed, *args, **kwargs)
  File "renpy/common/000statements.rpy", line 457, in execute_call_screen
    store._return = renpy.call_screen(name, *args, **kwargs)
  File "D:\DOWNLOAD\renpy-6.18.3-sdk\renpy\exports.py", line 2339, in call_screen
    rv = renpy.ui.interact(mouse="screen", type="screen", roll_forward=roll_forward)
  File "D:\DOWNLOAD\renpy-6.18.3-sdk\renpy\ui.py", line 277, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "D:\DOWNLOAD\renpy-6.18.3-sdk\renpy\display\core.py", line 2287, in interact
    scene_lists.replace_transient()
  File "D:\DOWNLOAD\renpy-6.18.3-sdk\renpy\display\core.py", line 672, in replace_transient
    self.remove(layer, tag)
  File "D:\DOWNLOAD\renpy-6.18.3-sdk\renpy\display\core.py", line 959, in remove
    self.hide_or_replace(layer, remove_index, "hide")
  File "D:\DOWNLOAD\renpy-6.18.3-sdk\renpy\display\core.py", line 883, in hide_or_replace
    d = oldsle.displayable._hide(now - st, now - at, prefix)
  File "D:\DOWNLOAD\renpy-6.18.3-sdk\renpy\display\screen.py", line 426, in _hide
    self.update()
  File "D:\DOWNLOAD\renpy-6.18.3-sdk\renpy\display\screen.py", line 556, in update
    self.screen.function(**self.scope)
  File "game/rozdzial1.rpy", line 30, in execute
    screen peter():
  File "D:\DOWNLOAD\renpy-6.18.3-sdk\renpy\sl2\slast.py", line 702, in execute
    imc = renpy.ui.imagemap_stack[-1]
IndexError: list index out of range

Windows-7-6.1.7601-SP1
Ren'Py 6.99.4.467
Helvetti 1.0
Here's the error log. I have no idea, why it doesn't work.

Pippin123
Regular
Posts: 52
Joined: Sat Jan 31, 2015 7:33 pm
Contact:

Re: List index out of range?

#4 Post by Pippin123 »

I don't know the screen language that well, but it seems it takes exception with your

Code: Select all

zorder -1
?

Code: Select all

imc = renpy.ui.imagemap_stack[-1]
Are you somehow pushing a screen "under" the first level?

philat
Eileen-Class Veteran
Posts: 1909
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: List index out of range?

#5 Post by philat »

Code: Select all

  File "game/rozdzial1.rpy", line 30, in execute
    screen peter():
  File "D:\DOWNLOAD\renpy-6.18.3-sdk\renpy\sl2\slast.py", line 702, in execute
    imc = renpy.ui.imagemap_stack[-1]
IndexError: list index out of range
Well, look at what exactly is causing the problem. This line of code is trying to access the last item in a list called renpy.ui.imagemap_stack. The error is that there is no last item in the stack, i.e., the list is empty.

Then that means the imagemap is somehow faulty. Knowing that, what do you think is the issue? I'm asking since it will help you to work out the answer yourself.
The hotspots are indented incorrectly. They should all be indented one level further. http://www.renpy.org/doc/html/screens.h ... statements

Husky
Newbie
Posts: 22
Joined: Fri May 01, 2015 12:32 pm
Contact:

Re: List index out of range?

#6 Post by Husky »

Is it something with that zorder? I'm forced to put -1 for all the screens, because I have a one more screen called "Equipment". And it shows a little icon during the game, which opens the another screen with stuff the player gathered. And if my normal screens doesn't have -1, my Equipment screen (that icon) is hidden and I wanted it to be visible all the time.

User avatar
nyaatrap
Crawling Chaos
Posts: 1824
Joined: Mon Feb 13, 2012 5:37 am
Location: Kimashi Tower, Japan
Contact:

Re: List index out of range?

#7 Post by nyaatrap »

I never use imagemap, but hotspots are coded at outside of the imagemap block?

Husky
Newbie
Posts: 22
Joined: Fri May 01, 2015 12:32 pm
Contact:

Re: List index out of range?

#8 Post by Husky »

nyaatrap wrote:I never use imagemap, but hotspots are coded at outside of the imagemap block?
It works that way with other screens just fine.

@edit

Okay. My mistake. The hotspots were in fact broken.

Post Reply

Who is online

Users browsing this forum: Andredron, Google [Bot]