diff options
author | Aki <nthirtyone@gmail.com> | 2016-08-24 06:43:11 +0200 |
---|---|---|
committer | Aki <nthirtyone@gmail.com> | 2016-08-24 06:43:11 +0200 |
commit | b739e555026471db11e24cb4a92f55509e717761 (patch) | |
tree | cce6b2cf377edd8290b96dd95e9eaf88727b0d42 | |
parent | 4bb25bb6c752efba17ffbc97bd4de9b3f33a190b (diff) | |
download | roflnauts-b739e555026471db11e24cb4a92f55509e717761.zip roflnauts-b739e555026471db11e24cb4a92f55509e717761.tar.gz roflnauts-b739e555026471db11e24cb4a92f55509e717761.tar.bz2 |
Unique joysticks for sets
-rw-r--r-- | controller.lua | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/controller.lua b/controller.lua index 5ed7dd2..fde63c1 100644 --- a/controller.lua +++ b/controller.lua @@ -16,6 +16,7 @@ function Controller.controlreleased(set, action, key) end -- Create new controls set. function Controller.registerSet(left, right, up, down, attack, jump, joystick) + if not Controller.isJoystickUnique(joystick) then return end local set = {} set.left = left or "left" set.right = right or "right" @@ -34,6 +35,16 @@ function Controller.getSets() return Controller.sets end +-- Checks if given joystick is unique in current set of Controller sets +function Controller.isJoystickUnique(joystick) + if joystick ~= nil then + for _,set in pairs(Controller.sets) do + if set.joystick == joystick then return false end + end + end + return true +end + -- Tests all sets if they have control assigned to given key and joystick. function Controller.testSets(key, joystick) for i,set in pairs(Controller.sets) do |