Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

SSK2: ShuffleBag - persistance question.
Started by Appletreeman May 26 2019 12:51 PM

4 replies to this topic

Best Answer roaminggamer , 26 May 2019 - 04:51 PM

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" )
 
 

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Appletreeman

[GLOBAL: userInfoPane.html]
Appletreeman
  • Contributor

  • 434 posts
  • Corona SDK

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).



[TOPIC: post.html]
#2

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,569 posts
  • Corona SDK

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.



[TOPIC: post.html]
#3

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,569 posts
  • Corona SDK

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



[TOPIC: post.html]
#4

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,569 posts
  • Corona SDK

  Best Answer

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" )
 
 

  • Appletreeman likes this

[TOPIC: post.html]
#5

Appletreeman

[GLOBAL: userInfoPane.html]
Appletreeman
  • Contributor

  • 434 posts
  • Corona SDK

Magic!

Thanks so much.  You're an absolute star!




[topic_controls]
[/topic_controls]