Page 1 of 3 123 LastLast
Results 1 to 20 of 56
  1. #1
    Member Cotaks's Avatar
    Join Date
    May 2012
    Location
    The Netherlands
    Posts
    1,235

    Save and Load script v3.0 by cotax

    Hello,

    * New version *
    3.0 - it now saves the GD to a file and location of choice (8-4-2016).


    It saves:
    - position
    - orientation
    - properties
    - Linear and Angular velocities


    How it works:
    Every scene that gets saved needs an object(any name) with a property: spawner. This to define the object spawner in the scene (best is just an empty).

    Objects u want to save needs a property called: save -> boolean.
    True = # saving inactive objects (objects that are added(spawned) like the cube)
    False = # saving object that arent added and are in the main layer

    To load use python->module->name_of_script.load (check menu scene).
    To save use python->module->name_of_script.save (check menu scene).

    you can change the file name and path to your likings (some directories may need admin rights).

    This script is verry easy to use, from a menu or from whatever scene/object you want to use it
    or simply keybind it.


    Here you see the console output (at saving, you see the property "save" state (true/false) behind the object)



    And here you find the .blend version 3.0:
    save_and_load 3.0.blend


    Old version 2.2 save to globaldict
    save_and_load 2.2.blend


    Thats it, hope you like it,
    Cotax
    Attached Images Attached Images
    Last edited by Cotaks; 08-Apr-16 at 09:06.
    '- It's not working' then check your console like: this
    Did you know that you can make a complete game with the .blends that i share?



  2. #2
    Member
    Join Date
    Feb 2011
    Location
    Belgium
    Posts
    1,395
    Hi, nicely done. But maybe you want to check line 28. It should be enough to just convert to a list:
    Code:
    position = list(obj.worldPosition)
    Edit: I especially like it because when the globalDictionary is saved, it seems to be encrypted too. I didn't know that.
    Last edited by Raco; 11-Jan-15 at 06:48.



  3. #3
    Member Cotaks's Avatar
    Join Date
    May 2012
    Location
    The Netherlands
    Posts
    1,235
    Originally Posted by Raco View Post
    Hi, nicely done. But maybe you want to check line 28. It should be enough to just convert to a list:
    Code:
    position = list(obj.worldPosition)
    Edit: I especially like it because when the globalDictionary is saved, it seems to be encrypted too. I didn't know that.
    Hi, thank you.

    You are right about the position, gonna adjust that in the blend and re upload it.

    Thank you for your sharp eye
    '- It's not working' then check your console like: this
    Did you know that you can make a complete game with the .blends that i share?



  4. #4
    Member solarforge's Avatar
    Join Date
    Jul 2013
    Location
    Europe
    Posts
    384
    Thanks for sharing this, I tried many times to make something similar but with no success...

    For sure I will try and integrate it into a game...
    Last edited by solarforge; 11-Jan-15 at 09:02.



  5. #5
    Member Cotaks's Avatar
    Join Date
    May 2012
    Location
    The Netherlands
    Posts
    1,235
    Originally Posted by solarforge View Post
    Thanks for sharing this, I tried many times to make something similar but with no success...

    For sure I will try and integrate it into a game...
    No problem, glad that people can use it!
    Have fun with it.
    '- It's not working' then check your console like: this
    Did you know that you can make a complete game with the .blends that i share?



  6. #6
    Member adriansnetlis's Avatar
    Join Date
    Jun 2014
    Location
    Latvia
    Posts
    4,304
    Does it have some tweakables to set for different scene names etc?
    My Blogspot my 3d development blog. I am at GTM + 2.00 time belt! Intel® Core™ i5-6300HQ 2.3 GHz(quadcore), NVIDIA GeForce GTX960M, 4GB DDR4 RAM, Linux Ubuntu 16.04.
    Worn Tires, Engine Roar, AstrumNetwork.com, Support me in Patreon



  7. #7
    Member Cotaks's Avatar
    Join Date
    May 2012
    Location
    The Netherlands
    Posts
    1,235
    Originally Posted by adriansnetlis View Post
    Does it have some tweakables to set for different scene names etc?
    yes and no, not physically, u need to understand python abit. this save and load saves everything in the main scene.

    Edit:
    As of save_and_load 2.0 it saves every active scene
    Last edited by Cotaks; 12-Jan-15 at 16:23.
    '- It's not working' then check your console like: this
    Did you know that you can make a complete game with the .blends that i share?



  8. #8
    Member adriansnetlis's Avatar
    Join Date
    Jun 2014
    Location
    Latvia
    Posts
    4,304
    Main Scene? And... Do I have to set Main Scene somehow? Or is it possible to apply that script to another scene?
    My Blogspot my 3d development blog. I am at GTM + 2.00 time belt! Intel® Core™ i5-6300HQ 2.3 GHz(quadcore), NVIDIA GeForce GTX960M, 4GB DDR4 RAM, Linux Ubuntu 16.04.
    Worn Tires, Engine Roar, AstrumNetwork.com, Support me in Patreon



  9. #9
    Member adriansnetlis's Avatar
    Join Date
    Jun 2014
    Location
    Latvia
    Posts
    4,304
    Actually, ould you tell me, please, how to make this save method:

    Scene "Settings" object contains 4 properties which must be saved each time player presses "ESC"(exits to main menu). It must also always load theese properties when player enters that scene(properties are: "Volume"(int), "r"(float), "g"(float) and "b"(float)). Scene Level_1 contains object with the same named and the same type properties. It must read the data saved from "Settings" scene and load them(so it is possible to set car color trought settings, and also volume. And... The last thing... In scene "Level_1" there is a property called "points"(int). This property also belongs to car. I need that pproperty to be saved, always loaded and than loaded in another scene which contains scores. But in that scene it must be loaded with name "LV1points". Could you help me with this by creating that script, than explaining how to add more porperties in that system?
    My Blogspot my 3d development blog. I am at GTM + 2.00 time belt! Intel® Core™ i5-6300HQ 2.3 GHz(quadcore), NVIDIA GeForce GTX960M, 4GB DDR4 RAM, Linux Ubuntu 16.04.
    Worn Tires, Engine Roar, AstrumNetwork.com, Support me in Patreon



  10. #10
    Member Cotaks's Avatar
    Join Date
    May 2012
    Location
    The Netherlands
    Posts
    1,235
    Originally Posted by adriansnetlis View Post
    Main Scene? And... Do I have to set Main Scene somehow? Or is it possible to apply that script to another scene?
    No you don't have to set a scene, it assumes that your "game scene" is the one that runs first, then you load hud and any other overlays/underlays.

    As for your other questions, no i don't make scripts, you should learn python in order to build it on your own.
    i share this for people who can't write a save/load system. if you can use it, use it, else i am sorry.

    (score and hud elements are coming from the main scene right? so give the wearer of the stats the property save)


    Edit:
    As of save_and_load 2.0 it saves every active scene
    Last edited by Cotaks; 12-Jan-15 at 16:24.
    '- It's not working' then check your console like: this
    Did you know that you can make a complete game with the .blends that i share?



  11. #11
    Member
    Join Date
    Feb 2011
    Location
    Belgium
    Posts
    1,395
    @ cotax: I've made a blend with a save and load system, based on yours, which will also save scenes. If you appreciate it, I can post it here. It also stores velocities. Let me know.



  12. #12
    Member Cotaks's Avatar
    Join Date
    May 2012
    Location
    The Netherlands
    Posts
    1,235
    Originally Posted by Raco View Post
    @ cotax: I've made a blend with a save and load system, based on yours, which will also save scenes. If you appreciate it, I can post it here. It also stores velocities. Let me know.
    Ill leave that up to you. If you want you can post it inhere.


    EDIT: I've rebuild my save and load to fit the demands, it now saves all active scenes.
    - Changed info in the first topic

    Have fun with it, Cotax
    Last edited by Cotaks; 12-Jan-15 at 13:19.
    '- It's not working' then check your console like: this
    Did you know that you can make a complete game with the .blends that i share?



  13. #13
    Member
    Join Date
    Feb 2011
    Location
    Belgium
    Posts
    1,395
    Originally Posted by cotax View Post
    Ill leave that up to you. If you want you can post it inhere.
    EDIT: I've rebuild my save and load to fit the demands, it now saves all active scenes.
    The mechanics are a little different. It also saves velocities. And it can save as many scenes as you want. I didn't make it so that it saves all active scenes, but just the active scene. The overlay scene should be an extension of the active scene anyway. So you should program it like so, so that whatever you save in the active scene, it will be updated in the overlay scene. The only condition is to give a property to all inactive objects that will be instanced in the active scene.
    Attached Files Attached Files
    Last edited by Raco; 12-Jan-15 at 13:55.



  14. #14
    Member Cotaks's Avatar
    Join Date
    May 2012
    Location
    The Netherlands
    Posts
    1,235
    I didn't make it so that it saves all active scenes, but just the active scene. The overlay scene should be an extension of the active scene anyway
    True, but if u do it right the "hud" will be removed when u open the menu(so it is not active anymore), and will be added again when leaving the menu.
    '- It's not working' then check your console like: this
    Did you know that you can make a complete game with the .blends that i share?



  15. #15
    Member adriansnetlis's Avatar
    Join Date
    Jun 2014
    Location
    Latvia
    Posts
    4,304
    Hi, COTAX! I have a question- could you tell me how do I write that dictionary(where you save it(I think it was globalDict)) to the file and than read it so I can also save data when I exit game? It would be very useful...
    My Blogspot my 3d development blog. I am at GTM + 2.00 time belt! Intel® Core™ i5-6300HQ 2.3 GHz(quadcore), NVIDIA GeForce GTX960M, 4GB DDR4 RAM, Linux Ubuntu 16.04.
    Worn Tires, Engine Roar, AstrumNetwork.com, Support me in Patreon



  16. #16
    Member adriansnetlis's Avatar
    Join Date
    Jun 2014
    Location
    Latvia
    Posts
    4,304
    Actually, it saves a .bgeconfig file when I test your dome, but when I implement it in my game, it works only in session, but doesn't make a file... How to fix it?
    My Blogspot my 3d development blog. I am at GTM + 2.00 time belt! Intel® Core™ i5-6300HQ 2.3 GHz(quadcore), NVIDIA GeForce GTX960M, 4GB DDR4 RAM, Linux Ubuntu 16.04.
    Worn Tires, Engine Roar, AstrumNetwork.com, Support me in Patreon



  17. #17
    Member adriansnetlis's Avatar
    Join Date
    Jun 2014
    Location
    Latvia
    Posts
    4,304
    Code:
    Blender Game Engine Started
    Python module can't be imported - object 'Cell.001', controller 'Python':
    ImportError: No module named 'Cell'
    SAVING (Slot1gameplay)
     - Player (False)
     - cell2 (False)
     - Equipment (False)
     - cell1 (False)
     - Playercam (False)
     - DayNight (False)
     - SkySphere (False)
     - Stick (True)
     - Stick (True)
    Error, bge.logic.globalDict could not be marshal'd
    Warning: could not create marshal buffer
    Python script error - object 'save', controller 'save':
    Traceback (most recent call last):
      File "/home/user/Adriana_Faili/Games/FloatedAway/CreationZone/FloatedAway.blend/save.py", line 23, in save
    ValueError: unmarshallable object
    warning: scene InventoryHUD already exists, not added!
    warning: scene HUD does not exist, not removed!
    warning: scene InventoryHUD already exists, not added!
    warning: scene HUD does not exist, not removed!
    warning: scene InventoryHUD already exists, not added!
    warning: scene HUD does not exist, not removed!
    warning: scene InventoryHUD already exists, not added!
    warning: scene HUD does not exist, not removed!
    Blender Game Engine Finished
    
    
    Blender Game Engine Started
    Python module can't be imported - object 'Cell.001', controller 'Python':
    ImportError: No module named 'Cell'
    SAVING (InventoryHUD)LOADING (Slot1gameplay) removing objects
     - removing Stick
     - removing Stick
    All OBJECTS ARE REMOVED
    LOADING (Slot1gameplay) -> spawn objects
    Warning: could not open '/home/user/Adriana_Faili/Games/FloatedAway/CreationZone/FloatedAway.bgeconf'
    Python script error - object 'load', controller 'load':
    Traceback (most recent call last):
      File "/home/user/Adriana_Faili/Games/FloatedAway/CreationZone/FloatedAway.blend/save.py", line 84, in load
      File "/home/user/Adriana_Faili/Games/FloatedAway/CreationZone/FloatedAway.blend/save.py", line 107, in spawn_object
    KeyError: 'save game'
    Saved session recovery to '/tmp/quit.blend'
    Error: Not freed memory blocks: 59
    
    
    Blender quit
    The console output. Maybe this can help you to figure out my problem...
    My Blogspot my 3d development blog. I am at GTM + 2.00 time belt! Intel® Core™ i5-6300HQ 2.3 GHz(quadcore), NVIDIA GeForce GTX960M, 4GB DDR4 RAM, Linux Ubuntu 16.04.
    Worn Tires, Engine Roar, AstrumNetwork.com, Support me in Patreon



  18. #18
    Member adriansnetlis's Avatar
    Join Date
    Jun 2014
    Location
    Latvia
    Posts
    4,304
    OK! I am going to post the .blend file so you just tell me why it doesn't save the .bgeconf file. What's wrong with it???
    http://www.pasteall.org/blend/35046
    Last edited by adriansnetlis; 16-Mar-15 at 02:35.
    My Blogspot my 3d development blog. I am at GTM + 2.00 time belt! Intel® Core™ i5-6300HQ 2.3 GHz(quadcore), NVIDIA GeForce GTX960M, 4GB DDR4 RAM, Linux Ubuntu 16.04.
    Worn Tires, Engine Roar, AstrumNetwork.com, Support me in Patreon



  19. #19
    Member adriansnetlis's Avatar
    Join Date
    Jun 2014
    Location
    Latvia
    Posts
    4,304
    And, by the way, could you tell me how do I also save linear and angular velocity with this?
    My Blogspot my 3d development blog. I am at GTM + 2.00 time belt! Intel® Core™ i5-6300HQ 2.3 GHz(quadcore), NVIDIA GeForce GTX960M, 4GB DDR4 RAM, Linux Ubuntu 16.04.
    Worn Tires, Engine Roar, AstrumNetwork.com, Support me in Patreon



  20. #20
    Member
    Join Date
    May 2007
    Location
    somewhere north of Syracuse
    Posts
    450
    Thank you for this script. It works very well. Now with a functioning save/load maybe I'll move from 2.49 to 2.73.

    One thing I did notice. If you have a Text property parented to the camera in the main scene, (like Socials FPS, Ammo, Mags, Text) it saves the location of the planes it's mapped to. LOL Then when saved, ends up off the camera. LOL I'll play with the code later to see if I can stop it from saving objects positions, and save only Text properties.

    Thanks again.



Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •