Hi. I created simple save/load system for my project and since there currently aren't any other save/load systems in GameGuru, I'll share it here in case somebody needs one.
Save and Load game script
Jussi Palomäki a.k.a. Moshroom. (Parts of the script are based on the default scripts of GameGuru.)
Edit freely, use in any project (non-commercial or commercial) with GameGuru. Name me as script creator if you find this useful.
The script creates simple save prompt that let's the player save his/her progress to up to 10 slots. The moshroom_savepoint script creates a .dat file that stores player health, player lives and Counter table with 100 variables ("Counters"). These can be loaded with moshroom_loadpoint script.
Counters are used to save entity data. There are currently three scripts that are compatible with Counters: moshroom_ai_keymaster, moshroom_remotedoor and moshroom_health. Keymaster is a character that opens the remote door when player first talks to him/her. Health is based on default health script and the only difference between this and the original is that this adds the Counter table.
The best way to use my script is to create one large map with save- and loadpoints at the center and lots of unlockable features that open new sections of the map.
Setting up the save and load points
1) Create an entity with Static Mode boolean set to NO and ai system (script) set to moshroom_loadpoint.lua.
2) Repeat step 1 with moshroom_savepoint.lua. This script introduces the Counter table so you probably should set the Always active boolean to YES if you have large map (at least I think... not 100 % sure about this).
Setting the save/load system compatible entities
3) Create an entity with Static Mode boolean set to NO and ai system (script) set to moshroom_ai_keymaster, moshroom_remotedoor or moshroom_health
4) Set the name of your keymaster AND remotedoor entities to a number between 1 and 100 (one number per one pair). This links them together and to Counter table, which allows the save/load system to store whether player has talked to keymaster to trigger unlocking of the door
5) Set the name of your health item to a number between 1 and 100 (different than any keymaster/remotedoor pair). This links it to Counter table which allows the save/load system to store whether the item has been picked up or not.
6) Make sure there is only one keymaster/remotedoor pair or health item per each Counter (in other words, make sure that every keymaster/remotedoor pair and health item has different numbers as a name).
There are some limitations
that are due to lack of certain LUA command in the current GameGuru version. Please read carefully:
- data can be only saved from entities that use the Counter table
- player position can't be loaded
- weapon data can't be saved nor loaded
- everything happens in single map
A workaround is probably possible for at least the last three of these limitations, but it requires game-specific manual editing of the script. Unless new LUA commands are added to GameGuru, these will probably never work out-of-box. It's left to be seen whether new LUA commands will be available before the official save/load system (which is currenlty at top at the feature vote).
(inclues all 5 lua:s mentioned here and very simple example map)
(savepoint, loadpoint, ai_keymaster and remotedoor)
moshroom_savepoint.lua (version 2.0, 11.11.2015)
moshroom_loadpoint.lua (version 2.0, 11.11.2015)
moshroom_health.lua (version 2.0, saves "Healing Potion" to inventory, if inventory is available, 12.11.2015)
moshroom_magic.lua (version 2.0, saves "Magic Source" to inventory, if inventory is available, 12.11.2015)