Exception caught when cycling through a list via a button

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
Xenubin
Newbie
Posts: 15
Joined: Tue Aug 11, 2020 7:04 pm
Completed: 5
Projects: Lytelove, Titan Arum, Carnival of Shadows
Github: xenubinx
itch: xenubinstudios
Contact:

Exception caught when cycling through a list via a button

#1 Post by Xenubin »

Hi all!

I'm playing around with some screen language again and testing out a super rough character creation screen.

Currently I have a little screen with a name input box, no issues there thankfully,a nd im trying to add a cycleable section below it for something like pronouns, a title, etc for the character as a text displayable.


here's my code for this!

Code: Select all


default list1 = {
    "1" : "", 
    "2": "", 
    "3": ""
}


default selection_variable = 0

screen charcreate:
    image "images/createbg.png"
    fixed: 
        xpos 650
        ypos 490
        text "{color=#000000}This book belongs to{/color}": 
            size 30
            
        input:
            ypos 65
            xpos 20
            pixel_width(500)
            value VariableInputValue("player_name")
    textbutton ">":
        xpos 650
        ypos 700
        action CycleVariable(list1, values=["1","2","3"], loop=True)
    text "[list1[selection_variable]]":
        xpos 675
        ypos 700

    textbutton "Start":
        xpos 1500
        ypos 1000
        action Jump("continue")
        keysym('K_RETURN', 'K_KP_ENTER')

and then the current error i am getting is:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 15, in script
    call screen charcreate
  File "renpy/common/000statements.rpy", line 671, in execute_call_screen
    store._return = renpy.call_screen(name, *args, **kwargs)
  File "renpy/common/00action_data.rpy", line 75, in __call__
    _set_field(self.object, self.field, self.value_to_set(), self.kind)
  File "renpy/common/00action_data.rpy", line 253, in value_to_set
    value = self.current_value()
  File "renpy/common/00action_data.rpy", line 79, in current_value
    return _get_field(self.object, self.field, self.kind)
  File "renpy/common/00action_data.rpy", line 36, in _get_field
    raise Exception("The {!r} {} does not exist.".format(name, kind))
Exception: The '1' global variable does not exist.

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

Full traceback:
  File "game/script.rpy", line 15, in script
    call screen charcreate
  File "C:\Users\Wampl\OneDrive\Documents\renpy-8.2.0-sdk\renpy\ast.py", line 1968, in execute
    self.call("execute")
  File "C:\Users\Wampl\OneDrive\Documents\renpy-8.2.0-sdk\renpy\ast.py", line 1950, in call
    return renpy.statements.call(method, parsed, *args, **kwargs)
  File "C:\Users\Wampl\OneDrive\Documents\renpy-8.2.0-sdk\renpy\statements.py", line 349, in call
    return method(parsed, *args, **kwargs)
  File "renpy/common/000statements.rpy", line 671, in execute_call_screen
    store._return = renpy.call_screen(name, *args, **kwargs)
  File "C:\Users\Wampl\OneDrive\Documents\renpy-8.2.0-sdk\renpy\exports.py", line 3413, in call_screen
    rv = renpy.ui.interact(mouse="screen", type="screen", roll_forward=roll_forward)
  File "C:\Users\Wampl\OneDrive\Documents\renpy-8.2.0-sdk\renpy\ui.py", line 301, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "C:\Users\Wampl\OneDrive\Documents\renpy-8.2.0-sdk\renpy\display\core.py", line 2165, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, pause=pause, pause_start=pause_start, pause_modal=pause_modal, **kwargs) # type: ignore
  File "C:\Users\Wampl\OneDrive\Documents\renpy-8.2.0-sdk\renpy\display\core.py", line 3197, in interact_core
    rv = root_widget.event(ev, x, y, 0)
  File "C:\Users\Wampl\OneDrive\Documents\renpy-8.2.0-sdk\renpy\display\layout.py", line 1202, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\Wampl\OneDrive\Documents\renpy-8.2.0-sdk\renpy\display\layout.py", line 1202, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\Wampl\OneDrive\Documents\renpy-8.2.0-sdk\renpy\display\layout.py", line 1202, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\Wampl\OneDrive\Documents\renpy-8.2.0-sdk\renpy\display\screen.py", line 793, in event
    rv = self.child.event(ev, x, y, st)
  File "C:\Users\Wampl\OneDrive\Documents\renpy-8.2.0-sdk\renpy\display\layout.py", line 1202, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\Wampl\OneDrive\Documents\renpy-8.2.0-sdk\renpy\display\behavior.py", line 1174, in event
    return handle_click(self.clicked)
  File "C:\Users\Wampl\OneDrive\Documents\renpy-8.2.0-sdk\renpy\display\behavior.py", line 1095, in handle_click
    rv = run(action)
  File "C:\Users\Wampl\OneDrive\Documents\renpy-8.2.0-sdk\renpy\display\behavior.py", line 395, in run
    return action(*args, **kwargs)
  File "renpy/common/00action_data.rpy", line 75, in __call__
    _set_field(self.object, self.field, self.value_to_set(), self.kind)
  File "renpy/common/00action_data.rpy", line 253, in value_to_set
    value = self.current_value()
  File "renpy/common/00action_data.rpy", line 79, in current_value
    return _get_field(self.object, self.field, self.kind)
  File "renpy/common/00action_data.rpy", line 36, in _get_field
    raise Exception("The {!r} {} does not exist.".format(name, kind))
Exception: The '1' global variable does not exist.

Windows-10-10.0.19045 AMD64
Ren'Py 8.2.0.24012702
char creation test 1.0
Wed Feb 14 07:45:18 2024

I currently don't feel that the selection_variable is set up to cycle correctly, but i'm not 100% what I need to be doing here with it

User avatar
m_from_space
Miko-Class Veteran
Posts: 978
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Exception caught when cycling through a list via a button

#2 Post by m_from_space »

Xenubin wrote: Wed Feb 14, 2024 8:51 am

Code: Select all

default list1 = {
    "1" : "", 
    "2": "", 
    "3": ""
}
Yours is not a list, it's a dictionary.

Code: Select all

default mylist = ["this", "is", "a", "list"]

Xenubin
Newbie
Posts: 15
Joined: Tue Aug 11, 2020 7:04 pm
Completed: 5
Projects: Lytelove, Titan Arum, Carnival of Shadows
Github: xenubinx
itch: xenubinstudios
Contact:

Re: Exception caught when cycling through a list via a button

#3 Post by Xenubin »

m_from_space wrote: Wed Feb 14, 2024 8:57 am
Xenubin wrote: Wed Feb 14, 2024 8:51 am

Code: Select all

default list1 = {
    "1" : "", 
    "2": "", 
    "3": ""
}
Yours is not a list, it's a dictionary.

Code: Select all

default mylist = ["this", "is", "a", "list"]
I did Initially have it set up like that, but was still getting the same error when i pressed the button to cycle through the list, which is why it got changed to that lol

even changing it back i still get the "The '1' global variable does not exist'' exception

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2407
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Exception caught when cycling through a list via a button

#4 Post by Ocelot »

Code: Select all

default var = 0
define name = "var"

CycleVariable("var", [0, 1]) # Cycles var through 0 and 1
CycleVariable(name, [0, 1]) # Cycles var through 0 and 1
Second comment is not a mistake. list1"list1".
< < insert Rick Cook quote here > >

User avatar
m_from_space
Miko-Class Veteran
Posts: 978
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Exception caught when cycling through a list via a button

#5 Post by m_from_space »

Xenubin wrote: Wed Feb 14, 2024 9:02 am even changing it back i still get the "The '1' global variable does not exist'' exception
I guess what you're trying to do is something like this:

Code: Select all

default fruitlist = ["Apples", "Bananas", "Cherries"]

screen bazaar():
    default fruit = None
    vbox:
        if fruit is None:
            text "Check out our fruits!"
        else:
            text fruit
        textbutton "Next Fruit" action CycleVariable("fruit", fruitlist)

Post Reply

Who is online

Users browsing this forum: Ocelot