Advertisement
Guest User

Untitled

a guest
Jun 29th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.37 KB | None | 0 0
  1. function loadSettings()
  2.     defaultSettings()
  3.        
  4.     success, value = pcall(love.filesystem.read, "save.txt")
  5.  
  6.     netsucc, value = pcall(love.filesystem.read, "coop.txt")
  7.     if netsucc then
  8.         local netData = love.filesystem.read("coop.txt")
  9.  
  10.         if not netData then
  11.             return
  12.         end
  13.  
  14.         local keys = netData:split(";")
  15.  
  16.         for x = 1, #keys do
  17.             local keyPairs = keys[x]:split(":")
  18.  
  19.             if keyPairs[1] and keyPairs[2] then
  20.                 table.insert(serverList, {keyPairs[1], keyPairs[2], tonumber(keyPairs[3])})
  21.             end
  22.         end
  23.     end
  24.  
  25.     local saveData
  26.     if success then
  27.         saveData = love.filesystem.read("save.txt")
  28.        
  29.         if not saveData then
  30.             return
  31.         end
  32.  
  33.         local keys = saveData:split(";")
  34.  
  35.         for x = 1, #keys do
  36.             local keyPairs = keys[x]:split(":")
  37.  
  38.             local index, value = keyPairs[1], keyPairs[2]
  39.  
  40.             if index == "shoot" then
  41.                 controls[index] = value
  42.             elseif index == "ability" then
  43.                 controls[index] = value
  44.             elseif index == "left" then
  45.                 controls[index] = value
  46.             elseif index == "right" then
  47.                 controls[index] = value
  48.             elseif index == "dpad" then
  49.                 useDirectionalPad(util.toBoolean(value))
  50.             elseif index == "achievement" then
  51.                 achievements[tonumber(value)]:unlock()
  52.             elseif index == "highscore" then
  53.                 local split = value:split("~")
  54.  
  55.                 highscores[tonumber(split[1])] = {split[2], split[3], tonumber(split[4])}
  56.             end
  57.         end
  58.     end
  59. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement