summaryrefslogtreecommitdiffhomepage
path: root/not/Selector.lua
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-09-04 22:37:47 +0200
committerAki <nthirtyone@gmail.com>2017-09-04 22:37:47 +0200
commit6d81b4c2e65593218bb2a8ee322d083e362c7ab1 (patch)
treef8e81f669924cc7433422ad56d24d92f1a957586 /not/Selector.lua
parent5da2cf3f8dc86da6b35641b3bf462808bfab913b (diff)
downloadroflnauts-6d81b4c2e65593218bb2a8ee322d083e362c7ab1.zip
roflnauts-6d81b4c2e65593218bb2a8ee322d083e362c7ab1.tar.gz
roflnauts-6d81b4c2e65593218bb2a8ee322d083e362c7ab1.tar.bz2
Basic interaction and changes to lock mechanic
Diffstat (limited to 'not/Selector.lua')
-rw-r--r--not/Selector.lua26
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