Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cdel = ("right") -- Reset Counter (Button, Switch...)
- cin = ("left") -- Input Counter (RP-Signal, Redstonepipe...)
- cout = ("back") -- Input Counter (RP-Signal, Redstonepipe...)
- local s = 0
- local inp = false
- local z = 0
- local stack = 0
- local stueck = 0
- local count = 0
- if fs.exists('count') then
- local oFile=io.open('count','r')
- count=tonumber(oFile:read())
- oFile:close()
- else
- local count=0
- end
- local tSides={input='left';reset='right';output='back'}
- local bInput=rs.getInput(tSides['input'])
- while true do
- os.pullEvent('redstone')
- if rs.getInput(tSides['input']) and rs.getInput(tSides['input'])~=bInput then
- bInput=rs.getInput(tSides['input'])
- count=count+1
- local oFile=io.open('count','w')
- oFile:write(count)
- oFile:close()
- elseif rs.getInput(tSides['reset']) then
- fs.delete('count')
- count=0
- elseif rs.getinput(tsides['back']) then
- count=count-1
- local oFile=io.open('count','w')
- oFile:write(count)
- oFile:close()
- end
- function _str(z) -- Stack/Stueckrechnung
- sta = math.floor(z / 64)
- stu = math.fmod(z, 64)
- return sta, stu
- end
- function _ascii()
- out = string.char(98,121,32,82,101,100,108,101,100,55,50)
- return out
- end
- while s == 0 do -- Loop Hauptschleife
- inp = rs.getInput(cin)
- z = _latch(inp)
- stack, stueck = _str(z)
- shell.run("clear")
- print(" Item = XXX")
- print(" Stueckzahl: " ..z.. " ")
- print(" Anzahl in Stack")
- print(" " ..stack.." Stack & " ..stueck.. " Stück")
- end
- end
- print(newline)
- print("\"CC-ItemCounter\" " .._ascii().. "")
Advertisement
Add Comment
Please, Sign In to add comment