Advertisement
Guest User

Untitled

a guest
Jan 16th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.66 KB | None | 0 0
  1. function onSave()
  2.     local data_to_save = {saved_count1 = countHP, saved_count2 = countMP}
  3.     saved_data = JSON.encode(data_to_save)
  4.     return saved_data
  5. end
  6.  
  7. --Loads the saved data then creates the buttons
  8. function onload(saved_data)
  9.     generateButtonParamiters()
  10.     --Checks if there is a saved data. If there is, it gets the saved value for 'count'
  11.     if saved_data != '' then
  12.         local loaded_data = JSON.decode(saved_data)
  13.         countHP = loaded_data.saved_count1
  14.         countMP = loaded_data.saved_count2
  15.     else
  16.         --If there wasn't saved data, the default value is set to 10.
  17.         countHP = 0
  18.         countMP = 0
  19.     end
  20. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement