That renpy cannot save objects I already know about, but all possible solutions are not working and I have no idea how to make the code below work properly.
Basically it's a code with some pre-defined elements for me to have a basis for how I'm going to build a clothing system:
renpy.storage.object which in theory was supposed to save the data, is not saving. (at least I imagine that's it )
Although while the game is open, if I load the 3 items, save, go to the main menu, and load the save, the 3 items will be there, but when I close the game, open it again and load the save, the items are gone - first problem
I read about Rollback can cause problems like this in addition to being duplicated every time the label start is read again, using the renpy.block_rollback() command solves this problem but the others do not. - second "problem"
The last problem is in relation to the duplication of items every time the label that inserts them is read, I thought of a temporary solution that they are only added when a variable X is false
(I also thought about writing a function inside the classes but it would be additional work since I didn't solve the previous problems)
Code: Select all
init -2 python:
import renpy.store as store
import renpy.exports as renpy
class Player(renpy.store.object):
def __init__(self, name):
self.name=name
self.inv=[]
def gain(self,Item):
self.inv.append([Item])
return
class Item(renpy.store.object):
def __init__(self, name, image):
self.name=name
self.image=image
init -1 python:
box_1 = Item("box","box.png")
triangle_1= Item("triangle","triangle.png")
circle_1 = Item("circle","circle.png")
init :
$ eil = Player("Eil")
define n = Character(eil.name)
define n = "Narrador"
define e = "Eileen"
label start:
scene bg room
show eileen happy
n "Eileen inventory has: Box, Triangle and Circle"
$ eil.gain(box_1)
$ eil.gain(triangle_1)
$ eil.gain(circle_1)
$ renpy.block_rollback()
jump inv
return
label inv:
call screen inventario
screen inventario:
zorder 1
vbox:
hbox:
textbutton "{color=FFFFFF}Close:{/color}":
action [Hide ("inventario"), Call ("start")]
for item in eil.inv:
$ pic = item[0].image
$ hover = im.Sepia(pic)
imagebutton:
idle Composite((100,100), (0,0), pic)
hover Composite((100,100), (0,0), pic)
action NullAction()
ps :English is not my native language.