rakugoteam / Rakugo-archive

Framework (inspired by Ren'Py) for story driven games in Godot.
https://rakugoteam.github.io/
MIT License
317 stars 31 forks source link

After loading game Scene don't return to state form save #85

Closed Jeremi360 closed 5 years ago

Jeremi360 commented 5 years ago

Solutions is to use PackedScene with ResourceSaver and ResourceLoader here is example of this: https://godotengine.org/qa/31138/saving-a-dictionary-of-scene-states

Jeremi360 commented 5 years ago

Today I got an idea - there is simpler and easier way to fix it- just inst2dict() to save state of nodes that was add do ren's global variables by node_link() (now there is only save path to node) and then use get_property_list() and set() to set it after load. What you think @ivandardi?

Jeremi360 commented 5 years ago

I need to use PackedScene with ResourceSaverand ResourceLoader as dict - unfortunately inst2dict()only give vars define in script

Jeremi360 commented 5 years ago

It is not a bug, it properly save/load data, but it just don't save scene state - it will be hard to do and have many disadvantages. Just use build rakugo_vars mechanics to save what you need I also added on "loaded" signal to help with it.

Jeremi360 commented 5 years ago

Yes this solution is good enough. Here are examples:

Jeremi360 commented 5 years ago

This solution for some reason stop to work - save don't save all values of variables for some reason :(

Jeremi360 commented 5 years ago

To replicate the bug:

  1. run project
  2. choose "new game"
  3. go forward until get to part with testing animation
  4. save game
  5. close game
  6. run project
  7. load saved game
  8. see if animation is playing
  9. see if you can go further
MatiasVME commented 5 years ago

Hello, the error is with the persistence node ... when loading the data is erased. I did a test in beta11.

....

Well, I fixed that, but it only happened when you didn't use profiles.

I will try to do several tests for the persistence node to see if everything is working correctly.

Jeremi360 commented 5 years ago

@MatiasVME Thanks for your help. How you discover that "when loading the data is erased" ? I don't know why bug is happening - I didn't change anything in side save/load methods for months.

Jeremi360 commented 5 years ago

Ups!

MatiasVME commented 5 years ago

Let me explain... My english is bad..

I found a bug in PersistenceNode, but this only affects projects that don't use this:

Persistence.get_data("blabla") # No error

They're using this:

$Persistence.get_data() # Error

The PersistenceNode in the Rakugo project should not have problems. (I think)

Yesterday I was trying to see the error and I don't know what's going on.

Jeremi360 commented 5 years ago

@MatiasVME I use $Persistence.get_data(), so I have an error and I should make PersistenceNode as singleton yes? Also I see that you did update then addon should I update it?

MatiasVME commented 5 years ago

Just change the following line:

https://github.com/jebedaia360/Rakugo/blob/9e62ec328790f654a2351a9334016dfedf737cde/addons/PersistenceNode/persistence_node.gd#L410

To:

if profile_name == "":

But I don't think that solves the rakugo error.

In a while I'm going to do some tests with PersistenceNode to see if everything is working correctly.

Edit: And singleton is for the range, there is no other effect with it.

MatiasVME commented 5 years ago

Also so I saw you're not using get_data() without arguments.

matias@matias-Lenovo-ideapad-110-14ISK:/media/disco/git/Ren$ grep -rni 'get_data()'
gui/Screens/Screens.gd:159: return get_viewport().get_texture().get_data()
Jeremi360 commented 5 years ago

@MatiasVME I will fix this and update to 1.4.0 version of PersistenceNode. Next time when you update PersistenceNode tell me.

MatiasVME commented 5 years ago

This is the last version and the tests are correct.

https://github.com/MatiasVME/Persistence/releases/tag/v1.4.0-Godot.3.1

Jeremi360 commented 5 years ago

@MatiasVME "Also so I saw you're not using get_data() without arguments" ? gui/Screens/Screens.gd:159: return get_viewport().get_texture().get_data() - This is correct code it is not connected with yours PersistenceNode.

Jeremi360 commented 5 years ago

Bug continues to occur - it seems that for some reason not, all vars are saved. I will try to make some code in main.gd less clutter - maybe it will fix it or make it easy to fix.

MatiasVME commented 5 years ago

That's all I was saying, since the grep command shows all the strings in which 'get_data()' is used in the project.

The line: gui/Screens/Screens.gd:159: return get_viewport().get_texture().get_data()

It is not related to persistence node.

If you run it with beta7 or 8, does it work?

Jeremi360 commented 5 years ago

for me this line worked in every beta, also it is impossible to use this 'get_data()` with any arguments.

Jeremi360 commented 5 years ago

I update to PersistenceNode 1.4.0 , and made code of rakugo simpler, cleaner and less clutter. Switched PersistenceNode to Text mode to check if it fix any thing with save/load. And now when I try to load I get this:

[PersistenceNode] El archivo no existe: user://saves/default.save  
[PersistenceNode] retorna false.  
[PersistenceNode] El archivo no existe: user://saves/default.save  
[PersistenceNode] load_profile_default retorna false.  
MatiasVME commented 5 years ago

I've been watching, and I don't know what's gonna happen. S:

Jeremi360 commented 5 years ago

I fixed PersistenceNode profile name checking, and it save, but for some reason characters after load are null, and some variables was saved with starting value - but it all is saved in the same way :( I will try write better RakugoVar types - maybe it will fix some thing.

Jeremi360 commented 5 years ago

I try check some older version of rakugo, but all of theme has this bug :/ It seams that it was only working because of some bug in godot, which was fixed in 3.1

MatiasVME commented 5 years ago

But do you think it's the PersistenceNode?

The tests are fine, if you think a test is missing you can add it to the repo de persistence node.

Jeremi360 commented 5 years ago

Is there test for dictionary and array? I save big dictionary with alot of dictionaries in it - maybe I should do it easier - saves these dictionaries with as data with out this one extra dictionary that's keep them together

MatiasVME commented 5 years ago

I've previously tested with giant dictionaries (in my game Spaceship Shooter RPG Deluxe). But I haven't tested the PeristenceNode version for 3.1 with giant dictionaries.

I'll try to see what happens in Rakugo later.

Jeremi360 commented 5 years ago

I will compare current main.gd with main.gd from 1.0 - maybe this way I will find what is wrong.

Jeremi360 commented 5 years ago

It didn't help. But I got idea to add saved nodes to "save" group and use it to update its var base before save. I also need to check all ifs in jump()

Jeremi360 commented 5 years ago

Fixed jump() now after load you can go further :D #131

Jeremi360 commented 5 years ago

It fixed in resource-save branch :D , but bug with that you can't go further is back https://youtu.be/8amzuitYWtI

Jeremi360 commented 5 years ago

but bug with that you can't go further is back

:arrow_up: fixed :D

But this save system/load need few tweaks

Jeremi360 commented 5 years ago

Fixed an merged #135