When testing if you 'watch backpack.inventory[0].amount', you get an 'eval failed' after you choose to ask on the date, because it's been removed from the inventory.
Yes, yes, yes... That's what I wasn't able to put my finger on...
Like the item is created directly when added into the list, there's only one copy of it, the one in the list. Therefore, when it's removed from the list, it also disappear, and it's what make Ren'py goes out of track.
[Note: It's really a quick summary of the process ; the intent is to explain the problem, not Ren'py mechanism]
With each interaction, Ren'py look at the known entities, and for each one it keep the actual value, this in order to restore it in case of rollback. This lead to Ren'py to duplicate the objects ; therefore, an object isn't really deleted, it's just the value of the variable that become null.
[in the console]
Code:
a = "string"
id( a )
b = a
id( a ) == id( b )
delattr( store, "a" )
a
b
a = b
a
id( a )
It's, globally, the same principle than with the rollback process.
The variable
a
is duplicated ; they don't have the same value, but point to the same memory space. Then
a
is deleted, but
b
continue to exist. In the end, we give back it's value to
a
, and it's still the same memory space like its
id show.
But here, when the object is removed from the list, it stop to be a "known entity", because it only exist as a duplicated copy in Ren'py rollback stack. Therefore, Ren'py can't take a new copy of its new value ; it don't exist, Ren'py don't know that something have changed.
Then, when you rollback, the
inventory list retrieve its value before the deletion. Among those value, there's the pointer to the object... an object that haven't been included in the last rollback preparation, so that will not be restored to its value and still have
amount
at 0.
I assume that if you do something like :
- amount = 2
- amount = 1
- amount = 0
- whatever.
when you rollback to 3, you'll have the value of 0, and the value will still be 0 if you rollback to 2. But once you'll rollback to 1, the value will suddenly become 2, because at this time the object was still a "known entity", and Ren'py correctly took care of it during the rollback preparation.
As I imply previously, my brain isn't at its best actually, still hope that my explanation are understandable.