Skip to content
Browse files

remove duplicated code

  • Loading branch information...
1 parent 07467f5 commit c29fe67f4335943081654b435540e1b62ee5a535 @esmil esmil committed Jan 18, 2012
Showing with 6 additions and 42 deletions.
  1. +6 −42 drinkomatic.lua
View
48 drinkomatic.lua
@@ -88,48 +88,6 @@ end
--- declare states ---
-IDLE = {
- card = login,
-
- barcode = function(code)
- print(" Price check..")
-
- local r = assert(db:fetchone(
- "SELECT name, price FROM products WHERE barcode = ?", code))
- if r == true then
- print " Unknown product."
- return 'MAIN'
- end
-
- product_dump(r)
- return 'MAIN'
- end,
-
- keyboard = {
- ['*'] = function()
- main_menu()
- return 'MAIN'
- end,
- ['1'] = function()
- print " Please enter user name (or press enter to abort):"
- return 'NEWUSER_NAME'
- end,
- ['2'] = function()
- print(" Scan barcode (or press enter to abort):")
- return 'PROD_CODE'
- end,
- [''] = function()
- print(" ENTAR!")
- return 'MAIN'
- end,
- function(cmd) --default
- print(" Unknown command '%s'.", cmd)
- main_menu()
- return 'MAIN'
- end,
- },
-}
-
MAIN = {
wait = timeout,
timeout = idle,
@@ -175,6 +133,12 @@ MAIN = {
},
}
+IDLE = {
+ card = MAIN.card,
+ barcode = MAIN.barcode,
+ keyboard = MAIN.keyboard,
+}
+
NEWUSER_NAME = {
wait = 120, -- allow 2 minutes for typing account name
timeout = function()

0 comments on commit c29fe67

Please sign in to comment.
Something went wrong with that request. Please try again.