Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- isRunning = true
- state ={"Waitint for Card", "CardReceived", "Wait", "Writing Card", "Card Complete"}
- curState=1
- function toPercent(num)
- num = num*100
- return math.floor(num+.5).."%"
- end
- writer = peripheral.wrap("right")
- while isRunning do
- if not writer.isPresent() then
- curState = 1
- else -- card ist present
- curState = 2
- if writer.getProgress() >0 then
- curState = 4
- elseif writer.isCoded() then
- curState = 5
- end
- end
- if curState == 2 then
- print("Card Ready. Enter data to write to card")
- data = read()
- print("Enter label ")
- label = read()
- curState = 3
- sleep(2)
- writer.encode(data, label)
- end
- term.clear()
- term.setCursorPos(1,1)
- print(state[curState])
- if curState == 4 then
- print(toPercent(writer.getProgress()))
- end
- sleep(2)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement