Advertisement
Sunspider

Twine Persistent Vars Initializer Passage

Jan 4th, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. I run this passage at the start, to initialize the memory object's variables (so there's default values if there's nothing stored in Local Storage, and attempt to load the memory object from Local Storage, overwriting the defaults.
  2.  
  3. <<set $memory to {
  4. name: "Default",
  5. madeImportantChoice: false
  6. }>>
  7. <<set $memory to setup.loadMemory()>>
  8.  
  9. <<if ndef $memory>>
  10. <<set $memory to {
  11. name: "",
  12. madeImportantChoice: false
  13. }>>
  14. <<run setup.saveMemory()>>
  15. <</if>>
  16. <<if $memory is null>>
  17. <<set $memory to {
  18. name: "",
  19. madeImportantChoice: false
  20. }>>
  21. <<run setup.saveMemory()>>
  22. <</if>>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement