SSK2: ShuffleBag - persistance question.

Using the shufflebag feature of SSK2 I have a number of items (20 atm) that are selected at random using.  The problem I’m having is that I’d like the bag to stay shuffled between games.  Is there a way I can save and load a bags current state.  I don’t want it reshuffled until all of the items have been used (however many games that takes).

Not directly, but I think it wouldn’t be too hard to modify the bag module to make it persistent.

In fact, I would probably add functionality to the bag module that directly uses the persist module.  This will allow you to update the ‘persisted’ state every time you modify the bag and still get good performance.  i.e. You would end up temporarily deferring writes to the actual storage when modifying the bag repeatedly in a short period of time.

Let me think about this a bit and if I can see an easy way to add this I’ll let you know tonight.

Shuffle bag updated. Docs NOT updated.

Download updated SSK2 here: https://github.com/roaminggamer/SSK2/raw/master/ssk2.zip

Get example here:

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2019/05/persistentShuffleBags.zip

To save state of bag:

bag:save( "testBag.json" )

To restore state of bag:

bag:restore( "testBag.json" )

Magic!

Thanks so much.  You’re an absolute star!

Not directly, but I think it wouldn’t be too hard to modify the bag module to make it persistent.

In fact, I would probably add functionality to the bag module that directly uses the persist module.  This will allow you to update the ‘persisted’ state every time you modify the bag and still get good performance.  i.e. You would end up temporarily deferring writes to the actual storage when modifying the bag repeatedly in a short period of time.

Let me think about this a bit and if I can see an easy way to add this I’ll let you know tonight.

Shuffle bag updated. Docs NOT updated.

Download updated SSK2 here: https://github.com/roaminggamer/SSK2/raw/master/ssk2.zip

Get example here:

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2019/05/persistentShuffleBags.zip

To save state of bag:

bag:save( "testBag.json" )

To restore state of bag:

bag:restore( "testBag.json" )

Magic!

Thanks so much.  You’re an absolute star!