From 6d81b4c2e65593218bb2a8ee322d083e362c7ab1 Mon Sep 17 00:00:00 2001 From: Aki Date: Mon, 4 Sep 2017 22:37:47 +0200 Subject: Basic interaction and changes to lock mechanic --- not/Selector.lua | 26 +++++++++++++++++++++++--- 1 file 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 -- cgit v1.1