diff options
author | Aki <nthirtyone@gmail.com> | 2016-10-10 22:33:34 +0200 |
---|---|---|
committer | Aki <nthirtyone@gmail.com> | 2016-10-10 22:33:34 +0200 |
commit | 7e567d1fc37d8e65e4e8fe5c7ece2cea8a6567b1 (patch) | |
tree | 6a83204f6ff49b15d845a7456b285cec531d9286 /settings.lua | |
parent | 26199823381c0a9ee81a8eddde1d8c093c101685 (diff) | |
download | roflnauts-7e567d1fc37d8e65e4e8fe5c7ece2cea8a6567b1.zip roflnauts-7e567d1fc37d8e65e4e8fe5c7ece2cea8a6567b1.tar.gz roflnauts-7e567d1fc37d8e65e4e8fe5c7ece2cea8a6567b1.tar.bz2 |
Load controller sets from file
Diffstat (limited to 'settings.lua')
-rw-r--r-- | settings.lua | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/settings.lua b/settings.lua index 5b0e38a..920abdf 100644 --- a/settings.lua +++ b/settings.lua @@ -2,8 +2,20 @@ Settings = {} function Settings.load() if Controller then - Controller.registerSet("left", "right", "up", "down", "return", "rshift") - Controller.registerSet("a", "d", "w", "s", "g", "h") + if not love.filesystem.exists("settings") then + local def = love.filesystem.newFile("settings.default") + local new = love.filesystem.newFile("settings") + new:open("w") def:open("r") + new:write(def:read()) + new:close() def:close() + end + local getSettings = love.filesystem.load("settings") + for _,set in pairs(getSettings()) do + local isJoystick = set[7] + if isJoystick then + -- Add first free joystick from joysticks list + end + Controller.registerSet(set[1], set[2], set[3], set[4], set[5], set[6], joystick) + end end - print(love.filesystem.getIdentity(), love.filesystem.exists("settings.lua")) end |