[SOLVED] How to update a Dictionary Screen Variable?

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
hell_oh_world
Regular
Posts: 179
Joined: Fri Jul 12, 2019 5:21 am
Projects: The Button Man
Organization: NILA
Contact:

[SOLVED] How to update a Dictionary Screen Variable?

#1 Post by hell_oh_world » Tue Feb 25, 2020 5:25 pm

Hey Folks! Good Morning to all of you!

So right now I have my variables inside my screen. I structured one of my variables as a dict, unfortunately, I am unable to update it. Simply

Code: Select all

ScreenVariableInputValue
, which I use because I want to live update the variable using an input, and `SetScreenVariable`, which is another way of modifying screen variables in some cases, do not work. I mean, is it possible to use the

Code: Select all

value
property of the input element and update at the same time the dict? I've been using something like this

Code: Select all

value ScreenVariableInputValue("dict['key1']['key2']")
, unfortunately it throws an error that key is not found. Is this possible though?

Another thing... If things are not really feasible and the use of

Code: Select all

changed
property is the only solution, is there a

Code: Select all

namespace
that I can call inside my python functions or inside the python blocks itself that contains the screen variables for a specific screen? Something like

Code: Select all

screen.variables.dict["key1"]["key2"]
Hope my questions make sense. Thank you, everyone, have a good day!
Last edited by hell_oh_world on Wed Feb 26, 2020 3:22 am, edited 1 time in total.


User avatar
hell_oh_world
Regular
Posts: 179
Joined: Fri Jul 12, 2019 5:21 am
Projects: The Button Man
Organization: NILA
Contact:

Re: How to update a Dictionary Screen Variable?

#3 Post by hell_oh_world » Tue Feb 25, 2020 6:20 pm

Oh my god! Didn't see that one, this one should definitely work! Gotta try this after I get home. Thanks Alex. I'll see if this will work.

User avatar
hell_oh_world
Regular
Posts: 179
Joined: Fri Jul 12, 2019 5:21 am
Projects: The Button Man
Organization: NILA
Contact:

Re: How to update a Dictionary Screen Variable?

#4 Post by hell_oh_world » Wed Feb 26, 2020 3:15 am

Unfortunately, I have no idea on how to use this Action... I used it something like this?

Code: Select all

value DictInputValue("inputFields", "['givenName']['value']")
But an error appears, it says "string indices must be an integer." Am I using this right? the doc is not clear on what kind of data type or parameters that the action needs, so i passed string arguments. Tried also escaping the brackets knowing that it might interpret it as a string interpolation, but no luck. Am I doing something wrong with this? Clearly I have no clue on how to use this action.

User avatar
hell_oh_world
Regular
Posts: 179
Joined: Fri Jul 12, 2019 5:21 am
Projects: The Button Man
Organization: NILA
Contact:

Re: How to update a Dictionary Screen Variable?

#5 Post by hell_oh_world » Wed Feb 26, 2020 3:21 am

Guess I made it work! so the only string argument is the key argument and the dict argument is the actual name of the variable.

Code: Select all

value DictInputValue(inputFields["givenName"], "value")
Thanks for the help Alex!

Post Reply

Who is online

Users browsing this forum: Google [Bot], MaydohMaydoh