Hi
I am working on the Inventory code that was in cookbook
http://www.renpy.org/wiki/renpy/doc/coo ... ney_System
i used it in a different way cause i let the user put things in his inventory(cause the game has nothing to do with money and stores)
so user adds thing any time at the Inventory .when the game saved and be loaded again before closing the game everything is good..but when i close the game and open it then load the game i always find the Inventory is empty
..
that's because i put this line in the initial part
inventory = myInventory()
so every thing we'll be start again as its first time
but this impotent to keep the Inventory stores other items they will be added during the game (if i put this line in the start label
it will save only the items i add them when the game starts even with loading before exit the game .
i think to solve this i need to stop the initial code (init python) when the game not new ( loaded )
or
i need the store my Inventory in external file so the code will get the variable from the file
or
saving my Inventory inside the load method
unfortunately i dont know how to do any of these,i tried but i coudnt
so anyone can help
I lose my items in the Inventory after loading the game
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.
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.
Re: I lose my items in the Inventory after loading the game
Try to move <inventory = myInventory()> from init to start label, like
Code: Select all
#init:
#$ inventory = myInventory()
label start:
$ inventory = myInventory()
"..."
Re: I lose my items in the Inventory after loading the game
if I put this line in the Start label it will not save the items those are added by the user during the game
i need a way to save the Inventory in safe place like in external file
i need a way to save the Inventory in safe place like in external file
-
- Eileen-Class Veteran
- Posts: 1258
- Joined: Fri Sep 21, 2007 7:13 am
- Projects: a battle engine
- Contact:
Re: I lose my items in the Inventory after loading the game
Why won't it? It just stores those things in a list. Doesn't matter if they are newly-created items or not.lolosa wrote:if I put this line in the Start label it will not save the items those are added by the user during the game
Give us an example of something that will break if you declare the inventory after label start.
Re: I lose my items in the Inventory after loading the game
i found this ..i think it is the situation here
http://www.renpy.org/wiki/renpy/doc/coo ... nit_blocks
http://www.renpy.org/wiki/renpy/doc/coo ... nit_blocks
Re: I lose my items in the Inventory after loading the game
If the inventory is in an init block, it will lose everything when you reload. If it's after the start label, though, it will save properly. Just make sure anything (variable, list, etc.) you want saved isn't in an init block, and is instead somewhere in the script after the start label.
Who is online
Users browsing this forum: No registered users