From b80ba2f5a7bf7acbbbf14c1325fca8df3c39cac4 Mon Sep 17 00:00:00 2001 From: Aki Date: Sat, 14 Jan 2017 23:03:35 +0100 Subject: Fixed gamepad bug and overwrite bug --- config/menusettings.lua | 2 +- controller.lua | 6 ++++++ settings.lua | 7 +++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/config/menusettings.lua b/config/menusettings.lua index 1b19e84..3046781 100644 --- a/config/menusettings.lua +++ b/config/menusettings.lua @@ -48,7 +48,7 @@ local controlreleased = function(self, set, action, key) dimmer:set("visible", false) self.parent.allowMove = true self.inProgress = false - table.insert(self.newSet, Controller.sets[self.setNumber()][7]) + table.insert(self.newSet, Controller.sets[self.setNumber()].joystick) print(self.newSet[7]) Settings.change(self.setNumber(), self.newSet[1], self.newSet[2], self.newSet[3], self.newSet[4], self.newSet[5], self.newSet[6], self.newSet[7]) else diff --git a/controller.lua b/controller.lua index e435d63..f035162 100644 --- a/controller.lua +++ b/controller.lua @@ -30,6 +30,12 @@ function Controller.registerSet(left, right, up, down, attack, jump, joystick) return set end +-- Reset table of controls sets. +function Controller.reset() + local t = {} + Controller.sets = t +end + -- Get table of controls sets. function Controller.getSets() return Controller.sets diff --git a/settings.lua b/settings.lua index ad8b8e5..e73b997 100644 --- a/settings.lua +++ b/settings.lua @@ -11,6 +11,7 @@ function Settings.load() end local getSettings = love.filesystem.load("settings") Settings.current = getSettings() + Controller.reset() local joysticksList = love.joystick.getJoysticks() -- local list for editing for _,set in pairs(Settings.current) do local isJoystick = set[7] @@ -57,7 +58,9 @@ function Settings.change(n, left, right, up, down, attack, jump, joystick) else bool = false end + -- Save current settings Settings.current[n] = {left, right, up, down, attack, jump, bool} - table.remove(Controller.sets, n) - Controller.registerSet(left, right, up, down, attack, jump, joystick) + Settings.save() + -- Load settings + Settings.load() end \ No newline at end of file -- cgit v1.1