Guest User

Untitled

a guest
Dec 18th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.27 KB | None | 0 0
  1. -- ItemCounter by redled72 5/2012
  2.  
  3. cdel  = ("right")         -- Reset Counter (Button, Switch...)
  4. cin   = ("left")          -- Input Counter (RP-Signal, Redstonepipe...)
  5. cout  = ("back")          -- Input Counter (RP-Signal, Redstonepipe...)
  6.  
  7. local s      = 0
  8. local inp    = false
  9. local z      = 0
  10. local stack  = 0
  11. local stueck = 0
  12. local count  = 0
  13.  
  14. function _latch(inp)      -- Counter
  15.          if inp == true then
  16.             count = count + 1
  17.             while rs.getInput(cin) == inp do
  18.                   sleep(0.05)
  19.             end
  20.          end
  21.  
  22.          if rs.getInput(cdel) == true then
  23.             count = 0
  24.          end
  25.          sleep(0.05)
  26.    return count
  27. end
  28.  
  29. function _str(z)          -- Stack/Stueckrechnung
  30.          sta = math.floor(z / 64)
  31.          stu = math.fmod(z, 64)
  32.    return sta, stu
  33. end
  34.  
  35. function _ascii()
  36.           out = string.char(98,121,32,82,101,100,108,101,100,55,50)
  37.     return out
  38.  end
  39.  
  40. while s == 0 do           -- Loop Hauptschleife  
  41.          inp = rs.getInput(cin)
  42.          z = _latch(inp)  
  43.          stack, stueck = _str(z)
  44.          shell.run("clear")
  45.    print("        Item = Samen")
  46.    print("       Stueckzahl: " ..z.. " ")
  47.          print("       Anzahl in Stack")
  48.    print("      " ..stack.." Stack & " ..stueck.. " Stück")
  49. end
  50.  
  51. print(newline)
  52. print("\"CC-ItemCounter\" " .._ascii().. "")
Add Comment
Please, Sign In to add comment