diff options
Diffstat (limited to 'not/Selector.lua')
-rw-r--r-- | not/Selector.lua | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/not/Selector.lua b/not/Selector.lua index d96c2f9..00cf5a0 100644 --- a/not/Selector.lua +++ b/not/Selector.lua @@ -14,7 +14,7 @@ function Selector:new (list, group, parent) self.delay = Selector.DEFAULT_DELAY self.shape = Selector.SHAPE_PORTRAIT self.focused = false - self.locked = false + self.lock = false self.index = 1 end @@ -56,9 +56,9 @@ function Selector:getSelected () end --- Checks if selection is locked and returns item's value. --- @return item selected from the list if locked, nil otherwise +-- @return item selected from the list if Selector is locked, nil otherwise function Selector:getLocked () - if self.locked then + if self.lock then return self:getSelected() end end @@ -118,4 +118,24 @@ function Selector:update (dt) end end +function Selector:controlpressed (set, action, key) + if set and self.focused then + if not self.lock then + if action == "left" then + self:setIndex(self.index - 1) + end + if action == "right" then + self:setIndex(self.index + 1) + end + if action == "attack" then + self.lock = true + end + end + + if action == "jump" then + self.lock = false + end + end +end + return Selector |