summaryrefslogtreecommitdiffhomepage
path: root/not/Selector.lua
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-09-05 02:36:08 +0200
committerAki <nthirtyone@gmail.com>2017-09-05 02:36:08 +0200
commit975e5663c09f0d74b2d0a18a7a5ce1297362a4a2 (patch)
tree05c7c998b402b5056218da8439bdf98de73d7342 /not/Selector.lua
parent7f524270713a558c0538c7d728271121928a60ec (diff)
downloadroflnauts-975e5663c09f0d74b2d0a18a7a5ce1297362a4a2.zip
roflnauts-975e5663c09f0d74b2d0a18a7a5ce1297362a4a2.tar.gz
roflnauts-975e5663c09f0d74b2d0a18a7a5ce1297362a4a2.tar.bz2
Moved selector's action handlers outside controlpressed method
Diffstat (limited to 'not/Selector.lua')
-rw-r--r--not/Selector.lua37
1 files changed, 23 insertions, 14 deletions
diff --git a/not/Selector.lua b/not/Selector.lua
index ed1813f..bd6224b 100644
--- a/not/Selector.lua
+++ b/not/Selector.lua
@@ -145,23 +145,32 @@ 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
- -- TODO: Extend functionality on attack action in Selector.
- if action == "attack" then
- self.lock = true
- end
+ local handler = self[action]
+ if handler then
+ handler(self)
end
+ end
+end
- if action == "jump" then
- self.lock = false
- end
+function Selector:left ()
+ if not self.lock then
+ self:setIndex(self.index - 1)
+ end
+end
+
+function Selector:right ()
+ if not self.lock then
+ self:setIndex(self.index + 1)
end
end
+function Selector:attack ()
+ self.lock = true
+end
+
+-- Selector doesn't actually jump, haha, I tricked you!
+function Selector:jump ()
+ self.lock = false
+end
+
return Selector