String Index is 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
User avatar
Braydxne
Regular
Posts: 50
Joined: Tue Aug 08, 2017 4:03 am
Projects: DR: Chains of Trust
Contact:

String Index is Out of Range?

#1 Post by Braydxne »

I'm trying to animate the namebox in my game so it slides in when a character is speaking, and slides off when they're done. I got the first part to work but after adding code for the sliding out it broke. Whats wrong with it?

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 76, in script
    mthink "Sometimes I like to remember."
  File "renpy/common/000window.rpy", line 98, in _window_auto_callback
    _window_show()
  File "renpy/common/000window.rpy", line 60, in _window_show
    renpy.with_statement(trans)
  File "game/screens.rpy", line 100, in execute
    screen say(who, what):
  File "game/screens.rpy", line 100, in execute
    screen say(who, what):
  File "game/screens.rpy", line 103, in execute
    window:
  File "game/screens.rpy", line 106, in execute
    if who is not None:
  File "game/screens.rpy", line 118, in execute
    if what[0] == "#":
IndexError: string index out of range

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

Full traceback:
  File "C:\Users\Mom\Downloads\renpy-6.99.14.3-sdk\renpy\bootstrap.py", line 306, in bootstrap
    renpy.main.main()
  File "C:\Users\Mom\Downloads\renpy-6.99.14.3-sdk\renpy\main.py", line 513, in main
    run(restart)
  File "C:\Users\Mom\Downloads\renpy-6.99.14.3-sdk\renpy\main.py", line 139, in run
    renpy.execution.run_context(True)
  File "C:\Users\Mom\Downloads\renpy-6.99.14.3-sdk\renpy\execution.py", line 879, in run_context
    context.run()
  File "game/script.rpy", line 76, in script
    mthink "Sometimes I like to remember."
  File "C:\Users\Mom\Downloads\renpy-6.99.14.3-sdk\renpy\ast.py", line 618, in execute
    statement_name("say")
  File "C:\Users\Mom\Downloads\renpy-6.99.14.3-sdk\renpy\ast.py", line 43, in statement_name
    i(name)
  File "renpy/common/000window.rpy", line 98, in _window_auto_callback
    _window_show()
  File "renpy/common/000window.rpy", line 60, in _window_show
    renpy.with_statement(trans)
  File "C:\Users\Mom\Downloads\renpy-6.99.14.3-sdk\renpy\exports.py", line 1452, in with_statement
    return renpy.game.interface.do_with(trans, paired, clear=clear)
  File "C:\Users\Mom\Downloads\renpy-6.99.14.3-sdk\renpy\display\core.py", line 2207, in do_with
    clear=clear)
  File "C:\Users\Mom\Downloads\renpy-6.99.14.3-sdk\renpy\display\core.py", line 2649, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
  File "C:\Users\Mom\Downloads\renpy-6.99.14.3-sdk\renpy\display\core.py", line 3033, in interact_core
    root_widget.visit_all(lambda i : i.per_interact())
  File "C:\Users\Mom\Downloads\renpy-6.99.14.3-sdk\renpy\display\core.py", line 511, in visit_all
    d.visit_all(callback)
  File "C:\Users\Mom\Downloads\renpy-6.99.14.3-sdk\renpy\display\core.py", line 511, in visit_all
    d.visit_all(callback)
  File "C:\Users\Mom\Downloads\renpy-6.99.14.3-sdk\renpy\display\core.py", line 511, in visit_all
    d.visit_all(callback)
  File "C:\Users\Mom\Downloads\renpy-6.99.14.3-sdk\renpy\display\core.py", line 511, in visit_all
    d.visit_all(callback)
  File "C:\Users\Mom\Downloads\renpy-6.99.14.3-sdk\renpy\display\screen.py", line 424, in visit_all
    callback(self)
  File "C:\Users\Mom\Downloads\renpy-6.99.14.3-sdk\renpy\display\core.py", line 3033, in <lambda>
    root_widget.visit_all(lambda i : i.per_interact())
  File "C:\Users\Mom\Downloads\renpy-6.99.14.3-sdk\renpy\display\screen.py", line 434, in per_interact
    self.update()
  File "C:\Users\Mom\Downloads\renpy-6.99.14.3-sdk\renpy\display\screen.py", line 619, in update
    self.screen.function(**self.scope)
  File "game/screens.rpy", line 100, in execute
    screen say(who, what):
  File "game/screens.rpy", line 100, in execute
    screen say(who, what):
  File "game/screens.rpy", line 103, in execute
    window:
  File "game/screens.rpy", line 106, in execute
    if who is not None:
  File "game/screens.rpy", line 118, in execute
    if what[0] == "#":
  File "<screen language>", line 118, in <module>
IndexError: string index out of range

Windows-8-6.2.9200
Ren'Py 7.0.0.196
ERA 1.0
Thu Jun 21 15:32:37 2018

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: String Index is Out of Range?

#2 Post by Remix »

Have you amended screens.rpy to add new functionality?

The error simply says what[0] is out of range implying what is "" so as a workaround

if what and what[0] == "#":
Frameworks & Scriptlets:

User avatar
Braydxne
Regular
Posts: 50
Joined: Tue Aug 08, 2017 4:03 am
Projects: DR: Chains of Trust
Contact:

Re: String Index is Out of Range?

#3 Post by Braydxne »

Remix wrote: Thu Jun 21, 2018 7:12 pm Have you amended screens.rpy to add new functionality?

The error simply says what[0] is out of range implying what is "" so as a workaround

if what and what[0] == "#":
Thank you so much!

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]