Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----------------------------------
- -- file auslesen
- ----------------------------------
- if fs.exists('count') then
- local oFile=io.open('count','r')
- count=tonumber(oFile:read())
- oFile:close()
- else
- local count=0
- end
- ----------------------------------
- -- File auslesen ende
- ----------------------------------
- --
- ----------------------------------
- -- Variablen und Functions
- ----------------------------------
- local tSides={input='left';reset='right';output='back';monitor='top'}
- local bInput=rs.getInput(tSides['input'])
- local bInput2=rs.getInput(tSides['output'])
- local item = 'Cleanstone'
- local function display(count)
- term.clear()
- term.setCursorPos(1,1)
- print(" Item = "..item.." ")
- print(" Gesamt Vorrat = "..count)
- print(" entspricht")
- print(" "..math.floor(count/64).." Stacks & "..count%64)
- end
- ----------------------------------
- -- Variablen und Functions ende
- ----------------------------------
- --
- ----------------------------------
- -- Counter Section mit File write
- ----------------------------------
- term.redirect(peripheral.wrap('top'))
- while true do
- display(count)
- os.pullEvent('redstone')
- if rs.getInput(tSides['input']) and rs.getInput(tSides['input'])~=bInput then
- 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
- local oFile=io.open('count','w')
- oFile:write(count)
- oFile:close()
- elseif rs.getInput(tSides['output']) and rs.getInput(tSides['output'])~=bInput2 then
- count=count-1
- local oFile=io.open('count','w')
- oFile:write(count)
- oFile:close()
- end
- bInput=rs.getInput(tSides['input'])
- bInput2=rs.getInput(tSides['output'])
- end
- ---------------------------------------
- -- Counter Section mit File Write ende
- ---------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment