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.
-
Kia
- Eileen-Class Veteran
- Posts: 1011
- Joined: Fri Aug 01, 2014 7:49 am
- Deviantart: KiaAzad
- Discord: Kia#6810
-
Contact:
#1
Post
by Kia » Thu Oct 06, 2016 5:16 am
I have this button:
Code: Select all
vbox:
button:
text "Remove"
action SetVariable('persistent.chardb[i][0]',-3)
that should set an entry in a list, in my head it should work fine but I'm getting this error:
Code: Select all
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/script.rpy", line 12, in script call
call chars
File "game/battle/chars.rpy", line 107, in script
pause
File "renpy/common/000statements.rpy", line 385, in execute_pause
renpy.pause()
File "renpy/common/00action_data.rpy", line 50, in get_selected
return getattr(self.object, self.field) == self.value
AttributeError: 'StoreModule' object has no attribute 'persistent.chardb[i][0]'
anybody has any Idea what am I doing wrong here?
Last edited by
Kia on Mon Oct 10, 2016 2:32 am, edited 1 time in total.
-
Divona
- Miko-Class Veteran
- Posts: 678
- Joined: Sun Jun 05, 2016 8:29 pm
- Completed: The Falconers: Moonlight
- Organization: Bionic Penguin
- itch: bionicpenguin
-
Contact:
#2
Post
by Divona » Thu Oct 06, 2016 5:56 am
Completed:

-
Ocelot
- Eileen-Class Veteran
- Posts: 1883
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
-
Contact:
#3
Post
by Ocelot » Thu Oct 06, 2016 6:03 am
In my experience, SetVariable does not work well with dictionaries, lists, object fields and anything else. And trying to choose one of dozen of data manipulation functions is annoying.
So, I prefer to make python function which does what I want and call it with Function action. Something like that:
Code: Select all
def set_persistent_char_data(id1, id2, value):
persistent.chardb[id1][id2] = value
#...
action Function('set_persistent_char_data', i, 0, -3)
< < insert Rick Cook quote here > >
-
Kia
- Eileen-Class Veteran
- Posts: 1011
- Joined: Fri Aug 01, 2014 7:49 am
- Deviantart: KiaAzad
- Discord: Kia#6810
-
Contact:
#4
Post
by Kia » Thu Oct 06, 2016 6:10 am
Divona wrote:Try:
Code: Select all
action SetField(persistent, 'chardb[i][0]', -3)
I've tried this one before but I didn't work, I'll give the function a try but I'm trying to make it only using screen code and avoiding python blocks, any other suggestion would be appreciated
-
papiersam
- Veteran
- Posts: 231
- Joined: Fri Aug 12, 2016 2:24 pm
- Completed: Gem Hunt Beta, 1/Probably, Animunch
- Projects: The Panda Who Dreamed
-
Contact:
#5
Post
by papiersam » Thu Oct 06, 2016 8:00 am
In my experience, I don't think you can edit the values in a two-dimensional array like that, simply by screen (left me stumped for a while). Your best bet is to try a function.
-
Evildumdum
- Regular
- Posts: 191
- Joined: Sun Jan 18, 2015 8:49 am
- Projects: ApoclypseZ
-
Contact:
#6
Post
by Evildumdum » Thu Oct 06, 2016 5:12 pm
I think you need the AddToSet function
"If at first you don't succeed, try hitting it with a shoe."
-
Kia
- Eileen-Class Veteran
- Posts: 1011
- Joined: Fri Aug 01, 2014 7:49 am
- Deviantart: KiaAzad
- Discord: Kia#6810
-
Contact:
#7
Post
by Kia » Fri Oct 07, 2016 12:42 am
r_sami wrote:In my experience, I don't think you can edit the values in a two-dimensional array like that, simply by screen (left me stumped for a while). Your best bet is to try a function.
as I checked, the problem is with modifying any kind of arrays(lists). I can change a variable with both "SetField" and "SetVariable" but as soon as I change the variable to an array it stops working, right now I am using the function solution but I was hoping to find out what's wrong with those two functions.
Evildumdum wrote:I think you need the AddToSet function
as far as I Know "AddToSet" appends the value to the end of the set, it will change the structure of the set and the code will break.
Users browsing this forum: Bing [Bot]