[SOLVED] About store module(probably)

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
couto886
Newbie
Posts: 9
Joined: Sat Nov 10, 2018 9:29 pm
Contact:

[SOLVED] About store module(probably)

#1 Post by couto886 »

So I started with renpy recently and found this store thing (that I'm GUESSING it's a module) in a cookbook recipe and can't find out more details about it in the documentation . Actually (And I have the strong feeling that I'm just being extremaly dumb here) I coudn't find any detailed information about renpy modules itself. If anyone could provide at least an explanation of what is this store module and how it works, or share a link to an page that give me some help I'd REALLY apreciate.

The code in question:
init -1 python:
import renpy.store as store
import renpy.exports as renpy

inv_page = 0
item = None
class Player(renpy.store.object):
Last edited by couto886 on Sat Feb 09, 2019 3:39 pm, edited 1 time in total.

User avatar
isobellesophia
Miko-Class Veteran
Posts: 979
Joined: Mon Jan 07, 2019 2:55 am
Completed: None
Projects: Maddox and Friends! (AI Teacher friend), Friendly Universities! (Soon)
Organization: Friendly Teachers series
Deviantart: SophBelle
itch: Child Creation
Location: Philippines, Mindanao
Contact:

Re: About store module(probably)

#2 Post by isobellesophia »

I think the store module is a app in purchase nor a error, because it shows on the list i searched.

https://www.renpy.org/doc/html/python.h ... ed-stores

https://www.renpy.org/doc/html/iap.html ... chasing
I am a friendly user, please respect and have a good day.


Image

Image


couto886
Newbie
Posts: 9
Joined: Sat Nov 10, 2018 9:29 pm
Contact:

Re: About store module(probably)

#3 Post by couto886 »

Thanks for the help, but from what I've found until now it's not related with In-App Purchasing. From the little I have found until now (mostly from this link viewtopic.php?t=23050 ) it's probably something related to rollback, but how exactly works, or when and how should I use it I have no idea... :cry:

DragoonHP
Miko-Class Veteran
Posts: 758
Joined: Tue Jun 22, 2010 12:54 am
Completed: Christmas
IRC Nick: DragoonHP
Location: Zion Island, Solario
Contact:

Re: About store module(probably)

#4 Post by DragoonHP »

So renpy.store in esssence is basically a class/object which stores game variables and objects. So when in script you write default my_int = 1, it gets stored in renpy.store and can be accessed via store.my_int

But for all intent and purposes, you don't need to touch the store object. What exactly are you trying to do?

couto886
Newbie
Posts: 9
Joined: Sat Nov 10, 2018 9:29 pm
Contact:

Re: About store module(probably)

#5 Post by couto886 »

What exactly are you trying to do?
This is my doubt right now. I've found this code in a cookbook, so I'm actually trying to understand what he was doing, so I can edit without messing everything up.
But for all intent and purposes, you don't need to touch the store object
So I could do the same code without the need of import/inherit store?? If this is the case, why had the coder imported the store??

DragoonHP
Miko-Class Veteran
Posts: 758
Joined: Tue Jun 22, 2010 12:54 am
Completed: Christmas
IRC Nick: DragoonHP
Location: Zion Island, Solario
Contact:

Re: About store module(probably)

#6 Post by DragoonHP »

Link what code you are talking about please

couto886
Newbie
Posts: 9
Joined: Sat Nov 10, 2018 9:29 pm
Contact:

Re: About store module(probably)

#7 Post by couto886 »

Code: Select all

    init -1 python:
    import renpy.store as store 
    import renpy.exports as renpy
    from operator import attrgetter

    inv_page = 0
    item = None
    class Player(renpy.store.object):
        def __init__(self, name, max_hp=0, max_mp=0, element=None):
            self.name=name
            self.max_hp=max_hp
            self.hp=max_hp
            self.max_mp=max_mp
            self.mp=max_mp
            self.element=element
    player = Player("Derp", 100, 50)
    
    class Item(store.object):
        def __init__(self, name, player=None, hp=0, mp=0, element="", image="", cost=0):
            self.name = name
            self.player=player
            self.hp = hp
            self.mp = mp
            self.element=element 
            self.image=image 
            self.cost=cost 
        def use(self): 
            if self.hp>0:
                player.hp = player.hp+self.hp
                if player.hp > player.max_hp: 
                    player.hp = player.max_hp
                inventory.drop(self) 
            elif self.mp>0:
                player.mp = player.mp+self.mp
                if player.mp > player.max_mp: 
                    player.mp = player.max_mp
                inventory.drop(self) 
            else:
                player.element=self.element 

DragoonHP
Miko-Class Veteran
Posts: 758
Joined: Tue Jun 22, 2010 12:54 am
Completed: Christmas
IRC Nick: DragoonHP
Location: Zion Island, Solario
Contact:

Re: About store module(probably)

#8 Post by DragoonHP »

You don't need both of the import lines.

Also, you can just replace renpy.store.object and store.object with object

couto886
Newbie
Posts: 9
Joined: Sat Nov 10, 2018 9:29 pm
Contact:

Re: About store module(probably)

#9 Post by couto886 »

Thanks dude. Really helped me. :D

Post Reply

Who is online

Users browsing this forum: Ocelot